Skip to content

Commit a370915

Browse files
authored
feat: base response 형식 적용 (#161)
* feat: S3 업로드, 조회 로직 구현 * fix: 매핑 url 오탈자 수정 * feat: base response 형식 적용 * style: 스타일 미적용 수정
1 parent 42c288c commit a370915

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed
Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package com.threestar.trainus.domain.file.controller;
22

33
import lombok.RequiredArgsConstructor;
4-
import org.springframework.http.HttpStatusCode;
4+
5+
import org.springframework.http.HttpStatus;
56
import org.springframework.http.ResponseEntity;
67
import org.springframework.web.bind.annotation.GetMapping;
78
import org.springframework.web.bind.annotation.RequestMapping;
@@ -11,6 +12,7 @@
1112
import com.threestar.trainus.domain.file.dto.GetS3UrlDto;
1213
import com.threestar.trainus.domain.file.service.S3Service;
1314
import com.threestar.trainus.global.annotation.LoginUser;
15+
import com.threestar.trainus.global.unit.BaseResponse;
1416

1517
@RestController
1618
@RequiredArgsConstructor
@@ -19,14 +21,14 @@ public class S3Controller {
1921
private final S3Service s3Service;
2022

2123
@GetMapping(value = "/posturl")
22-
public ResponseEntity<GetS3UrlDto> getPostS3Url(@LoginUser Long userId, String filename) {
23-
GetS3UrlDto getS3UrlDto = s3Service.getPostS3Url("image/"+userId, filename);
24-
return new ResponseEntity<>(getS3UrlDto, HttpStatusCode.valueOf(200));
24+
public ResponseEntity<BaseResponse<GetS3UrlDto>> getPostS3Url(@LoginUser Long userId, String filename) {
25+
GetS3UrlDto response = s3Service.getPostS3Url("image/" + userId, filename);
26+
return BaseResponse.ok("업로드용 presigned url 발급 완료", response, HttpStatus.OK);
2527
}
2628

2729
@GetMapping(value = "/geturl")
28-
public ResponseEntity<GetS3UrlDto> getGetS3Url(@LoginUser Long userId, @RequestParam String key) {
29-
GetS3UrlDto getS3UrlDto = s3Service.getGetS3Url(userId, key);
30-
return new ResponseEntity<>(getS3UrlDto, HttpStatusCode.valueOf(200));
30+
public ResponseEntity<BaseResponse<GetS3UrlDto>> getGetS3Url(@LoginUser Long userId, @RequestParam String key) {
31+
GetS3UrlDto response = s3Service.getGetS3Url(key);
32+
return BaseResponse.ok("조회용 presigned url 발급 완료", response, HttpStatus.OK);
3133
}
3234
}

src/main/java/com/threestar/trainus/domain/file/service/S3Service.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ private GeneratePresignedUrlRequest getGetGeneratePresignedUrlRequest(String key
8383
}
8484

8585
@Transactional(readOnly = true)
86-
public GetS3UrlDto getGetS3Url(Long memberId, String key) {
86+
public GetS3UrlDto getGetS3Url(String key) {
8787
// url 유효기간 설정하기(1시간)
8888
Date expiration = getExpiration();
8989

0 commit comments

Comments
 (0)