From b4ed55936a59319ded8b64dd7b294212b61542ee Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 26 Aug 2024 05:18:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#244=20refactor:=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/sharemind/payApp/presentation/PayAppController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/example/sharemind/payApp/presentation/PayAppController.java b/src/main/java/com/example/sharemind/payApp/presentation/PayAppController.java index 804fe00a..8dc8d62d 100644 --- a/src/main/java/com/example/sharemind/payApp/presentation/PayAppController.java +++ b/src/main/java/com/example/sharemind/payApp/presentation/PayAppController.java @@ -20,7 +20,7 @@ public String confirmConsult(HttpServletRequest request) { } @PostMapping("/posts") - public String testConfirmPost(HttpServletRequest request) { + public String confirmPost(HttpServletRequest request) { return payAppService.confirmPost(request); } } From bec5955b8aeda352b2b1f6160a4faaa6b1e26bf4 Mon Sep 17 00:00:00 2001 From: letskuku Date: Mon, 26 Aug 2024 05:19:07 +0900 Subject: [PATCH 2/2] =?UTF-8?q?#244=20refactor:=20=EA=B2=B0=EC=A0=9C=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=B0=BD=EC=9C=BC=EB=A1=9C=20=EB=A6=AC?= =?UTF-8?q?=EB=8B=A4=EC=9D=B4=EB=A0=89=ED=8A=B8=20=EB=90=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20responseEntity=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../consult/presentation/ConsultController.java | 10 +++++++--- .../sharemind/post/presentation/PostController.java | 9 +++++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/example/sharemind/consult/presentation/ConsultController.java b/src/main/java/com/example/sharemind/consult/presentation/ConsultController.java index aed7ed18..6c31e47f 100644 --- a/src/main/java/com/example/sharemind/consult/presentation/ConsultController.java +++ b/src/main/java/com/example/sharemind/consult/presentation/ConsultController.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -33,7 +34,7 @@ public class ConsultController { @Operation(summary = "상담 신청", description = "consult 생성") @ApiResponses({ - @ApiResponse(responseCode = "201", description = "신청 성공"), + @ApiResponse(responseCode = "301", description = "결제 url로 이동"), @ApiResponse(responseCode = "400", description = "1. 프로필 심사가 완료되지 않은 상담사 아이디로 요청됨\n 2. 상담사가 제공하지 않는 상담 유형\n 3. 자기자신에게 상담 요청", content = @Content(mediaType = "application/json", @@ -46,14 +47,17 @@ public class ConsultController { ) }) @PostMapping - public ResponseEntity createConsult( + public ResponseEntity createConsult( @Valid @RequestBody ConsultCreateRequest consultCreateRequest, @AuthenticationPrincipal CustomUserDetails customUserDetails) { Long paymentId = consultService.createConsult(consultCreateRequest, customUserDetails.getCustomer().getCustomerId()); String payUrl = payAppService.payConsult(paymentId); - return ResponseEntity.status(HttpStatus.CREATED).body(payUrl); + HttpHeaders headers = new HttpHeaders(); + headers.add(HttpHeaders.LOCATION, payUrl); + + return new ResponseEntity<>(headers, HttpStatus.MOVED_PERMANENTLY); } @Operation(summary = "상담사 진행 중인 상담 조회", description = "상담사 진행 중인 최근 상담 3개 조회") diff --git a/src/main/java/com/example/sharemind/post/presentation/PostController.java b/src/main/java/com/example/sharemind/post/presentation/PostController.java index dde54b91..93062a64 100644 --- a/src/main/java/com/example/sharemind/post/presentation/PostController.java +++ b/src/main/java/com/example/sharemind/post/presentation/PostController.java @@ -20,6 +20,7 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; @@ -38,6 +39,7 @@ public class PostController { @Operation(summary = "일대다 상담 질문 신청", description = "일대다 상담 질문 신청") @ApiResponses({ @ApiResponse(responseCode = "201", description = "신청 성공"), + @ApiResponse(responseCode = "301", description = "결제 url로 이동"), @ApiResponse(responseCode = "400", description = "요청 값 중 공백이 존재", content = @Content(mediaType = "application/json", @@ -49,7 +51,7 @@ public class PostController { ) }) @PostMapping - public ResponseEntity createPost( + public ResponseEntity createPost( @Valid @RequestBody PostCreateRequest postCreateRequest, @AuthenticationPrincipal CustomUserDetails customUserDetails) { Long postId = postService.createPost(postCreateRequest, @@ -60,7 +62,10 @@ public ResponseEntity createPost( } else { String payUrl = payAppService.payPost(postId); - return ResponseEntity.status(HttpStatus.CREATED).body(payUrl); + HttpHeaders headers = new HttpHeaders(); + headers.add(HttpHeaders.LOCATION, payUrl); + + return new ResponseEntity<>(headers, HttpStatus.MOVED_PERMANENTLY); } }