Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] docs: GitHub 연동, 자신이 만든 리뷰 그룹 목록 조회 API 문서 작성 #1014

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
4 changes: 4 additions & 0 deletions backend/src/docs/asciidoc/reviewgroup.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,4 +49,11 @@ public ResponseEntity<Void> checkGroupAccessCode(
session.setAttribute("reviewRequestCode", request.reviewRequestCode());
return ResponseEntity.noContent().build();
}

@GetMapping("/v2/groups/mine")
public ResponseEntity<ReviewGroupListResponse> getMyReviewGroups() {
// TODO: 세션을 활용한 권한 체계에 따른 추가 조치 필요
ReviewGroupListResponse response = reviewGroupLookupService.getMyReviewGroups();
return ResponseEntity.ok(response);
}
nayonsoso marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,4 +22,8 @@ public ReviewGroupResponse getReviewGroupSummary(String reviewRequestCode) {

return new ReviewGroupResponse(reviewGroup.getReviewee(), reviewGroup.getProjectName());
}

public ReviewGroupListResponse getMyReviewGroups() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package reviewme.reviewgroup.service.dto;

import java.time.LocalDate;

public record ReviewGroupDetailResponse(
nayonsoso marked this conversation as resolved.
Show resolved Hide resolved
String revieweeName,
String projectName,
LocalDate createdAt,
String reviewRequestCode
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

프로젝트 목록에서 해당 프로젝트에 리뷰가 몇 개 작성되어있는지도 같이 제공하면 어떨까요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오~ 괜찮은데요? 이건 프론트 분들이랑 이야기를 해봐야 할 것 같아요!

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package reviewme.reviewgroup.service.dto;

import java.util.List;

public record ReviewGroupListResponse(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

어떤 회원의 그룹 목록인지 확인할 수 있도록 memberId 필드에 추가하는 건 어떻게 생각하시나요?

#1017 (comment)
저희가 작업한 dto와 같은 이유입니다~

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

음 이거에 대해서 다시 생각해봤는데, 불필요한 응답 같다고 다시 생각을 바꾸게 되었어요///😔
#1017 (comment)
여기에 코멘트 달아놨습니다!

boolean isLastPage,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

내가 받은 리뷰와 동일하게 무한스크롤 구현을 생각해서요~ lastReviewId 필드는 필요하지 않을까요?

Copy link
Contributor

@nayonsoso nayonsoso Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사실 일반적인 사용자가 무한 스크롤이 필요할 정도로 많은 리뷰 그룹을 만들 것이라고 생각되진 않는데요..! 🤔
그럼에도 [통일성 / 악의적인 무리한 요청 방지]를 위해서 무스를 추가해줘야 하려나요!
일단 다른 분들의 의견도 들어보겠습니다
@donghoony @Kimprodp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

무한 스크롤 / 페이징을 여러 군데에서 사용할 것으로 보이는데, 따로 함수로 빼야할 것 같기도 하고.. 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

페이징 적용해서 나쁠건 없다고 생각합니다~
현재 내용은 한번에 보내주는 걸로 설계한 것으로 보이는데 isLastPage 는 다른 용도가 있나요?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그럼 페이징 적용하는 것으로 하겠습니다👍

@Kimprodp
isLastPage 를 내려주면 클라이언트 측에서 '이게 마지막 페이지이구나, 더 이상 요청을 보내면 안되겠구나'를 알 수 있습니다.
따라서 더 이상 로딩이 안되게 하거나 / ui 면에서 차이를 둘 수 있습니다.
이를 위해서 내려주고 있습니다!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 제가 물어본건 페이징이 안되어있는데 저 필드가 있어서 물어본거였슴당

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kimprodp
페이징될 수 있게 long lastReviewGroupId 도 추가해줬습니다 👍

List<ReviewGroupDetailResponse> reviewGroups
) {
}
43 changes: 43 additions & 0 deletions backend/src/test/java/reviewme/api/ReviewGroupApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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);
}
}
Loading