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 11 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,
nayonsoso marked this conversation as resolved.
Show resolved Hide resolved
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