From 6932721c65629bd7a990d1d9572f2b05917b676a Mon Sep 17 00:00:00 2001 From: letskuku Date: Tue, 26 Mar 2024 01:46:29 +0900 Subject: [PATCH] =?UTF-8?q?#156=20feat:=20=EA=B5=AC=EB=A7=A4=EC=9E=90=20?= =?UTF-8?q?=EC=82=AC=EC=9D=B4=EB=93=9C=20=EC=9D=BC=EB=8C=80=EB=8B=A4=20?= =?UTF-8?q?=EC=83=81=EB=8B=B4=20=EB=8C=93=EA=B8=80=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=ED=95=98=EB=8A=94=20api=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/CommentController.java | 40 ++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/sharemind/comment/presentation/CommentController.java b/src/main/java/com/example/sharemind/comment/presentation/CommentController.java index 0584c0e7..49a962e9 100644 --- a/src/main/java/com/example/sharemind/comment/presentation/CommentController.java +++ b/src/main/java/com/example/sharemind/comment/presentation/CommentController.java @@ -34,19 +34,19 @@ public class CommentController { - 주소 형식: /api/v1/comments/counselors/1""") @ApiResponses({ @ApiResponse(responseCode = "200", description = "조회 성공"), - @ApiResponse(responseCode = "400", description = "1. 진행중이지 않은 상담 2. 마감된 상담 중 상담사 본인이 답변을 작성하지 않은 상담", + @ApiResponse(responseCode = "400", description = "1. 진행중이지 않은 상담\n 2. 마감된 상담 중 상담사 본인이 답변을 작성하지 않은 상담", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CustomExceptionResponse.class)) ) }) @Parameters({ - @Parameter(name = "postId", description = """ - - 일대다 상담 ID""") + @Parameter(name = "postId", description = "일대다 상담 ID") }) @GetMapping("/counselors/{postId}") public ResponseEntity> getCounselorComments(@PathVariable Long postId, - @AuthenticationPrincipal CustomUserDetails customUserDetails) { - return ResponseEntity.ok(commentService.getCommentsByPost(postId, customUserDetails.getCustomer().getCustomerId())); + @AuthenticationPrincipal CustomUserDetails customUserDetails) { + return ResponseEntity.ok(commentService.getCounselorComments(postId, + customUserDetails.getCustomer().getCustomerId())); } @Operation(summary = "상담사 사이드 일대다 상담 댓글 작성", description = """ @@ -54,15 +54,37 @@ public ResponseEntity> getCounselorComments(@PathVariab - 주소 형식: /api/v1/comments/counselors""") @ApiResponses({ @ApiResponse(responseCode = "201", description = "댓글 생성 성공"), - @ApiResponse(responseCode = "400", description = "1. 진행중이지 않은 상담 2. 마감된 상담 중 상담사 본인이 답변을 작성하지 않은 상담 3. 이미 답변을 작성한 상담", + @ApiResponse(responseCode = "400", description = "1. 진행중이지 않은 상담\n 2. 마감된 상담 중 상담사 본인이 답변을 작성하지 않은 상담 3. 이미 답변을 작성한 상담", content = @Content(mediaType = "application/json", schema = @Schema(implementation = CustomExceptionResponse.class)) ) }) @PostMapping("/counselors") - public ResponseEntity createComments(@RequestBody CommentCreateRequest commentCreateRequest, - @AuthenticationPrincipal CustomUserDetails customUserDetails) { - commentService.createComment(commentCreateRequest, customUserDetails.getCustomer().getCustomerId()); + public ResponseEntity createComments( + @RequestBody CommentCreateRequest commentCreateRequest, + @AuthenticationPrincipal CustomUserDetails customUserDetails) { + commentService.createComment(commentCreateRequest, + customUserDetails.getCustomer().getCustomerId()); return ResponseEntity.status(HttpStatus.CREATED).build(); } + + @Operation(summary = "구매자 사이드 일대다 상담 질문 단건의 댓글 목록 조회", description = """ + - 구매자&비로그인 사용자 일대다 상담 질문 단건의 댓글 목록 조회 + - 로그인한 사용자일 경우 헤더에 accessToken을 넣어주세요""") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "조회 성공"), + @ApiResponse(responseCode = "400", description = "접근 권한이 없는 상담(다른 회원의 비공개 상담 접근 시도)", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = CustomExceptionResponse.class)) + ) + }) + @Parameters({ + @Parameter(name = "postId", description = "일대다 상담 ID") + }) + @GetMapping("/customers/{postId}") + public ResponseEntity> getCustomerComments(@PathVariable Long postId, + @AuthenticationPrincipal CustomUserDetails customUserDetails) { + return ResponseEntity.ok(commentService.getCustomerComments(postId, + customUserDetails == null ? 0 : customUserDetails.getCustomer().getCustomerId())); + } }