From 490780f70abc16a91eb2c613b475de2345614e4f Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 15:57:06 +0900 Subject: [PATCH 01/10] =?UTF-8?q?feat:=20=EB=82=B4=EA=B0=80=20=EC=93=B4=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=AA=A9=EB=A1=9D=20DTO,=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/controller/ReviewController.java | 13 +++++++++++++ .../review/service/ReviewListLookupService.java | 7 ++++++- .../list/WrittenReviewElementResponse.java | 14 ++++++++++++++ .../dto/response/list/WrittenReviewsResponse.java | 11 +++++++++++ 4 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewElementResponse.java create mode 100644 backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewsResponse.java diff --git a/backend/src/main/java/reviewme/review/controller/ReviewController.java b/backend/src/main/java/reviewme/review/controller/ReviewController.java index 1b31af214..bf5718038 100644 --- a/backend/src/main/java/reviewme/review/controller/ReviewController.java +++ b/backend/src/main/java/reviewme/review/controller/ReviewController.java @@ -20,6 +20,7 @@ import reviewme.review.service.dto.response.gathered.ReviewsGatheredBySectionResponse; import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; import reviewme.review.service.dto.response.list.ReceivedReviewsSummaryResponse; +import reviewme.review.service.dto.response.list.WrittenReviewsResponse; import reviewme.reviewgroup.controller.ReviewGroupSession; import reviewme.reviewgroup.domain.ReviewGroup; @@ -75,4 +76,16 @@ public ResponseEntity getReceivedReviewsBySect reviewGatheredLookupService.getReceivedReviewsBySectionId(reviewGroup, sectionId); return ResponseEntity.ok(response); } + + @GetMapping("/v2/written") + public ResponseEntity findWrittenReviews( + @RequestParam(required = false) Long lastReviewId, + @RequestParam(required = false) Integer size +// @MemberSession Member member + // TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요 + ) { + WrittenReviewsResponse response = reviewListLookupService.getWrittenReviews(lastReviewId, size); + return ResponseEntity.ok(response); + } + } diff --git a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java index d576e9eeb..ca5c16562 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java @@ -7,14 +7,15 @@ import reviewme.review.repository.ReviewRepository; import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; import reviewme.review.service.dto.response.list.ReviewListElementResponse; +import reviewme.review.service.dto.response.list.WrittenReviewsResponse; import reviewme.review.service.mapper.ReviewListMapper; import reviewme.reviewgroup.domain.ReviewGroup; @Service @RequiredArgsConstructor public class ReviewListLookupService { - private final ReviewRepository reviewRepository; + private final ReviewListMapper reviewListMapper; @Transactional(readOnly = true) @@ -29,6 +30,10 @@ public ReceivedReviewsResponse getReceivedReviews(Long lastReviewId, Integer siz ); } + public WrittenReviewsResponse getWrittenReviews(Long lastReviewId, Integer size) { + return null; + } + private long calculateLastReviewId(List elements) { if (elements.isEmpty()) { return 0; diff --git a/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewElementResponse.java b/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewElementResponse.java new file mode 100644 index 000000000..8f9f59757 --- /dev/null +++ b/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewElementResponse.java @@ -0,0 +1,14 @@ +package reviewme.review.service.dto.response.list; + +import java.time.LocalDate; +import java.util.List; + +public record WrittenReviewElementResponse( + long reviewId, + String revieweeName, + String projectName, + LocalDate createdAt, + String contentPreview, + List categories +) { +} diff --git a/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewsResponse.java b/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewsResponse.java new file mode 100644 index 000000000..04a0c3553 --- /dev/null +++ b/backend/src/main/java/reviewme/review/service/dto/response/list/WrittenReviewsResponse.java @@ -0,0 +1,11 @@ +package reviewme.review.service.dto.response.list; + +import java.util.List; + +public record WrittenReviewsResponse( + long memberId, + List reviews, + long lastReviewId, + boolean isLastPage +) { +} From 1585e9458936409cb2b77998db047ef0a4a0f665 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 16:10:03 +0900 Subject: [PATCH 02/10] =?UTF-8?q?docs:=20=EB=82=B4=EA=B0=80=20=EC=93=B4=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EB=AA=A9=EB=A1=9D=20api=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/asciidoc/review-list.adoc | 4 ++ .../test/java/reviewme/api/ReviewApiTest.java | 61 ++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/backend/src/docs/asciidoc/review-list.adoc b/backend/src/docs/asciidoc/review-list.adoc index 3d8648566..229c3d34d 100644 --- a/backend/src/docs/asciidoc/review-list.adoc +++ b/backend/src/docs/asciidoc/review-list.adoc @@ -1,3 +1,7 @@ ==== 자신이 받은 리뷰 목록 조회 operation::received-review-list-with-pagination[snippets="curl-request,request-cookies,query-parameters,http-response,response-fields"] + +==== 자신이 작성한 리뷰 목록 조회 + +operation::written-review-list-with-pagination[snippets="curl-request,query-parameters,http-response,response-fields"] diff --git a/backend/src/test/java/reviewme/api/ReviewApiTest.java b/backend/src/test/java/reviewme/api/ReviewApiTest.java index e05935d43..f30d14960 100644 --- a/backend/src/test/java/reviewme/api/ReviewApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewApiTest.java @@ -21,7 +21,6 @@ import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.request.ParameterDescriptor; -import reviewme.template.domain.QuestionType; import reviewme.review.service.dto.request.ReviewRegisterRequest; import reviewme.review.service.dto.response.gathered.HighlightResponse; import reviewme.review.service.dto.response.gathered.RangeResponse; @@ -34,7 +33,10 @@ import reviewme.review.service.dto.response.list.ReceivedReviewsSummaryResponse; import reviewme.review.service.dto.response.list.ReviewCategoryResponse; import reviewme.review.service.dto.response.list.ReviewListElementResponse; +import reviewme.review.service.dto.response.list.WrittenReviewElementResponse; +import reviewme.review.service.dto.response.list.WrittenReviewsResponse; import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException; +import reviewme.template.domain.QuestionType; class ReviewApiTest extends ApiTest { @@ -314,4 +316,61 @@ class ReviewApiTest extends ApiTest { .apply(handler) .statusCode(200); } + + @Test + void 자신이_작성한_리뷰_목록을_조회한다() { + List writtenReviews = List.of( + new WrittenReviewElementResponse(1L, "테드1", "리뷰미", LocalDate.of(2024, 8, 1), "(리뷰 미리보기 1)", + List.of(new ReviewCategoryResponse(1L, "카테고리 1"))), + new WrittenReviewElementResponse(2L, "테드2", "리뷰미", LocalDate.of(2024, 8, 2), "(리뷰 미리보기 2)", + List.of(new ReviewCategoryResponse(2L, "카테고리 2"))) + ); + WrittenReviewsResponse response = new WrittenReviewsResponse( + 1L, writtenReviews, 1L, true); + BDDMockito.given(reviewListLookupService.getWrittenReviews(anyLong(), anyInt())) + .willReturn(response); + +// CookieDescriptor[] cookieDescriptors = { +// cookieWithName("JSESSIONID").description("세션 ID") +// }; + + ParameterDescriptor[] queryParameter = { + parameterWithName("lastReviewId").description("페이지의 마지막 리뷰 ID - 기본으로 최신순 첫번째 페이지 응답"), + parameterWithName("size").description("페이지의 크기 - 기본으로 10개씩 응답") + }; + + FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("memberId").description("회원 ID"), + fieldWithPath("lastReviewId").description("페이지의 마지막 리뷰 ID"), + fieldWithPath("isLastPage").description("마지막 페이지 여부"), + + fieldWithPath("reviews[]").description("리뷰 목록"), + fieldWithPath("reviews[].reviewId").description("리뷰 ID"), + fieldWithPath("reviews[].createdAt").description("리뷰 작성 날짜"), + fieldWithPath("reviews[].contentPreview").description("리뷰 미리보기"), + fieldWithPath("reviews[].revieweeName").description("리뷰이 이름"), + fieldWithPath("reviews[].projectName").description("프로젝트명"), + + fieldWithPath("reviews[].categories[]").description("카테고리 목록"), + fieldWithPath("reviews[].categories[].optionId").description("카테고리 ID"), + fieldWithPath("reviews[].categories[].content").description("카테고리 내용") + }; + + RestDocumentationResultHandler handler = document( + "written-review-list-with-pagination", +// requestCookies(cookieDescriptors), + queryParameters(queryParameter), + responseFields(responseFieldDescriptors) + ); + + givenWithSpec().log().all() +// .cookie("JSESSIONID", "ASVNE1VAKDNV4") +// .queryParam("reviewRequestCode", "hello!!") + .queryParam("lastReviewId", "2") + .queryParam("size", "5") + .when().get("/v2/written") + .then().log().all() + .apply(handler) + .statusCode(200); + } } From 3eff679dafb93715b44eeba72bdc3047218b8b36 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 16:31:47 +0900 Subject: [PATCH 03/10] =?UTF-8?q?refactor:=20=EA=B8=B0=EC=A1=B4=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EA=B7=B8=EB=A3=B9=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9D=84=20=EB=B9=84=ED=9A=8C=EC=9B=90=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EC=83=9D=EC=84=B1=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/asciidoc/reviewgroup.adoc | 3 ++- .../reviewgroup/controller/ReviewGroupController.java | 7 ++++--- .../reviewme/reviewgroup/service/ReviewGroupService.java | 5 +++-- ...nRequest.java => GuestReviewGroupCreationRequest.java} | 2 +- .../src/test/java/reviewme/api/ReviewGroupApiTest.java | 8 ++++---- .../reviewgroup/service/ReviewGroupServiceTest.java | 6 +++--- 6 files changed, 17 insertions(+), 14 deletions(-) rename backend/src/main/java/reviewme/reviewgroup/service/dto/{ReviewGroupCreationRequest.java => GuestReviewGroupCreationRequest.java} (90%) diff --git a/backend/src/docs/asciidoc/reviewgroup.adoc b/backend/src/docs/asciidoc/reviewgroup.adoc index c3eb2f803..a55fb436b 100644 --- a/backend/src/docs/asciidoc/reviewgroup.adoc +++ b/backend/src/docs/asciidoc/reviewgroup.adoc @@ -1,6 +1,7 @@ -==== 리뷰 그룹 생성 +==== 비회원용 리뷰 그룹 생성 operation::review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] +operation::guest-review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] ==== 리뷰 그룹 간단 정보 조회 diff --git a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java index b6c7a973c..ff9c26ec3 100644 --- a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java +++ b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java @@ -13,7 +13,8 @@ import reviewme.reviewgroup.service.ReviewGroupLookupService; import reviewme.reviewgroup.service.ReviewGroupService; import reviewme.reviewgroup.service.dto.CheckValidAccessRequest; -import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.GuestReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.MemberReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; @@ -32,9 +33,9 @@ public ResponseEntity getReviewGroupSummary(@RequestParam S @PostMapping("/v2/groups") public ResponseEntity createReviewGroup( - @Valid @RequestBody ReviewGroupCreationRequest request + @Valid @RequestBody GuestReviewGroupCreationRequest request ) { - ReviewGroupCreationResponse response = reviewGroupService.createReviewGroup(request); + ReviewGroupCreationResponse response = reviewGroupService.createGuestReviewGroup(request); return ResponseEntity.ok(response); } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java index 86303197c..45a3e0809 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java @@ -3,12 +3,13 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import reviewme.reviewgroup.service.dto.MemberReviewGroupCreationRequest; import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException; import reviewme.reviewgroup.service.exception.ReviewGroupUnauthorizedException; import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; import reviewme.reviewgroup.service.dto.CheckValidAccessRequest; -import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.GuestReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; import reviewme.template.domain.Template; import reviewme.template.repository.TemplateRepository; @@ -26,7 +27,7 @@ public class ReviewGroupService { private final TemplateRepository templateRepository; @Transactional - public ReviewGroupCreationResponse createReviewGroup(ReviewGroupCreationRequest request) { + public ReviewGroupCreationResponse createGuestReviewGroup(GuestReviewGroupCreationRequest request) { String reviewRequestCode; do { reviewRequestCode = randomCodeGenerator.generate(REVIEW_REQUEST_CODE_LENGTH); diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupCreationRequest.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/GuestReviewGroupCreationRequest.java similarity index 90% rename from backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupCreationRequest.java rename to backend/src/main/java/reviewme/reviewgroup/service/dto/GuestReviewGroupCreationRequest.java index c31a70f04..c213caf59 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupCreationRequest.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/GuestReviewGroupCreationRequest.java @@ -3,7 +3,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; -public record ReviewGroupCreationRequest( +public record GuestReviewGroupCreationRequest( @NotEmpty(message = "리뷰이 이름을 입력해주세요.") String revieweeName, diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index e87cb8b5c..3695a837f 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -18,15 +18,15 @@ import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.request.ParameterDescriptor; -import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.GuestReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; class ReviewGroupApiTest extends ApiTest { @Test - void 리뷰_그룹을_생성한다() { - BDDMockito.given(reviewGroupService.createReviewGroup(any(ReviewGroupCreationRequest.class))) + void 비회원용_리뷰_그룹을_생성한다() { + BDDMockito.given(reviewGroupService.createGuestReviewGroup(any(GuestReviewGroupCreationRequest.class))) .willReturn(new ReviewGroupCreationResponse("ABCD1234")); String request = """ @@ -48,7 +48,7 @@ class ReviewGroupApiTest extends ApiTest { }; RestDocumentationResultHandler handler = document( - "review-group-create", + "guest-review-group-create", requestFields(requestFieldDescriptors), responseFields(responseFieldDescriptors) ); diff --git a/backend/src/test/java/reviewme/reviewgroup/service/ReviewGroupServiceTest.java b/backend/src/test/java/reviewme/reviewgroup/service/ReviewGroupServiceTest.java index 83b399682..5e93e39bd 100644 --- a/backend/src/test/java/reviewme/reviewgroup/service/ReviewGroupServiceTest.java +++ b/backend/src/test/java/reviewme/reviewgroup/service/ReviewGroupServiceTest.java @@ -22,7 +22,7 @@ import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; import reviewme.reviewgroup.service.dto.CheckValidAccessRequest; -import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.GuestReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; import reviewme.support.ServiceTest; import reviewme.template.repository.TemplateRepository; @@ -52,10 +52,10 @@ class ReviewGroupServiceTest { .willReturn("0000") // ReviewRequestCode .willReturn("AAAA"); - ReviewGroupCreationRequest request = new ReviewGroupCreationRequest("sancho", "reviewme", "groupAccessCode"); + GuestReviewGroupCreationRequest request = new GuestReviewGroupCreationRequest("sancho", "reviewme", "groupAccessCode"); // when - ReviewGroupCreationResponse response = reviewGroupService.createReviewGroup(request); + ReviewGroupCreationResponse response = reviewGroupService.createGuestReviewGroup(request); // then assertThat(response).isEqualTo(new ReviewGroupCreationResponse("AAAA")); From 5dd5322d46b606e3ff8b2b1817a96ad26417c0a8 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 16:33:25 +0900 Subject: [PATCH 04/10] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=EC=9A=A9=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EC=83=9D=EC=84=B1=20DTO,=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ReviewGroupController.java | 8 ++++++++ .../reviewgroup/service/ReviewGroupService.java | 4 ++++ .../dto/MemberReviewGroupCreationRequest.java | 13 +++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 backend/src/main/java/reviewme/reviewgroup/service/dto/MemberReviewGroupCreationRequest.java diff --git a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java index ff9c26ec3..52d383169 100644 --- a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java +++ b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java @@ -38,6 +38,14 @@ public ResponseEntity createReviewGroup( ReviewGroupCreationResponse response = reviewGroupService.createGuestReviewGroup(request); return ResponseEntity.ok(response); } + + @PostMapping("/v2/groups/member") + public ResponseEntity createReviewGroup( + @Valid @RequestBody MemberReviewGroupCreationRequest request + ) { + ReviewGroupCreationResponse response = reviewGroupService.createMemberReviewGroup(request); + return ResponseEntity.ok(response); + } @PostMapping("/v2/groups/check") public ResponseEntity checkGroupAccessCode( diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java index 45a3e0809..0f691f88b 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupService.java @@ -45,6 +45,10 @@ public ReviewGroupCreationResponse createGuestReviewGroup(GuestReviewGroupCreati return new ReviewGroupCreationResponse(reviewGroup.getReviewRequestCode()); } + public ReviewGroupCreationResponse createMemberReviewGroup(MemberReviewGroupCreationRequest request) { + return null; + } + @Transactional(readOnly = true) public void checkGroupAccessCode(CheckValidAccessRequest request) { ReviewGroup reviewGroup = reviewGroupRepository.findByReviewRequestCode(request.reviewRequestCode()) diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/MemberReviewGroupCreationRequest.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/MemberReviewGroupCreationRequest.java new file mode 100644 index 000000000..c76c3c19c --- /dev/null +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/MemberReviewGroupCreationRequest.java @@ -0,0 +1,13 @@ +package reviewme.reviewgroup.service.dto; + +import jakarta.validation.constraints.NotEmpty; + +public record MemberReviewGroupCreationRequest( + + @NotEmpty(message = "리뷰이 이름을 입력해주세요.") + String revieweeName, + + @NotEmpty(message = "프로젝트 이름을 입력해주세요.") + String projectName +) { +} From b1c5cb4fbd0f62fee63153fcf40e78b713ff47e9 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 16:41:04 +0900 Subject: [PATCH 05/10] =?UTF-8?q?docs:=20=ED=9A=8C=EC=9B=90=EC=9A=A9=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EC=83=9D=EC=84=B1=20api=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/asciidoc/reviewgroup.adoc | 5 ++- .../java/reviewme/api/ReviewGroupApiTest.java | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/backend/src/docs/asciidoc/reviewgroup.adoc b/backend/src/docs/asciidoc/reviewgroup.adoc index a55fb436b..2b6bd342b 100644 --- a/backend/src/docs/asciidoc/reviewgroup.adoc +++ b/backend/src/docs/asciidoc/reviewgroup.adoc @@ -1,8 +1,11 @@ ==== 비회원용 리뷰 그룹 생성 -operation::review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] operation::guest-review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] +==== 회원용 리뷰 그룹 생성 + +operation::member-review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] + ==== 리뷰 그룹 간단 정보 조회 operation::review-group-summary[snippets="curl-request,http-response,response-fields"] diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index 3695a837f..03f29fceb 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -19,6 +19,7 @@ import org.springframework.restdocs.payload.FieldDescriptor; import org.springframework.restdocs.request.ParameterDescriptor; import reviewme.reviewgroup.service.dto.GuestReviewGroupCreationRequest; +import reviewme.reviewgroup.service.dto.MemberReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; @@ -61,6 +62,41 @@ class ReviewGroupApiTest extends ApiTest { .statusCode(200); } + @Test + void 회원용_리뷰_그룹을_생성한다() { + BDDMockito.given(reviewGroupService.createMemberReviewGroup(any(MemberReviewGroupCreationRequest.class))) + .willReturn(new ReviewGroupCreationResponse("ABCD1234")); + + String request = """ + { + "revieweeName": "아루", + "projectName": "리뷰미" + } + """; + + FieldDescriptor[] requestFieldDescriptors = { + fieldWithPath("revieweeName").description("리뷰이 이름"), + fieldWithPath("projectName").description("프로젝트 이름") + }; + + FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("reviewRequestCode").description("리뷰 요청 코드") + }; + + RestDocumentationResultHandler handler = document( + "member-review-group-create", + requestFields(requestFieldDescriptors), + responseFields(responseFieldDescriptors) + ); + + givenWithSpec().log().all() + .body(request) + .when().post("/v2/groups/member") + .then().log().all() + .apply(handler) + .statusCode(200); + } + @Test void 리뷰_요청_코드로_리뷰_그룹_정보를_반환한다() { BDDMockito.given(reviewGroupLookupService.getReviewGroupSummary(anyString())) From 4e3f3dff854f08591cfa5ce57d078a167b5cc98d Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 20:42:40 +0900 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?api=EB=A5=BC=20=ED=9A=8C=EC=9B=90,=20=EB=B9=84=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/asciidoc/reviewgroup.adoc | 8 +++-- .../service/ReviewGroupLookupService.java | 2 +- .../service/dto/ReviewGroupResponse.java | 3 ++ .../java/reviewme/api/ReviewGroupApiTest.java | 36 +++++++++++++++++-- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/backend/src/docs/asciidoc/reviewgroup.adoc b/backend/src/docs/asciidoc/reviewgroup.adoc index 2b6bd342b..4c6661ad9 100644 --- a/backend/src/docs/asciidoc/reviewgroup.adoc +++ b/backend/src/docs/asciidoc/reviewgroup.adoc @@ -6,9 +6,13 @@ operation::guest-review-group-create[snippets="curl-request,request-fields,http- operation::member-review-group-create[snippets="curl-request,request-fields,http-response,response-fields"] -==== 리뷰 그룹 간단 정보 조회 +==== 회원이 만든 리뷰 그룹 간단 정보 조회 -operation::review-group-summary[snippets="curl-request,http-response,response-fields"] +operation::member-review-group-summary[snippets="curl-request,http-response,response-fields"] + +==== 비회원이 만든 리뷰 그룹 간단 정보 조회 + +operation::guest-review-group-summary[snippets="curl-request,http-response,response-fields"] ==== 리뷰 요청 코드, 확인 코드 일치 여부 diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java index 0567f6344..539c3a03c 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java @@ -19,6 +19,6 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) { ReviewGroup reviewGroup = reviewGroupRepository.findByReviewRequestCode(reviewRequestCode) .orElseThrow(() -> new ReviewGroupNotFoundByReviewRequestCodeException(reviewRequestCode)); - return new ReviewGroupResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName()); + return new ReviewGroupResponse(null, reviewGroup.getReviewee(), reviewGroup.getProjectName()); } } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupResponse.java index ea6f12a29..4d1accfbf 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupResponse.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupResponse.java @@ -1,7 +1,10 @@ package reviewme.reviewgroup.service.dto; +import jakarta.annotation.Nullable; + public record ReviewGroupResponse( + @Nullable Long revieweeId, String revieweeName, String projectName ) { diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index 03f29fceb..d82b990f7 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -98,21 +98,51 @@ class ReviewGroupApiTest extends ApiTest { } @Test - void 리뷰_요청_코드로_리뷰_그룹_정보를_반환한다() { + void 리뷰_요청_코드로_회원이_만든_리뷰_그룹_정보를_반환한다() { BDDMockito.given(reviewGroupLookupService.getReviewGroupSummary(anyString())) - .willReturn(new ReviewGroupResponse("아루", "리뷰미")); + .willReturn(new ReviewGroupResponse(1L,"아루", "리뷰미")); ParameterDescriptor[] parameterDescriptors = { parameterWithName("reviewRequestCode").description("리뷰 요청 코드") }; FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("revieweeId").description("리뷰이 ID"), fieldWithPath("revieweeName").description("리뷰이 이름"), fieldWithPath("projectName").description("프로젝트 이름") }; RestDocumentationResultHandler handler = document( - "review-group-summary", + "member-review-group-summary", + queryParameters(parameterDescriptors), + responseFields(responseFieldDescriptors) + ); + + givenWithSpec().log().all() + .queryParam("reviewRequestCode", "ABCD1234") + .when().get("/v2/groups") + .then().log().all() + .apply(handler) + .statusCode(200); + } + + @Test + void 리뷰_요청_코드로_비회원이_만든_리뷰_그룹_정보를_반환한다() { + BDDMockito.given(reviewGroupLookupService.getReviewGroupSummary(anyString())) + .willReturn(new ReviewGroupResponse(null, "아루", "리뷰미")); + + ParameterDescriptor[] parameterDescriptors = { + parameterWithName("reviewRequestCode").description("리뷰 요청 코드") + }; + + FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("revieweeId").description("리뷰이 ID"), + fieldWithPath("revieweeName").description("리뷰이 이름"), + fieldWithPath("projectName").description("프로젝트 이름") + }; + + RestDocumentationResultHandler handler = document( + "guest-review-group-summary", queryParameters(parameterDescriptors), responseFields(responseFieldDescriptors) ); From bd2d97aed02217e25de0c838797c2b315e5c0378 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 19 Dec 2024 21:06:22 +0900 Subject: [PATCH 07/10] =?UTF-8?q?refactor:=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20api=EB=A5=BC=20=EC=83=9D=EC=84=B1=EC=9E=90?= =?UTF-8?q?=EA=B0=80=20=ED=9A=8C=EC=9B=90,=20=EB=B9=84=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/docs/asciidoc/create-review.adoc | 8 +++-- .../review/controller/ReviewController.java | 8 ++++- .../test/java/reviewme/api/ReviewApiTest.java | 31 +++++++++++++++++-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/backend/src/docs/asciidoc/create-review.adoc b/backend/src/docs/asciidoc/create-review.adoc index 7b3464613..e05ef1b90 100644 --- a/backend/src/docs/asciidoc/create-review.adoc +++ b/backend/src/docs/asciidoc/create-review.adoc @@ -1,6 +1,10 @@ -==== 리뷰 생성 +==== 비회원이 리뷰 생성 -operation::create-review[snippets="curl-request,request-fields,http-response"] +operation::create-review-by-guest[snippets="curl-request,request-fields,http-response"] + +==== 회원이 리뷰 생성 + +operation::create-review-by-member[snippets="curl-request,request-fields,http-response"] ==== 그룹 코드가 올바르지 않은 경우 diff --git a/backend/src/main/java/reviewme/review/controller/ReviewController.java b/backend/src/main/java/reviewme/review/controller/ReviewController.java index bf5718038..8b984fc04 100644 --- a/backend/src/main/java/reviewme/review/controller/ReviewController.java +++ b/backend/src/main/java/reviewme/review/controller/ReviewController.java @@ -40,6 +40,13 @@ public ResponseEntity createReview(@Valid @RequestBody ReviewRegisterReque return ResponseEntity.created(URI.create("/reviews/" + savedReviewId)).build(); } + @PostMapping("/v2/reviews/member") + public ResponseEntity createReviewByMember(@Valid @RequestBody ReviewRegisterRequest request) { + // 회원 세션 추후 추가해야 함 + long savedReviewId = reviewRegisterService.registerReview(request); + return ResponseEntity.created(URI.create("/reviews/" + savedReviewId)).build(); + } + @GetMapping("/v2/reviews") public ResponseEntity findReceivedReviews( @RequestParam(required = false) Long lastReviewId, @@ -87,5 +94,4 @@ public ResponseEntity findWrittenReviews( WrittenReviewsResponse response = reviewListLookupService.getWrittenReviews(lastReviewId, size); return ResponseEntity.ok(response); } - } diff --git a/backend/src/test/java/reviewme/api/ReviewApiTest.java b/backend/src/test/java/reviewme/api/ReviewApiTest.java index f30d14960..e003db2a3 100644 --- a/backend/src/test/java/reviewme/api/ReviewApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewApiTest.java @@ -57,7 +57,7 @@ class ReviewApiTest extends ApiTest { """; @Test - void 리뷰를_등록한다() { + void 비회원이_리뷰를_등록한다() { BDDMockito.given(reviewRegisterService.registerReview(any(ReviewRegisterRequest.class))) .willReturn(1L); @@ -71,7 +71,7 @@ class ReviewApiTest extends ApiTest { }; RestDocumentationResultHandler handler = document( - "create-review", + "create-review-by-guest", requestFields(requestFieldDescriptors) ); @@ -83,6 +83,33 @@ class ReviewApiTest extends ApiTest { .statusCode(201); } + @Test + void 회원이_리뷰를_등록한다() { + BDDMockito.given(reviewRegisterService.registerReview(any(ReviewRegisterRequest.class))) + .willReturn(1L); + + FieldDescriptor[] requestFieldDescriptors = { + fieldWithPath("reviewRequestCode").description("리뷰 요청 코드"), + + fieldWithPath("answers[]").description("답변 목록"), + fieldWithPath("answers[].questionId").description("질문 ID"), + fieldWithPath("answers[].selectedOptionIds").description("선택한 옵션 ID 목록").optional(), + fieldWithPath("answers[].text").description("서술 답변").optional() + }; + + RestDocumentationResultHandler handler = document( + "create-review-by-member", + requestFields(requestFieldDescriptors) + ); + + givenWithSpec().log().all() + .body(request) + .when().post("/v2/reviews/member") + .then().log().all() + .apply(handler) + .statusCode(201); + } + @Test void 리뷰_그룹_코드가_올바르지_않은_경우_예외가_발생한다() { BDDMockito.given(reviewRegisterService.registerReview(any(ReviewRegisterRequest.class))) From 1d05f2af715668c92b8d2c8ef06b13a959ab3217 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 20 Dec 2024 17:46:18 +0900 Subject: [PATCH 08/10] =?UTF-8?q?fix:=20=EC=83=9D=EC=84=B1=EC=9D=BC?= =?UTF-8?q?=EC=9E=90=20=EC=B5=9C=EC=8B=A0=EC=88=9C=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EB=B0=98=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reviewme/review/service/ReviewListLookupService.java | 1 + backend/src/test/java/reviewme/api/ReviewApiTest.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java index ca5c16562..9360bfc37 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java @@ -31,6 +31,7 @@ public ReceivedReviewsResponse getReceivedReviews(Long lastReviewId, Integer siz } public WrittenReviewsResponse getWrittenReviews(Long lastReviewId, Integer size) { + // TODO: 생성일자 최신순 정렬 return null; } diff --git a/backend/src/test/java/reviewme/api/ReviewApiTest.java b/backend/src/test/java/reviewme/api/ReviewApiTest.java index e003db2a3..f2fbc94e3 100644 --- a/backend/src/test/java/reviewme/api/ReviewApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewApiTest.java @@ -347,9 +347,9 @@ class ReviewApiTest extends ApiTest { @Test void 자신이_작성한_리뷰_목록을_조회한다() { List writtenReviews = List.of( - new WrittenReviewElementResponse(1L, "테드1", "리뷰미", LocalDate.of(2024, 8, 1), "(리뷰 미리보기 1)", + new WrittenReviewElementResponse(1L, "테드1", "리뷰미", LocalDate.of(2024, 8, 2), "(리뷰 미리보기 1)", List.of(new ReviewCategoryResponse(1L, "카테고리 1"))), - new WrittenReviewElementResponse(2L, "테드2", "리뷰미", LocalDate.of(2024, 8, 2), "(리뷰 미리보기 2)", + new WrittenReviewElementResponse(2L, "테드2", "리뷰미", LocalDate.of(2024, 8, 1), "(리뷰 미리보기 2)", List.of(new ReviewCategoryResponse(2L, "카테고리 2"))) ); WrittenReviewsResponse response = new WrittenReviewsResponse( @@ -371,7 +371,7 @@ class ReviewApiTest extends ApiTest { fieldWithPath("lastReviewId").description("페이지의 마지막 리뷰 ID"), fieldWithPath("isLastPage").description("마지막 페이지 여부"), - fieldWithPath("reviews[]").description("리뷰 목록"), + fieldWithPath("reviews[]").description("리뷰 목록 (생성일 기준 내림차순 정렬)"), fieldWithPath("reviews[].reviewId").description("리뷰 ID"), fieldWithPath("reviews[].createdAt").description("리뷰 작성 날짜"), fieldWithPath("reviews[].contentPreview").description("리뷰 미리보기"), From 8751114a35a9473ff7c5bd73a533aa5752ea6a73 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 20 Dec 2024 17:48:37 +0900 Subject: [PATCH 09/10] =?UTF-8?q?style:=20=EA=B0=9C=ED=96=89=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/reviewme/review/service/ReviewListLookupService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java index 9360bfc37..4cf5de77e 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java @@ -14,8 +14,8 @@ @Service @RequiredArgsConstructor public class ReviewListLookupService { - private final ReviewRepository reviewRepository; + private final ReviewRepository reviewRepository; private final ReviewListMapper reviewListMapper; @Transactional(readOnly = true) From 13c10ed2a0c313636545b96eee2fce12dce6550f Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Mon, 23 Dec 2024 21:23:07 +0900 Subject: [PATCH 10/10] =?UTF-8?q?test:=20api=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EC=97=90=20=EC=BF=A0=ED=82=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/java/reviewme/api/ReviewApiTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/test/java/reviewme/api/ReviewApiTest.java b/backend/src/test/java/reviewme/api/ReviewApiTest.java index f2fbc94e3..53a438bbf 100644 --- a/backend/src/test/java/reviewme/api/ReviewApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewApiTest.java @@ -357,9 +357,9 @@ class ReviewApiTest extends ApiTest { BDDMockito.given(reviewListLookupService.getWrittenReviews(anyLong(), anyInt())) .willReturn(response); -// CookieDescriptor[] cookieDescriptors = { -// cookieWithName("JSESSIONID").description("세션 ID") -// }; + CookieDescriptor[] cookieDescriptors = { + cookieWithName("JSESSIONID").description("세션 ID") + }; ParameterDescriptor[] queryParameter = { parameterWithName("lastReviewId").description("페이지의 마지막 리뷰 ID - 기본으로 최신순 첫번째 페이지 응답"), @@ -385,13 +385,13 @@ class ReviewApiTest extends ApiTest { RestDocumentationResultHandler handler = document( "written-review-list-with-pagination", -// requestCookies(cookieDescriptors), + requestCookies(cookieDescriptors), queryParameters(queryParameter), responseFields(responseFieldDescriptors) ); givenWithSpec().log().all() -// .cookie("JSESSIONID", "ASVNE1VAKDNV4") + .cookie("JSESSIONID", "ASVNE1VAKDNV4") // .queryParam("reviewRequestCode", "hello!!") .queryParam("lastReviewId", "2") .queryParam("size", "5")