-
Notifications
You must be signed in to change notification settings - Fork 2
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] feat: 리뷰에 필요한 정보 조회 기능 추가 #103
Changes from 1 commit
d8cd5e5
f1bde50
274418b
1bb6831
92098cb
bda20e1
12e23b4
4708c69
9697ff0
57dbb5e
6577359
2da7521
5c0e0d8
e6b6b6e
7f29245
ae673b6
b201d3a
07fa6a3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package reviewme.member.dto.response; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.LocalDate; | ||
|
||
@Schema(description = "리뷰 생성 시 필요한 리뷰어 그룹 응답") | ||
public record ReviewCreationReviewerGroupResponse( | ||
|
||
@Schema(description = "리뷰어 그룹 아이디") | ||
long id, | ||
|
||
@Schema(description = "리뷰 그룹 이름 (레포지토리명)") | ||
String name, | ||
|
||
@Schema(description = "그룹 소개") | ||
String description, | ||
|
||
@Schema(description = "리뷰 작성 기한") | ||
LocalDate deadline, | ||
|
||
@Schema(description = "썸네일 URL") | ||
String thumbnailUrl, | ||
|
||
@Schema(description = "리뷰이") | ||
MemberResponse reviewee | ||
) { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
import reviewme.member.dto.response.MemberResponse; | ||
import reviewme.member.dto.response.ReviewerGroupResponse; | ||
import reviewme.member.repository.ReviewerGroupRepository; | ||
import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
|
@@ -24,4 +25,17 @@ public ReviewerGroupResponse findReviewerGroup(long reviewerGroupId) { | |
new MemberResponse(reviewee.getId(), reviewee.getName()) | ||
); | ||
} | ||
|
||
public ReviewCreationReviewerGroupResponse findReviewCreationReviewerGroup(long reviewerGroupId) { | ||
ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(reviewerGroupId); | ||
Member reviewee = reviewerGroup.getReviewee(); | ||
return new ReviewCreationReviewerGroupResponse( | ||
reviewerGroup.getId(), | ||
reviewerGroup.getGroupName(), | ||
reviewerGroup.getDescription(), | ||
reviewerGroup.getDeadline().toLocalDate(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이거 어제 프론트에서 이야기나온 건데, 데드라인은 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
앗 와이어프레임에는 날짜까지만 표기가 되어있어서 어제 프론트의 얘기 상 전자라고 생각했어요! |
||
reviewerGroup.getThumbnailUrl(), | ||
new MemberResponse(reviewee.getId(), reviewee.getName()) | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package reviewme.member.service; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertAll; | ||
import static reviewme.fixture.ReviewerGroupFixture.리뷰_그룹; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import reviewme.member.domain.GithubId; | ||
import reviewme.member.domain.Member; | ||
import reviewme.member.domain.ReviewerGroup; | ||
import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; | ||
import reviewme.member.repository.MemberRepository; | ||
import reviewme.member.repository.ReviewerGroupRepository; | ||
|
||
@SpringBootTest(webEnvironment = WebEnvironment.NONE) | ||
class ReviewerGroupServiceTest { | ||
|
||
@Autowired | ||
ReviewerGroupService reviewerGroupService; | ||
|
||
@Autowired | ||
ReviewerGroupRepository reviewerGroupRepository; | ||
|
||
@Autowired | ||
MemberRepository memberRepository; | ||
|
||
@Test | ||
void 리뷰_생성_시_필요한_리뷰어_그룹_정보를_조회한다() { | ||
// given | ||
Member reviewee = memberRepository.save(new Member("산초", 1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixture를 사용 할 수 있을 것 같아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아래의 리뷰어의 깃헙 아이디와 겹치지 않는 아이디를 배당한 것을 명시적으로 주고 싶었어요! Member reviewee = memberRepository.save(new Member("산초", 1));
List<GithubId> reviewergithubIds = List.of(new GithubId(2), new GithubId(3)); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오프라인 설명 납득 완료 |
||
List<GithubId> reviewergithubIds = List.of(new GithubId(2), new GithubId(3)); | ||
ReviewerGroup reviewerGroup = reviewerGroupRepository.save(리뷰_그룹.create(reviewee, reviewergithubIds)); | ||
|
||
// when | ||
ReviewCreationReviewerGroupResponse actual = reviewerGroupService.findReviewCreationReviewerGroup( | ||
reviewerGroup.getId()); | ||
|
||
// then | ||
assertAll( | ||
() -> assertThat(actual.id()).isEqualTo(reviewerGroup.getId()), | ||
() -> assertThat(actual.reviewee().id()).isEqualTo(reviewee.getId()) | ||
Comment on lines
+43
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ID 기반 비교니 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actual.reviewee()가 reviewee를 반환하지 않고 MemberResponse를 반환해서 id로 직접 비교할 수 밖에 없네요😂 |
||
); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
우리 요청마다 DTO 를 만들어주기로 했었던 것 같은데,
이 MemberResponse 는 다른 DTO에서도 사용되고 있는 것 같아요.
ReviewCreationRevieweerGroupRevieweeResponse 이런식으로 DTO를 추가로 만들어주세용~
(근데 이름 이거 맞아,,?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그거슨... 약간 또 저만의(?) 생각에서 나온 것인데요!
Member의 필드 id, name, githubId 중에 모든 경우에서 id, name이 쓰이는 것이 많은 멤버 응답의 기본형태일 것이라고 생각했어요!
따라서 id, name만을 가지는 MemberResponse를 기본형태라고 생각하고 컨텍스트를 추가하지 않은 기본형태로 다용도로 쓸 수 있는 약간의 예외 상황이라고 생각했습니다!
만 논의를 하지는 않았네요😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
으앙 저도 dto 는 그냥 막 만들고 재사용하지 말자 주의였긴 했는데,
막 철저하게 나누려다보니 너무 중복 코드가 많아지는 것 같아 흔들리네요🫨
이것도 이슈에 남겨둘게요! 일단 지금은 넘어가도 될 것 같아요