Skip to content

Commit

Permalink
#244 refactor: 결제 요청 창으로 리다이렉트 되도록 responseEntity 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
letskuku committed Aug 25, 2024
1 parent b4ed559 commit bec5955
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand All @@ -46,14 +47,17 @@ public class ConsultController {
)
})
@PostMapping
public ResponseEntity<String> createConsult(
public ResponseEntity<Void> 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개 조회")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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",
Expand All @@ -49,7 +51,7 @@ public class PostController {
)
})
@PostMapping
public ResponseEntity<?> createPost(
public ResponseEntity<Void> createPost(
@Valid @RequestBody PostCreateRequest postCreateRequest,
@AuthenticationPrincipal CustomUserDetails customUserDetails) {
Long postId = postService.createPost(postCreateRequest,
Expand All @@ -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);
}
}

Expand Down

0 comments on commit bec5955

Please sign in to comment.