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] feat: 리뷰에 필요한 정보 조회 기능 추가 #103

Merged
merged 18 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

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를 추가로 만들어주세용~

(근데 이름 이거 맞아,,?)

Copy link
Contributor Author

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이 쓰이는 것이 많은 멤버 응답의 기본형태일 것이라고 생각했어요!

  1. githubId는 id와 동일하게 식별자 역할을 하지만 github 종속적이기때문에 식별자가 필요하면 id를 쓸 것임. 즉, githubId는 응답으로 보내줄 일이 없음.
  2. name만 보내줄 일이 있지 않을까?: 그럼 그 때 name만 반환하는 DTO를 만들게되지 않을까?

따라서 id, name만을 가지는 MemberResponse를 기본형태라고 생각하고 컨텍스트를 추가하지 않은 기본형태로 다용도로 쓸 수 있는 약간의 예외 상황이라고 생각했습니다!

만 논의를 하지는 않았네요😂

Copy link
Contributor

Choose a reason for hiding this comment

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

으앙 저도 dto 는 그냥 막 만들고 재사용하지 말자 주의였긴 했는데,
막 철저하게 나누려다보니 너무 중복 코드가 많아지는 것 같아 흔들리네요🫨
이것도 이슈에 남겨둘게요! 일단 지금은 넘어가도 될 것 같아요

) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(),
Copy link
Contributor

Choose a reason for hiding this comment

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

이거 어제 프론트에서 이야기나온 건데, 데드라인은 LocalDateTime으로, 쓴 날짜는 LocalDate로 합의된 것 같아 적어둡니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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));
Copy link
Contributor

Choose a reason for hiding this comment

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

Fixture를 사용 할 수 있을 것 같아요

Copy link
Contributor Author

@skylar1220 skylar1220 Jul 25, 2024

Choose a reason for hiding this comment

The 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));

Copy link
Contributor

@Kimprodp Kimprodp Jul 25, 2024

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

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

ID 기반 비교니 .id() 말고 reviewee로 비교하는 건 어떨까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actual.reviewee()가 reviewee를 반환하지 않고 MemberResponse를 반환해서 id로 직접 비교할 수 밖에 없네요😂

);
}
}