Skip to content

Commit

Permalink
Merge pull request #7 from DrinkHere/develop
Browse files Browse the repository at this point in the history
Develop to Main 1
  • Loading branch information
Jeongh00 authored Dec 6, 2024
2 parents 9ecec3d + bed2a9a commit f095d7a
Show file tree
Hide file tree
Showing 44 changed files with 1,359 additions and 12 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,15 @@ out/
!**/src/main/**/out/
!**/src/test/**/out/

# End of https://www.toptal.com/developers/gitignore/api/macos,intellij,java,intellij+all
**/src/main/resources/application-rds-local.yml
**/src/main/resources/application-rds-prod.yml
# End of https://www.toptal.com/developers/gitignore/api/macos,intellij,java,intellij+all

**/src/main/resources/application-redis-local.yml
**/src/main/resources/application-redis-prod.yml

**/src/main/resources/application-s3-local.yml
**/src/main/resources/application-s3-prod.yml

# 깃허브 서브모듈 관련 폴더 ignore
backend-submodule/
3 changes: 2 additions & 1 deletion api/api-health-check/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ jar {enabled = true}
dependencies {
implementation project(':domain:domain-rds')
implementation project(':infra:infra-redis')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation project(':infra:infra-s3')
implementation project(':monitoring')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.drinkhere.apihealthcheck;

import com.drinkhere.common.response.BaseSuccessStatus;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;

@Getter
@RequiredArgsConstructor
public enum TestSuccessStatus implements BaseSuccessStatus {
GET_PRESIGNED_SUCCESS(HttpStatus.OK, "GET 위한 Presigned URL 조회 성공");

private final HttpStatus httpStatus;
private final String message;

@Override
public int getStatusCode() {
return this.httpStatus.value();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.drinkhere.apihealthcheck.dto.request;

public record GetPresignedUrlRequest(
String fileName
) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.drinkhere.apihealthcheck.dto.response;

import com.drinkhere.infras3.aop.Interface.TransformToPresignedUrl;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

@AllArgsConstructor
@Getter
@TransformToPresignedUrl
public class GetPresignedUrlCollectionResponse {
private List<String> filePaths;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.drinkhere.apihealthcheck.dto.response;

import com.drinkhere.infras3.aop.Interface.TransformToPresignedUrl;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.List;

@AllArgsConstructor
@Getter
@TransformToPresignedUrl
public class GetPresignedUrlResponse {
private String filePath;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
package com.drinkhere.apihealthcheck.presentations;

import com.drinkhere.apihealthcheck.TestSuccessStatus;
import com.drinkhere.apihealthcheck.dto.request.GetPresignedUrlRequest;
import com.drinkhere.apihealthcheck.dto.response.GetPresignedUrlCollectionResponse;
import com.drinkhere.apihealthcheck.dto.response.GetPresignedUrlResponse;
import com.drinkhere.common.response.ApiResponse;
import com.drinkhere.infraredis.util.RedisUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.drinkhere.infras3.application.PresignedUrlService;
import lombok.*;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/api/v1/health-check")
@RequiredArgsConstructor
public class HealthCheckController {

private final RedisUtil redisUtil;
private final PresignedUrlService presignedUrlService;

@GetMapping
public String healthCheck() {
return "This Turn is Green!";
Expand All @@ -30,4 +39,38 @@ public String redisConnectionCheck() {
return "No value found for key 'id1'";
}
}

@PostMapping("/presigned")
public ResponseEntity<ApiResponse<GetPresignedUrlResponse>> getPresignedUrl(
@RequestBody GetPresignedUrlRequest getPresignedUrlRequest
) {
System.out.println("getPresignedUrl.filePath() = " + getPresignedUrlRequest.fileName());

String presignedUrlForGet = presignedUrlService.getPresignedUrlForGet( getPresignedUrlRequest.fileName());

System.out.println("presignedUrlForGet = " + presignedUrlForGet);

com.drinkhere.apihealthcheck.dto.response.GetPresignedUrlResponse getPresignedUrlResponse = new com.drinkhere.apihealthcheck.dto.response.GetPresignedUrlResponse(getPresignedUrlRequest.fileName());

return ApiResponse.success(TestSuccessStatus.GET_PRESIGNED_SUCCESS, getPresignedUrlResponse);
}

@PostMapping("/presigned/collection")
public ResponseEntity<ApiResponse<GetPresignedUrlCollectionResponse>> getPresignedUrlCollection(
@RequestBody GetPresignedUrlRequest getPresignedUrlRequest
) {
System.out.println("getPresignedUrl.filePath() = " + getPresignedUrlRequest.fileName());

String presignedUrlForGet = presignedUrlService.getPresignedUrlForGet(getPresignedUrlRequest.fileName());

System.out.println("presignedUrlForGet = " + presignedUrlForGet);
ArrayList<String> list = new ArrayList<>();
GetPresignedUrlCollectionResponse getPresignedUrlResponse = new GetPresignedUrlCollectionResponse(list);
getPresignedUrlResponse.getFilePaths().add(getPresignedUrlRequest.fileName());
getPresignedUrlResponse.getFilePaths().add(getPresignedUrlRequest.fileName());
// 리스트를 포함한 ApiResponse 반환
return ApiResponse.success(TestSuccessStatus.GET_PRESIGNED_SUCCESS, getPresignedUrlResponse);
}


}
14 changes: 10 additions & 4 deletions api/api-health-check/src/main/resources/application-hc-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ spring:
name: api-health-check

management:
endpoint:
health:
show-details: always
endpoints:
web:
exposure:
include: "*"
include: health,metrics,prometheus
metrics:
export:
cors:
allowed-origins: "*"
allowed-methods: GET
prometheus:
metrics:
export:
enabled: true
2 changes: 1 addition & 1 deletion backend-submodule
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,10 @@ task copyPrivate(type: Copy) {
include "application-redis-prod.yml"
into 'infra/infra-redis/src/main/resources'
}

copy {
from './backend-submodule'
include "application-s3-prod.yml"
into 'infra/infra-s3/src/main/resources'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import java.io.IOException;

@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@Component
public class HttpResponseUtil {

Expand Down
2 changes: 2 additions & 0 deletions execute/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ spring:
import:
- application-rds-local.yml
- application-redis-local.yml
- application-s3-local.yml
- application-hc-local.yml

logging:
Expand All @@ -34,6 +35,7 @@ spring:
import:
- application-rds-prod.yml
- application-redis-prod.yml
- application-s3-prod.yml
- application-hc-prod.yml

logging:
Expand Down
3 changes: 3 additions & 0 deletions infra/infra-s3/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
37 changes: 37 additions & 0 deletions infra/infra-s3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/
11 changes: 11 additions & 0 deletions infra/infra-s3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
bootJar { enabled = false }
jar { enabled = true }

dependencies {
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.4'
implementation 'io.awspring.cloud:spring-cloud-starter-aws-secrets-manager-config:2.4.4'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-aop'
}

tasks.register("prepareKotlinBuildScriptModel"){}
Binary file added infra/infra-s3/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions infra/infra-s3/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit f095d7a

Please sign in to comment.