From ebe88bd367ec7f0ee1ae509ebab8e5dcb5f3bf10 Mon Sep 17 00:00:00 2001 From: donghoony Date: Thu, 19 Dec 2024 13:43:55 +0900 Subject: [PATCH 01/12] =?UTF-8?q?docs:=20=EC=9E=90=EC=8B=A0=EC=9D=B4=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A0=20=EB=A6=AC=EB=B7=B0=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EB=AC=B8?= =?UTF-8?q?=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 | 4 ++ .../controller/ReviewGroupController.java | 8 ++++ .../service/ReviewGroupLookupService.java | 5 +++ .../dto/ReviewGroupDetailResponse.java | 11 +++++ .../service/dto/ReviewGroupListResponse.java | 9 ++++ .../java/reviewme/api/ReviewGroupApiTest.java | 43 +++++++++++++++++++ 6 files changed, 80 insertions(+) create mode 100644 backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java create mode 100644 backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java diff --git a/backend/src/docs/asciidoc/reviewgroup.adoc b/backend/src/docs/asciidoc/reviewgroup.adoc index c3eb2f803..79d70a9f5 100644 --- a/backend/src/docs/asciidoc/reviewgroup.adoc +++ b/backend/src/docs/asciidoc/reviewgroup.adoc @@ -9,3 +9,7 @@ operation::review-group-summary[snippets="curl-request,http-response,response-fi ==== 리뷰 요청 코드, 확인 코드 일치 여부 operation::review-group-check-access[snippets="curl-request,request-fields,http-response,response-cookies"] + +==== 자신이 만든 리뷰 그룹 목록 조회 + +operation::review-group-list[snippets="curl-request,request-cookies,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..e48a76a74 100644 --- a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java +++ b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java @@ -15,6 +15,7 @@ import reviewme.reviewgroup.service.dto.CheckValidAccessRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; @RestController @@ -48,4 +49,11 @@ public ResponseEntity checkGroupAccessCode( session.setAttribute("reviewRequestCode", request.reviewRequestCode()); return ResponseEntity.noContent().build(); } + + @GetMapping("/v2/groups/mine") + public ResponseEntity getMyReviewGroups() { + // TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요 + ReviewGroupListResponse response = reviewGroupLookupService.getMyReviewGroups(); + return ResponseEntity.ok(response); + } } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java index 0567f6344..900225539 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java @@ -3,6 +3,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException; import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; @@ -21,4 +22,8 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) { return new ReviewGroupResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName()); } + + public ReviewGroupListResponse getMyReviewGroups() { + return null; + } } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java new file mode 100644 index 000000000..d502834f7 --- /dev/null +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java @@ -0,0 +1,11 @@ +package reviewme.reviewgroup.service.dto; + +import java.time.LocalDate; + +public record ReviewGroupDetailResponse( + String revieweeName, + String projectName, + LocalDate createdAt, + String reviewRequestCode +) { +} diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java new file mode 100644 index 000000000..1963d4390 --- /dev/null +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java @@ -0,0 +1,9 @@ +package reviewme.reviewgroup.service.dto; + +import java.util.List; + +public record ReviewGroupListResponse( + boolean isLastPage, + List reviewGroups +) { +} diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index e87cb8b5c..3a61e27b9 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -4,6 +4,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; +import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; import static org.springframework.restdocs.cookies.CookieDocumentation.responseCookies; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; @@ -12,6 +13,8 @@ import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; import static org.springframework.restdocs.request.RequestDocumentation.queryParameters; +import java.time.LocalDate; +import java.util.List; import org.junit.jupiter.api.Test; import org.mockito.BDDMockito; import org.springframework.restdocs.cookies.CookieDescriptor; @@ -20,6 +23,8 @@ import org.springframework.restdocs.request.ParameterDescriptor; import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupDetailResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; class ReviewGroupApiTest extends ApiTest { @@ -121,4 +126,42 @@ class ReviewGroupApiTest extends ApiTest { .cookie("JSESSIONID") .statusCode(204); } + + @Test + void 회원이_생성한_프로젝트_목록을_반환한다() { + ReviewGroupListResponse response = new ReviewGroupListResponse(true, + List.of( + new ReviewGroupDetailResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234"), + new ReviewGroupDetailResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1") + ) + ); + BDDMockito.given(reviewGroupLookupService.getMyReviewGroups()) + .willReturn(response); + + CookieDescriptor[] cookieDescriptors = { + cookieWithName("JSESSIONID").description("세션 ID") + }; + + FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("isLastPage").description("마지막 페이지 여부"), + fieldWithPath("reviewGroups[]").description("리뷰 그룹 목록"), + fieldWithPath("reviewGroups[].revieweeName").description("리뷰이 이름"), + fieldWithPath("reviewGroups[].projectName").description("프로젝트 이름"), + fieldWithPath("reviewGroups[].createdAt").description("생성일"), + fieldWithPath("reviewGroups[].reviewRequestCode").description("리뷰 요청 코드") + }; + + RestDocumentationResultHandler handler = document( + "review-group-list", + responseFields(responseFieldDescriptors), + requestCookies(cookieDescriptors) + ); + + givenWithSpec().log().all() + .cookie("JSESSIONID", "ABCDEFGHI1234") + .when().get("/v2/groups/mine") + .then().log().all() + .apply(handler) + .statusCode(200); + } } From 7a882578058a05bd03b4360c7f136b64e2579a3d Mon Sep 17 00:00:00 2001 From: donghoony Date: Thu, 19 Dec 2024 15:15:44 +0900 Subject: [PATCH 02/12] =?UTF-8?q?chore:=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?=ED=95=A0=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reviewme/reviewgroup/service/ReviewGroupLookupService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java index 900225539..e2d9a3d82 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java @@ -24,6 +24,7 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) { } public ReviewGroupListResponse getMyReviewGroups() { + // TODO: 생성일자 최신순 정렬 return null; } } From 772589ecfe362ad5a6eb330640eb6cdd44ae970d Mon Sep 17 00:00:00 2001 From: donghoony Date: Thu, 19 Dec 2024 15:16:26 +0900 Subject: [PATCH 03/12] =?UTF-8?q?fix:=20=EB=AC=B8=EC=84=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B5=9C=EC=8B=A0=EC=88=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/java/reviewme/api/ReviewGroupApiTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index 3a61e27b9..b84fedf8d 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -131,8 +131,8 @@ class ReviewGroupApiTest extends ApiTest { void 회원이_생성한_프로젝트_목록을_반환한다() { ReviewGroupListResponse response = new ReviewGroupListResponse(true, List.of( - new ReviewGroupDetailResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234"), - new ReviewGroupDetailResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1") + new ReviewGroupDetailResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1"), + new ReviewGroupDetailResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234") ) ); BDDMockito.given(reviewGroupLookupService.getMyReviewGroups()) From 98c0fff3077f9f56b0d5a4dc1759bcebc3492229 Mon Sep 17 00:00:00 2001 From: donghoony Date: Thu, 19 Dec 2024 15:16:41 +0900 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20=EB=AC=B8=EC=84=9C=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=EC=B5=9C=EC=8B=A0=EC=88=9C=20=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/java/reviewme/api/ReviewGroupApiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index b84fedf8d..ff5fcacac 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -144,7 +144,7 @@ class ReviewGroupApiTest extends ApiTest { FieldDescriptor[] responseFieldDescriptors = { fieldWithPath("isLastPage").description("마지막 페이지 여부"), - fieldWithPath("reviewGroups[]").description("리뷰 그룹 목록"), + fieldWithPath("reviewGroups[]").description("리뷰 그룹 목록 (생성일 기준 내림차순 정렬)"), fieldWithPath("reviewGroups[].revieweeName").description("리뷰이 이름"), fieldWithPath("reviewGroups[].projectName").description("프로젝트 이름"), fieldWithPath("reviewGroups[].createdAt").description("생성일"), From cfff7a44b1833f3dc838170799fceca47f97b9a7 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Thu, 19 Dec 2024 23:55:56 +0900 Subject: [PATCH 05/12] =?UTF-8?q?docs:=20=EC=9D=B8=EC=A6=9D=20api=20?= =?UTF-8?q?=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/auth.adoc | 7 +++ backend/src/docs/asciidoc/index.adoc | 4 ++ .../auth/controller/AuthController.java | 49 +++++++++++++++ .../reviewme/auth/service/AuthService.java | 7 +++ .../auth/service/dto/GithubCodeRequest.java | 8 +++ .../src/test/java/reviewme/api/ApiTest.java | 8 ++- .../test/java/reviewme/api/AuthApiTest.java | 61 +++++++++++++++++++ 7 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 backend/src/docs/asciidoc/auth.adoc create mode 100644 backend/src/main/java/reviewme/auth/controller/AuthController.java create mode 100644 backend/src/main/java/reviewme/auth/service/AuthService.java create mode 100644 backend/src/main/java/reviewme/auth/service/dto/GithubCodeRequest.java create mode 100644 backend/src/test/java/reviewme/api/AuthApiTest.java diff --git a/backend/src/docs/asciidoc/auth.adoc b/backend/src/docs/asciidoc/auth.adoc new file mode 100644 index 000000000..17900fe72 --- /dev/null +++ b/backend/src/docs/asciidoc/auth.adoc @@ -0,0 +1,7 @@ +==== 깃허브로 로그인/회원가입 + +operation::github-auth[snippets="curl-request,request-fields,http-response"] + +==== 로그아웃 + +operation::logout[snippets="curl-request,request-cookies,http-response"] diff --git a/backend/src/docs/asciidoc/index.adoc b/backend/src/docs/asciidoc/index.adoc index 4d67754a7..4fbe165d1 100644 --- a/backend/src/docs/asciidoc/index.adoc +++ b/backend/src/docs/asciidoc/index.adoc @@ -40,3 +40,7 @@ include::review-gather.adoc[] === 답변 하이라이트 include::highlight-answers.adoc[] + +== 인증 + +include::auth.adoc[] \ No newline at end of file diff --git a/backend/src/main/java/reviewme/auth/controller/AuthController.java b/backend/src/main/java/reviewme/auth/controller/AuthController.java new file mode 100644 index 000000000..a152ed3a7 --- /dev/null +++ b/backend/src/main/java/reviewme/auth/controller/AuthController.java @@ -0,0 +1,49 @@ +package reviewme.auth.controller; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseCookie; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +import reviewme.auth.service.AuthService; +import reviewme.auth.service.dto.GithubCodeRequest; + +@RestController +@RequiredArgsConstructor +public class AuthController { + + private final AuthService authService; + + @PostMapping("/v2/auth/github") + public ResponseEntity authWithGithub( + @Valid @RequestBody GithubCodeRequest request, + HttpServletRequest httpRequest + ) { + return ResponseEntity.ok().build(); + } + + @PostMapping("/v2/auth/logout") + public ResponseEntity logout( + HttpServletRequest httpRequest + ) { + HttpSession session = httpRequest.getSession(); + session.invalidate(); + + ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "") + .path("/") + .maxAge(0) + .secure(true) + .httpOnly(true) + .build(); + + return ResponseEntity + .noContent() + .header(HttpHeaders.SET_COOKIE, cookie.toString()) + .build(); + } +} diff --git a/backend/src/main/java/reviewme/auth/service/AuthService.java b/backend/src/main/java/reviewme/auth/service/AuthService.java new file mode 100644 index 000000000..5458807af --- /dev/null +++ b/backend/src/main/java/reviewme/auth/service/AuthService.java @@ -0,0 +1,7 @@ +package reviewme.auth.service; + +import org.springframework.stereotype.Service; + +@Service +public class AuthService { +} diff --git a/backend/src/main/java/reviewme/auth/service/dto/GithubCodeRequest.java b/backend/src/main/java/reviewme/auth/service/dto/GithubCodeRequest.java new file mode 100644 index 000000000..b26511917 --- /dev/null +++ b/backend/src/main/java/reviewme/auth/service/dto/GithubCodeRequest.java @@ -0,0 +1,8 @@ +package reviewme.auth.service.dto; + +import jakarta.validation.constraints.NotBlank; + +public record GithubCodeRequest( + @NotBlank(message = "깃허브 임시 코드를 입력해주세요.") + String code) { +} diff --git a/backend/src/test/java/reviewme/api/ApiTest.java b/backend/src/test/java/reviewme/api/ApiTest.java index 20d57db83..e1f3bac72 100644 --- a/backend/src/test/java/reviewme/api/ApiTest.java +++ b/backend/src/test/java/reviewme/api/ApiTest.java @@ -26,6 +26,8 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; +import reviewme.auth.controller.AuthController; +import reviewme.auth.service.AuthService; import reviewme.highlight.controller.HighlightController; import reviewme.highlight.service.HighlightService; import reviewme.review.controller.ReviewController; @@ -48,7 +50,8 @@ ReviewController.class, TemplateController.class, SectionController.class, - HighlightController.class + HighlightController.class, + AuthController.class }) @ExtendWith(RestDocumentationExtension.class) public abstract class ApiTest { @@ -85,6 +88,9 @@ public abstract class ApiTest { @MockBean protected HighlightService highlightService; + @MockBean + protected AuthService authService; + @MockBean private ReviewGroupSessionResolver reviewGroupSessionResolver; diff --git a/backend/src/test/java/reviewme/api/AuthApiTest.java b/backend/src/test/java/reviewme/api/AuthApiTest.java new file mode 100644 index 000000000..8e036b167 --- /dev/null +++ b/backend/src/test/java/reviewme/api/AuthApiTest.java @@ -0,0 +1,61 @@ +package reviewme.api; + +import static org.hamcrest.Matchers.containsString; +import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; +import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; + +import org.junit.jupiter.api.Test; +import org.springframework.restdocs.cookies.CookieDescriptor; +import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; +import org.springframework.restdocs.payload.FieldDescriptor; + +public class AuthApiTest extends ApiTest { + + @Test + void 깃허브로_인증한다() { + String request = """ + { + "code": "github_auth_code" + } + """; + + FieldDescriptor[] requestFieldDescriptors = { + fieldWithPath("code").description("깃허브 임시 인증 코드"), + }; + + RestDocumentationResultHandler handler = document( + "github-auth", + requestFields(requestFieldDescriptors) + ); + + givenWithSpec().log().all() + .body(request) + .when().post("/v2/auth/github") + .then().log().all() + .apply(handler) + .statusCode(200); + } + + @Test + void 로그아웃한다() { + CookieDescriptor[] cookieDescriptors = { + cookieWithName("JSESSIONID").description("세션 ID") + }; + + RestDocumentationResultHandler handler = document( + "logout", + requestCookies(cookieDescriptors) + ); + + givenWithSpec().log().all() + .cookie("JSESSIONID", "SESSION12345678") + .when().post("/v2/auth/logout") + .then().log().all() + .apply(handler) + .statusCode(204) + .header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0")); + } +} From 2afa5a2f465c3fcf672de549567352dacb37f39a Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Fri, 20 Dec 2024 00:36:07 +0900 Subject: [PATCH 06/12] =?UTF-8?q?docs:=20=EB=82=B4=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=ED=95=84=20api=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/index.adoc | 6 ++- backend/src/docs/asciidoc/member.adoc | 3 ++ .../member/controller/MemberController.java | 21 +++++++++ .../member/service/MemberService.java | 12 +++++ .../member/service/dto/ProfileResponse.java | 7 +++ .../src/test/java/reviewme/api/ApiTest.java | 6 +++ .../test/java/reviewme/api/MemberApiTest.java | 45 +++++++++++++++++++ 7 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 backend/src/docs/asciidoc/member.adoc create mode 100644 backend/src/main/java/reviewme/member/controller/MemberController.java create mode 100644 backend/src/main/java/reviewme/member/service/MemberService.java create mode 100644 backend/src/main/java/reviewme/member/service/dto/ProfileResponse.java create mode 100644 backend/src/test/java/reviewme/api/MemberApiTest.java diff --git a/backend/src/docs/asciidoc/index.adoc b/backend/src/docs/asciidoc/index.adoc index 4fbe165d1..0575b8a24 100644 --- a/backend/src/docs/asciidoc/index.adoc +++ b/backend/src/docs/asciidoc/index.adoc @@ -43,4 +43,8 @@ include::highlight-answers.adoc[] == 인증 -include::auth.adoc[] \ No newline at end of file +include::auth.adoc[] + +== 사용자 + +include::member.adoc[] \ No newline at end of file diff --git a/backend/src/docs/asciidoc/member.adoc b/backend/src/docs/asciidoc/member.adoc new file mode 100644 index 000000000..9a51e2c94 --- /dev/null +++ b/backend/src/docs/asciidoc/member.adoc @@ -0,0 +1,3 @@ +==== 내 프로필 정보 + +operation::my-profile[snippets="curl-request,request-cookies,http-response,response-fields"] \ No newline at end of file diff --git a/backend/src/main/java/reviewme/member/controller/MemberController.java b/backend/src/main/java/reviewme/member/controller/MemberController.java new file mode 100644 index 000000000..9d95885df --- /dev/null +++ b/backend/src/main/java/reviewme/member/controller/MemberController.java @@ -0,0 +1,21 @@ +package reviewme.member.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; +import reviewme.member.service.MemberService; +import reviewme.member.service.dto.ProfileResponse; + +@RestController +@RequiredArgsConstructor +public class MemberController { + + private final MemberService memberService; + + @GetMapping("/v2/members/profile/mine") + public ResponseEntity getProfile() { + ProfileResponse response = memberService.getProfile(); + return ResponseEntity.ok(response); + } +} diff --git a/backend/src/main/java/reviewme/member/service/MemberService.java b/backend/src/main/java/reviewme/member/service/MemberService.java new file mode 100644 index 000000000..ef828b848 --- /dev/null +++ b/backend/src/main/java/reviewme/member/service/MemberService.java @@ -0,0 +1,12 @@ +package reviewme.member.service; + +import org.springframework.stereotype.Service; +import reviewme.member.service.dto.ProfileResponse; + +@Service +public class MemberService { + + public ProfileResponse getProfile() { + return null; + } +} diff --git a/backend/src/main/java/reviewme/member/service/dto/ProfileResponse.java b/backend/src/main/java/reviewme/member/service/dto/ProfileResponse.java new file mode 100644 index 000000000..5ec6900cd --- /dev/null +++ b/backend/src/main/java/reviewme/member/service/dto/ProfileResponse.java @@ -0,0 +1,7 @@ +package reviewme.member.service.dto; + +public record ProfileResponse( + String nickname, + String profileImageUrl +) { +} diff --git a/backend/src/test/java/reviewme/api/ApiTest.java b/backend/src/test/java/reviewme/api/ApiTest.java index e1f3bac72..a656602bb 100644 --- a/backend/src/test/java/reviewme/api/ApiTest.java +++ b/backend/src/test/java/reviewme/api/ApiTest.java @@ -30,6 +30,8 @@ import reviewme.auth.service.AuthService; import reviewme.highlight.controller.HighlightController; import reviewme.highlight.service.HighlightService; +import reviewme.member.controller.MemberController; +import reviewme.member.service.MemberService; import reviewme.review.controller.ReviewController; import reviewme.review.service.ReviewDetailLookupService; import reviewme.review.service.ReviewGatheredLookupService; @@ -51,6 +53,7 @@ TemplateController.class, SectionController.class, HighlightController.class, + MemberController.class, AuthController.class }) @ExtendWith(RestDocumentationExtension.class) @@ -88,6 +91,9 @@ public abstract class ApiTest { @MockBean protected HighlightService highlightService; + @MockBean + protected MemberService memberService; + @MockBean protected AuthService authService; diff --git a/backend/src/test/java/reviewme/api/MemberApiTest.java b/backend/src/test/java/reviewme/api/MemberApiTest.java new file mode 100644 index 000000000..ab1da50eb --- /dev/null +++ b/backend/src/test/java/reviewme/api/MemberApiTest.java @@ -0,0 +1,45 @@ +package reviewme.api; + +import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; +import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; + +import org.junit.jupiter.api.Test; +import org.mockito.BDDMockito; +import org.springframework.restdocs.cookies.CookieDescriptor; +import org.springframework.restdocs.mockmvc.RestDocumentationResultHandler; +import org.springframework.restdocs.payload.FieldDescriptor; +import reviewme.member.service.dto.ProfileResponse; + +public class MemberApiTest extends ApiTest { + + @Test + void 내_프로필을_불러온다() { + BDDMockito.given(memberService.getProfile()) + .willReturn(new ProfileResponse("donghoony", "https://aru.image")); + + CookieDescriptor[] cookieDescriptors = { + cookieWithName("JSESSIONID").description("세션 ID") + }; + + FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("nickname").description("닉네임"), + fieldWithPath("profileImageUrl").description("프로필 이미지 URL") + }; + + RestDocumentationResultHandler handler = document( + "my-profile", + requestCookies(cookieDescriptors), + responseFields(responseFieldDescriptors) + ); + + givenWithSpec().log().all() + .cookie("JSESSIONID", "SESSION12345678") + .when().get("/v2/members/profile/mine") + .then().log().all() + .apply(handler) + .statusCode(200); + } +} From 6a7f683365af465c2dc7b19a12110ea0ac404f09 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sat, 21 Dec 2024 22:59:41 +0900 Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20=EC=84=B8=EC=85=98=EC=9D=B4?= =?UTF-8?q?=20null=EC=9D=B8=20=EA=B2=BD=EC=9A=B0=20=EB=B0=A9=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/reviewme/auth/controller/AuthController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/reviewme/auth/controller/AuthController.java b/backend/src/main/java/reviewme/auth/controller/AuthController.java index a152ed3a7..aca5f1e04 100644 --- a/backend/src/main/java/reviewme/auth/controller/AuthController.java +++ b/backend/src/main/java/reviewme/auth/controller/AuthController.java @@ -31,8 +31,10 @@ public ResponseEntity authWithGithub( public ResponseEntity logout( HttpServletRequest httpRequest ) { - HttpSession session = httpRequest.getSession(); - session.invalidate(); + HttpSession session = httpRequest.getSession(false); + if(session != null) { + session.invalidate(); + } ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "") .path("/") From 22827a358416236fd54627b928dd57e476d76605 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 22 Dec 2024 00:42:27 +0900 Subject: [PATCH 08/12] =?UTF-8?q?refactor:=20=EB=A1=9C=EA=B7=B8=EC=95=84?= =?UTF-8?q?=EC=9B=83=20=EA=B5=AC=ED=98=84=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthController.java | 20 +------------------ .../test/java/reviewme/api/AuthApiTest.java | 4 +--- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/backend/src/main/java/reviewme/auth/controller/AuthController.java b/backend/src/main/java/reviewme/auth/controller/AuthController.java index aca5f1e04..14573f2fe 100644 --- a/backend/src/main/java/reviewme/auth/controller/AuthController.java +++ b/backend/src/main/java/reviewme/auth/controller/AuthController.java @@ -1,11 +1,8 @@ package reviewme.auth.controller; import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpSession; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; -import org.springframework.http.HttpHeaders; -import org.springframework.http.ResponseCookie; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -31,21 +28,6 @@ public ResponseEntity authWithGithub( public ResponseEntity logout( HttpServletRequest httpRequest ) { - HttpSession session = httpRequest.getSession(false); - if(session != null) { - session.invalidate(); - } - - ResponseCookie cookie = ResponseCookie.from("JSESSIONID", "") - .path("/") - .maxAge(0) - .secure(true) - .httpOnly(true) - .build(); - - return ResponseEntity - .noContent() - .header(HttpHeaders.SET_COOKIE, cookie.toString()) - .build(); + return ResponseEntity.noContent().build(); } } diff --git a/backend/src/test/java/reviewme/api/AuthApiTest.java b/backend/src/test/java/reviewme/api/AuthApiTest.java index 8e036b167..3bf6c61c9 100644 --- a/backend/src/test/java/reviewme/api/AuthApiTest.java +++ b/backend/src/test/java/reviewme/api/AuthApiTest.java @@ -1,6 +1,5 @@ package reviewme.api; -import static org.hamcrest.Matchers.containsString; import static org.springframework.restdocs.cookies.CookieDocumentation.cookieWithName; import static org.springframework.restdocs.cookies.CookieDocumentation.requestCookies; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; @@ -55,7 +54,6 @@ public class AuthApiTest extends ApiTest { .when().post("/v2/auth/logout") .then().log().all() .apply(handler) - .statusCode(204) - .header("Set-Cookie", containsString("JSESSIONID=; Path=/; Max-Age=0")); + .statusCode(204); } } From d0560e15a173d801bb8f8b2d0d1708a29e00c5a7 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sat, 28 Dec 2024 00:27:20 +0900 Subject: [PATCH 09/12] =?UTF-8?q?refactor:=20=EB=82=B4=20=ED=94=84?= =?UTF-8?q?=EB=A1=9C=ED=95=84=20=EB=B3=B4=EB=8A=94=20uri=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/reviewme/member/controller/MemberController.java | 2 +- backend/src/test/java/reviewme/api/MemberApiTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/reviewme/member/controller/MemberController.java b/backend/src/main/java/reviewme/member/controller/MemberController.java index 9d95885df..662ccf88c 100644 --- a/backend/src/main/java/reviewme/member/controller/MemberController.java +++ b/backend/src/main/java/reviewme/member/controller/MemberController.java @@ -13,7 +13,7 @@ public class MemberController { private final MemberService memberService; - @GetMapping("/v2/members/profile/mine") + @GetMapping("/v2/members/profile") public ResponseEntity getProfile() { ProfileResponse response = memberService.getProfile(); return ResponseEntity.ok(response); diff --git a/backend/src/test/java/reviewme/api/MemberApiTest.java b/backend/src/test/java/reviewme/api/MemberApiTest.java index ab1da50eb..d8b4d4191 100644 --- a/backend/src/test/java/reviewme/api/MemberApiTest.java +++ b/backend/src/test/java/reviewme/api/MemberApiTest.java @@ -37,7 +37,7 @@ public class MemberApiTest extends ApiTest { givenWithSpec().log().all() .cookie("JSESSIONID", "SESSION12345678") - .when().get("/v2/members/profile/mine") + .when().get("/v2/members/profile") .then().log().all() .apply(handler) .statusCode(200); From f2af22382d67cdb5753ac9d25e7b5727fa5114d5 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sat, 28 Dec 2024 00:37:18 +0900 Subject: [PATCH 10/12] =?UTF-8?q?refactor:=20Paging=20=EC=A0=81=EC=9A=A9?= =?UTF-8?q?=EB=90=98=EB=8A=94=20Response=20=EB=84=A4=EC=9D=B4=EB=B0=8D=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../review/controller/ReviewController.java | 6 +++--- .../review/service/ReviewListLookupService.java | 16 ++++++++-------- ...va => ReceivedReviewPageElementResponse.java} | 2 +- ...onse.java => ReceivedReviewPageResponse.java} | 4 ++-- .../review/service/mapper/ReviewListMapper.java | 10 +++++----- .../controller/ReviewGroupController.java | 6 +++--- .../service/ReviewGroupLookupService.java | 4 ++-- .../service/dto/ReviewGroupListResponse.java | 9 --------- ....java => ReviewGroupPageElementResponse.java} | 2 +- .../service/dto/ReviewGroupPageResponse.java | 10 ++++++++++ .../test/java/reviewme/api/ReviewApiTest.java | 12 ++++++------ .../java/reviewme/api/ReviewGroupApiTest.java | 10 +++++----- .../service/ReviewListLookupServiceTest.java | 6 +++--- .../service/mapper/ReviewListMapperTest.java | 6 +++--- 14 files changed, 52 insertions(+), 51 deletions(-) rename backend/src/main/java/reviewme/review/service/dto/response/list/{ReviewListElementResponse.java => ReceivedReviewPageElementResponse.java} (83%) rename backend/src/main/java/reviewme/review/service/dto/response/list/{ReceivedReviewsResponse.java => ReceivedReviewPageResponse.java} (66%) delete mode 100644 backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java rename backend/src/main/java/reviewme/reviewgroup/service/dto/{ReviewGroupDetailResponse.java => ReviewGroupPageElementResponse.java} (81%) create mode 100644 backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageResponse.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..4e5903f21 100644 --- a/backend/src/main/java/reviewme/review/controller/ReviewController.java +++ b/backend/src/main/java/reviewme/review/controller/ReviewController.java @@ -18,7 +18,7 @@ import reviewme.review.service.dto.request.ReviewRegisterRequest; import reviewme.review.service.dto.response.detail.ReviewDetailResponse; import reviewme.review.service.dto.response.gathered.ReviewsGatheredBySectionResponse; -import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageResponse; import reviewme.review.service.dto.response.list.ReceivedReviewsSummaryResponse; import reviewme.reviewgroup.controller.ReviewGroupSession; import reviewme.reviewgroup.domain.ReviewGroup; @@ -40,12 +40,12 @@ public ResponseEntity createReview(@Valid @RequestBody ReviewRegisterReque } @GetMapping("/v2/reviews") - public ResponseEntity findReceivedReviews( + public ResponseEntity findReceivedReviews( @RequestParam(required = false) Long lastReviewId, @RequestParam(required = false) Integer size, @ReviewGroupSession ReviewGroup reviewGroup ) { - ReceivedReviewsResponse response = reviewListLookupService.getReceivedReviews(lastReviewId, size, reviewGroup); + ReceivedReviewPageResponse response = reviewListLookupService.getReceivedReviews(lastReviewId, size, reviewGroup); 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..6c75ce480 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewListLookupService.java @@ -5,8 +5,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; 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.ReceivedReviewPageResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageElementResponse; import reviewme.review.service.mapper.ReviewListMapper; import reviewme.reviewgroup.domain.ReviewGroup; @@ -18,30 +18,30 @@ public class ReviewListLookupService { private final ReviewListMapper reviewListMapper; @Transactional(readOnly = true) - public ReceivedReviewsResponse getReceivedReviews(Long lastReviewId, Integer size, ReviewGroup reviewGroup) { + public ReceivedReviewPageResponse getReceivedReviews(Long lastReviewId, Integer size, ReviewGroup reviewGroup) { PageSize pageSize = new PageSize(size); - List reviewListResponse + List reviewListResponse = reviewListMapper.mapToReviewList(reviewGroup, lastReviewId, pageSize.getSize()); long newLastReviewId = calculateLastReviewId(reviewListResponse); boolean isLastPage = isLastPage(reviewListResponse, reviewGroup); - return new ReceivedReviewsResponse( + return new ReceivedReviewPageResponse( reviewGroup.getReviewee(), reviewGroup.getProjectName(), newLastReviewId, isLastPage, reviewListResponse ); } - private long calculateLastReviewId(List elements) { + private long calculateLastReviewId(List elements) { if (elements.isEmpty()) { return 0; } return elements.get(elements.size() - 1).reviewId(); } - private boolean isLastPage(List elements, ReviewGroup reviewGroup) { + private boolean isLastPage(List elements, ReviewGroup reviewGroup) { if (elements.isEmpty()) { return true; } - ReviewListElementResponse lastReviewResponse = elements.get(elements.size() - 1); + ReceivedReviewPageElementResponse lastReviewResponse = elements.get(elements.size() - 1); return !reviewRepository.existsOlderReviewInGroup( reviewGroup.getId(), lastReviewResponse.reviewId(), lastReviewResponse.createdAt()); } diff --git a/backend/src/main/java/reviewme/review/service/dto/response/list/ReviewListElementResponse.java b/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageElementResponse.java similarity index 83% rename from backend/src/main/java/reviewme/review/service/dto/response/list/ReviewListElementResponse.java rename to backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageElementResponse.java index 07aa32c9f..5aa7c36e5 100644 --- a/backend/src/main/java/reviewme/review/service/dto/response/list/ReviewListElementResponse.java +++ b/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageElementResponse.java @@ -3,7 +3,7 @@ import java.time.LocalDate; import java.util.List; -public record ReviewListElementResponse( +public record ReceivedReviewPageElementResponse( long reviewId, LocalDate createdAt, String contentPreview, diff --git a/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewsResponse.java b/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageResponse.java similarity index 66% rename from backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewsResponse.java rename to backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageResponse.java index eace5cd50..35042e0d5 100644 --- a/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewsResponse.java +++ b/backend/src/main/java/reviewme/review/service/dto/response/list/ReceivedReviewPageResponse.java @@ -2,11 +2,11 @@ import java.util.List; -public record ReceivedReviewsResponse( +public record ReceivedReviewPageResponse( String revieweeName, String projectName, long lastReviewId, boolean isLastPage, - List reviews + List reviews ) { } diff --git a/backend/src/main/java/reviewme/review/service/mapper/ReviewListMapper.java b/backend/src/main/java/reviewme/review/service/mapper/ReviewListMapper.java index ab5ec4327..de46e8537 100644 --- a/backend/src/main/java/reviewme/review/service/mapper/ReviewListMapper.java +++ b/backend/src/main/java/reviewme/review/service/mapper/ReviewListMapper.java @@ -14,7 +14,7 @@ import reviewme.review.domain.TextAnswer; import reviewme.review.repository.ReviewRepository; import reviewme.review.service.dto.response.list.ReviewCategoryResponse; -import reviewme.review.service.dto.response.list.ReviewListElementResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageElementResponse; import reviewme.reviewgroup.domain.ReviewGroup; @Component @@ -26,7 +26,7 @@ public class ReviewListMapper { private final ReviewPreviewGenerator reviewPreviewGenerator = new ReviewPreviewGenerator(); - public List mapToReviewList(ReviewGroup reviewGroup, Long lastReviewId, int size) { + public List mapToReviewList(ReviewGroup reviewGroup, Long lastReviewId, int size) { List categoryOptionItems = optionItemRepository.findAllByOptionType(OptionType.CATEGORY); return reviewRepository.findByReviewGroupIdWithLimit(reviewGroup.getId(), lastReviewId, size) .stream() @@ -34,11 +34,11 @@ public List mapToReviewList(ReviewGroup reviewGroup, .toList(); } - private ReviewListElementResponse mapToReviewListElementResponse(Review review, - List categoryOptionItems) { + private ReceivedReviewPageElementResponse mapToReviewListElementResponse(Review review, + List categoryOptionItems) { List categoryResponses = mapToCategoryOptionResponse(review, categoryOptionItems); - return new ReviewListElementResponse( + return new ReceivedReviewPageElementResponse( review.getId(), review.getCreatedDate(), reviewPreviewGenerator.generatePreview(review.getAnswersByType(TextAnswer.class)), diff --git a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java index e48a76a74..4195e8cbf 100644 --- a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java +++ b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java @@ -15,7 +15,7 @@ import reviewme.reviewgroup.service.dto.CheckValidAccessRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; -import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupPageResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; @RestController @@ -51,9 +51,9 @@ public ResponseEntity checkGroupAccessCode( } @GetMapping("/v2/groups/mine") - public ResponseEntity getMyReviewGroups() { + public ResponseEntity getMyReviewGroups() { // TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요 - ReviewGroupListResponse response = reviewGroupLookupService.getMyReviewGroups(); + ReviewGroupPageResponse response = reviewGroupLookupService.getMyReviewGroups(); return ResponseEntity.ok(response); } } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java index e2d9a3d82..44c8402a2 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/ReviewGroupLookupService.java @@ -3,7 +3,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupPageResponse; import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException; import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; @@ -23,7 +23,7 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) { return new ReviewGroupResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName()); } - public ReviewGroupListResponse getMyReviewGroups() { + public ReviewGroupPageResponse getMyReviewGroups() { // TODO: 생성일자 최신순 정렬 return null; } diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java deleted file mode 100644 index 1963d4390..000000000 --- a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupListResponse.java +++ /dev/null @@ -1,9 +0,0 @@ -package reviewme.reviewgroup.service.dto; - -import java.util.List; - -public record ReviewGroupListResponse( - boolean isLastPage, - List reviewGroups -) { -} diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java similarity index 81% rename from backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java rename to backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java index d502834f7..7d66e2a1c 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupDetailResponse.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java @@ -2,7 +2,7 @@ import java.time.LocalDate; -public record ReviewGroupDetailResponse( +public record ReviewGroupPageElementResponse( String revieweeName, String projectName, LocalDate createdAt, diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageResponse.java new file mode 100644 index 000000000..ef6c250e9 --- /dev/null +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageResponse.java @@ -0,0 +1,10 @@ +package reviewme.reviewgroup.service.dto; + +import java.util.List; + +public record ReviewGroupPageResponse( + long lastReviewGroupId, + boolean isLastPage, + List reviewGroups +) { +} diff --git a/backend/src/test/java/reviewme/api/ReviewApiTest.java b/backend/src/test/java/reviewme/api/ReviewApiTest.java index e05935d43..eeea31f7c 100644 --- a/backend/src/test/java/reviewme/api/ReviewApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewApiTest.java @@ -30,10 +30,10 @@ import reviewme.review.service.dto.response.gathered.SimpleQuestionResponse; import reviewme.review.service.dto.response.gathered.TextResponse; import reviewme.review.service.dto.response.gathered.VoteResponse; -import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageResponse; 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.ReceivedReviewPageElementResponse; import reviewme.reviewgroup.service.exception.ReviewGroupNotFoundByReviewRequestCodeException; class ReviewApiTest extends ApiTest { @@ -167,13 +167,13 @@ class ReviewApiTest extends ApiTest { @Test void 자신이_받은_리뷰_목록을_조회한다() { - List receivedReviews = List.of( - new ReviewListElementResponse(1L, LocalDate.of(2024, 8, 1), "(리뷰 미리보기 1)", + List receivedReviews = List.of( + new ReceivedReviewPageElementResponse(1L, LocalDate.of(2024, 8, 1), "(리뷰 미리보기 1)", List.of(new ReviewCategoryResponse(1L, "카테고리 1"))), - new ReviewListElementResponse(2L, LocalDate.of(2024, 8, 2), "(리뷰 미리보기 2)", + new ReceivedReviewPageElementResponse(2L, LocalDate.of(2024, 8, 2), "(리뷰 미리보기 2)", List.of(new ReviewCategoryResponse(2L, "카테고리 2"))) ); - ReceivedReviewsResponse response = new ReceivedReviewsResponse( + ReceivedReviewPageResponse response = new ReceivedReviewPageResponse( "아루3", "리뷰미", 1L, true, receivedReviews); BDDMockito.given(reviewListLookupService.getReceivedReviews(anyLong(), anyInt(), any())) .willReturn(response); diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index ff5fcacac..4173ba756 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -23,8 +23,8 @@ import org.springframework.restdocs.request.ParameterDescriptor; import reviewme.reviewgroup.service.dto.ReviewGroupCreationRequest; import reviewme.reviewgroup.service.dto.ReviewGroupCreationResponse; -import reviewme.reviewgroup.service.dto.ReviewGroupDetailResponse; -import reviewme.reviewgroup.service.dto.ReviewGroupListResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupPageElementResponse; +import reviewme.reviewgroup.service.dto.ReviewGroupPageResponse; import reviewme.reviewgroup.service.dto.ReviewGroupResponse; class ReviewGroupApiTest extends ApiTest { @@ -129,10 +129,10 @@ class ReviewGroupApiTest extends ApiTest { @Test void 회원이_생성한_프로젝트_목록을_반환한다() { - ReviewGroupListResponse response = new ReviewGroupListResponse(true, + ReviewGroupPageResponse response = new ReviewGroupPageResponse(2L, true, List.of( - new ReviewGroupDetailResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1"), - new ReviewGroupDetailResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234") + new ReviewGroupPageElementResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1"), + new ReviewGroupPageElementResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234") ) ); BDDMockito.given(reviewGroupLookupService.getMyReviewGroups()) diff --git a/backend/src/test/java/reviewme/review/service/ReviewListLookupServiceTest.java b/backend/src/test/java/reviewme/review/service/ReviewListLookupServiceTest.java index ebc559924..06c311a2a 100644 --- a/backend/src/test/java/reviewme/review/service/ReviewListLookupServiceTest.java +++ b/backend/src/test/java/reviewme/review/service/ReviewListLookupServiceTest.java @@ -22,7 +22,7 @@ import reviewme.review.domain.Review; import reviewme.review.domain.TextAnswer; import reviewme.review.repository.ReviewRepository; -import reviewme.review.service.dto.response.list.ReceivedReviewsResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageResponse; import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; import reviewme.support.ServiceTest; @@ -82,7 +82,7 @@ class ReviewListLookupServiceTest { reviewRepository.saveAll(List.of(review1, review2)); // when - ReceivedReviewsResponse response = reviewListLookupService.getReceivedReviews( + ReceivedReviewPageResponse response = reviewListLookupService.getReceivedReviews( Long.MAX_VALUE, 5, reviewGroup ); @@ -116,7 +116,7 @@ class ReviewListLookupServiceTest { reviewRepository.saveAll(List.of(review1, review2, review3)); // when - ReceivedReviewsResponse response + ReceivedReviewPageResponse response = reviewListLookupService.getReceivedReviews(Long.MAX_VALUE, 2, reviewGroup); // then diff --git a/backend/src/test/java/reviewme/review/service/mapper/ReviewListMapperTest.java b/backend/src/test/java/reviewme/review/service/mapper/ReviewListMapperTest.java index 0032b7cb2..eb5ace5c0 100644 --- a/backend/src/test/java/reviewme/review/service/mapper/ReviewListMapperTest.java +++ b/backend/src/test/java/reviewme/review/service/mapper/ReviewListMapperTest.java @@ -15,7 +15,7 @@ import reviewme.review.domain.Review; import reviewme.review.domain.TextAnswer; import reviewme.review.repository.ReviewRepository; -import reviewme.review.service.dto.response.list.ReviewListElementResponse; +import reviewme.review.service.dto.response.list.ReceivedReviewPageElementResponse; import reviewme.reviewgroup.domain.ReviewGroup; import reviewme.reviewgroup.repository.ReviewGroupRepository; import reviewme.support.ServiceTest; @@ -76,13 +76,13 @@ class ReviewListMapperTest { int size = 5; // when - List responses = reviewListMapper.mapToReviewList( + List responses = reviewListMapper.mapToReviewList( reviewGroup, lastReviewId, size); // then assertAll( () -> assertThat(responses).hasSize(size), - () -> assertThat(responses).extracting(ReviewListElementResponse::reviewId) + () -> assertThat(responses).extracting(ReceivedReviewPageElementResponse::reviewId) .containsExactly( review7.getId(), review6.getId(), review5.getId(), review4.getId(), review3.getId()) ); From 6749503ba008edf4cc41b58d2357e30a0f6515cb Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sat, 28 Dec 2024 00:44:54 +0900 Subject: [PATCH 11/12] =?UTF-8?q?refactor:=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EA=B7=B8=EB=A3=B9=20=EC=9D=91=EB=8B=B5=EC=97=90=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=EB=90=9C=20=EB=A6=AC=EB=B7=B0=20=EC=88=98=20=ED=8F=AC?= =?UTF-8?q?=ED=95=A8=ED=95=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dto/ReviewGroupPageElementResponse.java | 3 ++- .../src/test/java/reviewme/api/ReviewGroupApiTest.java | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java index 7d66e2a1c..f5a7aab78 100644 --- a/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java +++ b/backend/src/main/java/reviewme/reviewgroup/service/dto/ReviewGroupPageElementResponse.java @@ -6,6 +6,7 @@ public record ReviewGroupPageElementResponse( String revieweeName, String projectName, LocalDate createdAt, - String reviewRequestCode + String reviewRequestCode, + int reviewCount ) { } diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index 4173ba756..d0f6e947c 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -131,8 +131,8 @@ class ReviewGroupApiTest extends ApiTest { void 회원이_생성한_프로젝트_목록을_반환한다() { ReviewGroupPageResponse response = new ReviewGroupPageResponse(2L, true, List.of( - new ReviewGroupPageElementResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1"), - new ReviewGroupPageElementResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234") + new ReviewGroupPageElementResponse("이동훈", "우테코", LocalDate.of(2024, 1, 30), "WOOTECO1", 1), + new ReviewGroupPageElementResponse("아루", "리뷰미", LocalDate.of(2024, 1, 5), "ABCD1234", 2) ) ); BDDMockito.given(reviewGroupLookupService.getMyReviewGroups()) @@ -143,12 +143,14 @@ class ReviewGroupApiTest extends ApiTest { }; FieldDescriptor[] responseFieldDescriptors = { + fieldWithPath("lastReviewGroupId").description("해당 페이지의 마지막 리뷰 그룹 ID"), fieldWithPath("isLastPage").description("마지막 페이지 여부"), fieldWithPath("reviewGroups[]").description("리뷰 그룹 목록 (생성일 기준 내림차순 정렬)"), fieldWithPath("reviewGroups[].revieweeName").description("리뷰이 이름"), fieldWithPath("reviewGroups[].projectName").description("프로젝트 이름"), fieldWithPath("reviewGroups[].createdAt").description("생성일"), - fieldWithPath("reviewGroups[].reviewRequestCode").description("리뷰 요청 코드") + fieldWithPath("reviewGroups[].reviewRequestCode").description("리뷰 요청 코드"), + fieldWithPath("reviewGroups[].reviewCount").description("작성된 리뷰 수") }; RestDocumentationResultHandler handler = document( From 25c4383858d31fc26f84b9234d2e876a6c0d9148 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Sun, 12 Jan 2025 11:57:33 +0900 Subject: [PATCH 12/12] =?UTF-8?q?refactor:=20=EB=82=B4=EA=B0=80=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A0=20=EA=B7=B8=EB=A3=B9=20uri=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 --- .../reviewgroup/controller/ReviewGroupController.java | 4 ++-- backend/src/test/java/reviewme/api/ReviewGroupApiTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java index 4195e8cbf..be0935c3f 100644 --- a/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java +++ b/backend/src/main/java/reviewme/reviewgroup/controller/ReviewGroupController.java @@ -25,7 +25,7 @@ public class ReviewGroupController { private final ReviewGroupService reviewGroupService; private final ReviewGroupLookupService reviewGroupLookupService; - @GetMapping("/v2/groups") + @GetMapping("/v2/groups/summary") public ResponseEntity getReviewGroupSummary(@RequestParam String reviewRequestCode) { ReviewGroupResponse response = reviewGroupLookupService.getReviewGroupSummary(reviewRequestCode); return ResponseEntity.ok(response); @@ -50,7 +50,7 @@ public ResponseEntity checkGroupAccessCode( return ResponseEntity.noContent().build(); } - @GetMapping("/v2/groups/mine") + @GetMapping("/v2/groups") public ResponseEntity getMyReviewGroups() { // TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요 ReviewGroupPageResponse response = reviewGroupLookupService.getMyReviewGroups(); diff --git a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java index d0f6e947c..fe3c8e5ff 100644 --- a/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java +++ b/backend/src/test/java/reviewme/api/ReviewGroupApiTest.java @@ -88,7 +88,7 @@ class ReviewGroupApiTest extends ApiTest { givenWithSpec().log().all() .queryParam("reviewRequestCode", "ABCD1234") - .when().get("/v2/groups") + .when().get("/v2/groups/summary") .then().log().all() .apply(handler) .statusCode(200); @@ -161,7 +161,7 @@ class ReviewGroupApiTest extends ApiTest { givenWithSpec().log().all() .cookie("JSESSIONID", "ABCDEFGHI1234") - .when().get("/v2/groups/mine") + .when().get("/v2/groups") .then().log().all() .apply(handler) .statusCode(200);