From d84a1c6b66d3f49fd2f3edd05d4dc37d9465c7dc Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 18 Jul 2024 17:15:49 +0900 Subject: [PATCH 01/16] =?UTF-8?q?feat:=20Member=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EC=97=90=20GitHub=20ID=20=EC=86=8D=EC=84=B1=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/reviewme/member/domain/Member.java | 6 +++++- .../java/reviewme/member/domain/ReviewerGroupTest.java | 6 +++--- .../test/java/reviewme/review/ReviewServiceTest.java | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/reviewme/member/domain/Member.java b/backend/src/main/java/reviewme/member/domain/Member.java index f39baf13a..6aaf6da65 100644 --- a/backend/src/main/java/reviewme/member/domain/Member.java +++ b/backend/src/main/java/reviewme/member/domain/Member.java @@ -23,7 +23,11 @@ public class Member { @Column(name = "name", nullable = false) private String name; - public Member(String name) { + @Column(name = "git_hub_id", nullable = false) + private String gitHubId; + + public Member(String name, String gitHubId) { this.name = name; + this.gitHubId = gitHubId; } } diff --git a/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java b/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java index d5235f152..a2ded1822 100644 --- a/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java +++ b/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java @@ -15,7 +15,7 @@ class ReviewerGroupTest { @Test void 리뷰_그룹이_올바르게_생성된다() { // given - Member sancho = new Member("산초"); + Member sancho = new Member("산초", "sancho"); String groupName = "a".repeat(100); String description = "a".repeat(50); LocalDateTime createdAt = LocalDateTime.of(2024, 7, 17, 12, 0); @@ -29,7 +29,7 @@ class ReviewerGroupTest { void 리뷰_그룹_이름_길이_제한을_벗어나는_경우_예외를_발생한다(int length) { // given String groupName = "a".repeat(length); - Member sancho = new Member("산초"); + Member sancho = new Member("산초", "sancho"); LocalDateTime createdAt = LocalDateTime.of(2024, 7, 17, 12, 0); // when, then assertThatThrownBy(() -> new ReviewerGroup(sancho, groupName, "설명", createdAt)) @@ -40,7 +40,7 @@ class ReviewerGroupTest { void 리뷰_그룹_설명_길이_제한을_벗어나는_경우_예외를_발생한다() { // given String description = "a".repeat(51); - Member sancho = new Member("산초"); + Member sancho = new Member("산초", "sancho"); LocalDateTime createdAt = LocalDateTime.of(2024, 7, 17, 12, 0); // when, then assertThatThrownBy(() -> new ReviewerGroup(sancho, "그룹 이름", description, createdAt)) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index f967c25cb..2564a36df 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -41,8 +41,8 @@ class ReviewServiceTest { @Test void 리뷰를_작성한다() { // given - memberRepository.save(new Member("산초")); - Member reviewee = memberRepository.save(new Member("아루")); + memberRepository.save(new Member("산초", "sancho")); + Member reviewee = memberRepository.save(new Member("아루", "aru")); reviewerGroupRepository.save( new ReviewerGroup(reviewee, "그룹A", "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); @@ -73,9 +73,9 @@ class ReviewServiceTest { @Test void 리뷰를_조회한다() { // given - Member reviewer = memberRepository.save(new Member("테드")); - Member reviewee = memberRepository.save(new Member("아루")); - memberRepository.save(new Member("산초")); + Member reviewer = memberRepository.save(new Member("테드", "ted")); + Member reviewee = memberRepository.save(new Member("아루", "aru")); + memberRepository.save(new Member("산초", "sancho")); ReviewerGroup reviewerGroup = reviewerGroupRepository.save(new ReviewerGroup( reviewee, "그룹A", From 1791df9fee5e33631d0fa22bf7c7a764ea7413d0 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 18 Jul 2024 17:17:11 +0900 Subject: [PATCH 02/16] =?UTF-8?q?feat:=20=EC=9E=91=EC=84=B1=ED=95=9C=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=EC=96=B4=EA=B0=80=20=EB=A6=AC=EB=B7=B0?= =?UTF-8?q?=EC=96=B4=20=EA=B7=B8=EB=A3=B9=EC=97=90=20=EC=86=8D=ED=95=98?= =?UTF-8?q?=EB=8A=94=EC=A7=80=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/domain/GitHubReviewGroup.java | 34 +++++++++++++++ .../GitHubReviewGroupRepository.java | 12 ++++++ .../GitHubReviewGroupNotFoundException.java | 10 +++++ .../review/service/ReviewService.java | 12 ++++++ .../reviewme/review/ReviewServiceTest.java | 41 +++++++++++++++++++ 5 files changed, 109 insertions(+) create mode 100644 backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java create mode 100644 backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java create mode 100644 backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java diff --git a/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java b/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java new file mode 100644 index 000000000..a50cf6bb8 --- /dev/null +++ b/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java @@ -0,0 +1,34 @@ +package reviewme.member.domain; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Table(name = "git_hub_review_group") +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Getter +public class GitHubReviewGroup { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String gitHubId; + + @ManyToOne + @JoinColumn(name = "reviewer_group") + private ReviewerGroup reviewerGroup; + + public GitHubReviewGroup(String gitHubId, ReviewerGroup reviewerGroup) { + this.gitHubId = gitHubId; + this.reviewerGroup = reviewerGroup; + } +} diff --git a/backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java b/backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java new file mode 100644 index 000000000..c11f2320b --- /dev/null +++ b/backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java @@ -0,0 +1,12 @@ +package reviewme.member.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; +import reviewme.member.domain.GitHubReviewGroup; +import reviewme.member.domain.ReviewerGroup; + +@Repository +public interface GitHubReviewGroupRepository extends JpaRepository { + + boolean existsByGitHubIdAndReviewerGroup(String gitHubId, ReviewerGroup reviewerGroup); +} diff --git a/backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java b/backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java new file mode 100644 index 000000000..55e92e787 --- /dev/null +++ b/backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java @@ -0,0 +1,10 @@ +package reviewme.review.exception; + +import reviewme.global.exception.NotFoundException; + +public class GitHubReviewGroupNotFoundException extends NotFoundException { + + public GitHubReviewGroupNotFoundException() { + super("일치하는 깃헙 사용자와 리뷰어 그룹이 존재하지 않습니다."); + } +} diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index b1313b8f6..ff5f05735 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -11,6 +11,7 @@ import reviewme.member.domain.ReviewerGroup; import reviewme.member.dto.response.MemberResponse; import reviewme.member.dto.response.ReviewerGroupResponse; +import reviewme.member.repository.GitHubReviewGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; @@ -19,6 +20,8 @@ import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewContentResponse; import reviewme.review.dto.response.ReviewResponse; +import reviewme.review.exception.GitHubReviewGroupNotFoundException; +import reviewme.review.exception.ReviewContentExistException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewKeywordRepository; import reviewme.review.repository.ReviewRepository; @@ -30,6 +33,7 @@ public class ReviewService { private final ReviewRepository reviewRepository; private final MemberRepository memberRepository; private final ReviewerGroupRepository reviewerGroupRepository; + private final GitHubReviewGroupRepository gitHubReviewGroupRepository; private final ReviewContentRepository reviewContentRepository; private final KeywordRepository keywordRepository; private final ReviewKeywordRepository reviewKeywordRepository; @@ -40,6 +44,14 @@ public Long createReview(CreateReviewRequest request) { ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(request.reviewerGroupId()); Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); + boolean isValidReviewer = gitHubReviewGroupRepository.existsByGitHubIdAndReviewerGroup( + reviewer.getGitHubId(), + reviewerGroup + ); + if (!isValidReviewer) { + throw new GitHubReviewGroupNotFoundException(); + } + List contents = request.contents() .stream() .map(content -> new ReviewContent(review, content.question(), content.answer())) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 2564a36df..fdc656f61 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -1,6 +1,7 @@ package reviewme.review; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import java.time.LocalDateTime; import java.util.List; @@ -8,14 +9,17 @@ import org.springframework.beans.factory.annotation.Autowired; import reviewme.keyword.domain.Keyword; import reviewme.keyword.repository.KeywordRepository; +import reviewme.member.domain.GitHubReviewGroup; import reviewme.member.domain.Member; import reviewme.member.domain.ReviewerGroup; +import reviewme.member.repository.GitHubReviewGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; import reviewme.review.dto.request.CreateReviewContentRequest; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewResponse; +import reviewme.review.exception.GitHubReviewGroupNotFoundException; import reviewme.review.repository.ReviewRepository; import reviewme.review.service.ReviewService; import reviewme.support.ServiceTest; @@ -35,6 +39,9 @@ class ReviewServiceTest { @Autowired ReviewerGroupRepository reviewerGroupRepository; + @Autowired + GitHubReviewGroupRepository gitHubReviewGroupRepository; + @Autowired KeywordRepository keywordRepository; @@ -91,4 +98,38 @@ class ReviewServiceTest { Long id = response.id(); assertThat(id).isEqualTo(review.getId()); } + + @Test + void 리뷰어_그룹에_속하지_않는_리뷰어가_리뷰를_작성할_경우_예외를_발생한다() { + // given + Member reviewee = memberRepository.save(new Member("아루", "aru")); + Member reviewer = memberRepository.save(new Member("테드", "ted")); + ReviewerGroup reviewerGroup = reviewerGroupRepository.save(new ReviewerGroup( + reviewee, + "그룹A", + "그룹 설명", + LocalDateTime.of(2024, 1, 1, 1, 1)) + ); + gitHubReviewGroupRepository.save(new GitHubReviewGroup("kirby", reviewerGroup)); + + Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); + Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); + + CreateReviewContentRequest contentRequest1 = new CreateReviewContentRequest( + 1L, "소프트스킬이 어떤가요?", "소통을 잘해요" + ); + CreateReviewContentRequest contentRequest2 = new CreateReviewContentRequest( + 2L, "기술역량이 어떤가요?", "스트림을 잘다뤄요" + ); + CreateReviewRequest createReviewRequest = new CreateReviewRequest( + reviewer.getId(), + reviewerGroup.getId(), + List.of(contentRequest1, contentRequest2), + List.of(keyword1.getId(), keyword2.getId()) + ); + + // when, then + assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) + .isInstanceOf(GitHubReviewGroupNotFoundException.class); + } } From ad15c64d71639faaae2c81fe679b435473240880 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 18 Jul 2024 17:18:46 +0900 Subject: [PATCH 03/16] =?UTF-8?q?feat:=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C,=20=EC=9D=B4=EB=AF=B8=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=ED=95=9C=20=EB=A6=AC=EB=B7=B0=EA=B0=80=20=EC=9E=88?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EC=9D=80=EC=A7=80=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReviewContentExistException.java | 10 +++++ .../review/service/ReviewService.java | 4 ++ .../reviewme/review/ReviewServiceTest.java | 41 +++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java diff --git a/backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java b/backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java new file mode 100644 index 000000000..bcedf584b --- /dev/null +++ b/backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java @@ -0,0 +1,10 @@ +package reviewme.review.exception; + +import reviewme.global.exception.BadRequestException; + +public class ReviewContentExistException extends BadRequestException { + + public ReviewContentExistException() { + super("이미 리뷰를 작성한 경우 리뷰를 작성할 수 없습니다."); + } +} diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index ff5f05735..1ba43304d 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -52,6 +52,10 @@ public Long createReview(CreateReviewRequest request) { throw new GitHubReviewGroupNotFoundException(); } + if (reviewContentRepository.existsById(review.getId())) { + throw new ReviewContentExistException(); + } + List contents = request.contents() .stream() .map(content -> new ReviewContent(review, content.question(), content.answer())) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index fdc656f61..89d01f259 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -20,6 +20,8 @@ import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewResponse; import reviewme.review.exception.GitHubReviewGroupNotFoundException; +import reviewme.review.exception.ReviewContentExistException; +import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewRepository; import reviewme.review.service.ReviewService; import reviewme.support.ServiceTest; @@ -45,6 +47,9 @@ class ReviewServiceTest { @Autowired KeywordRepository keywordRepository; + @Autowired + ReviewContentRepository reviewContentRepository; + @Test void 리뷰를_작성한다() { // given @@ -132,4 +137,40 @@ class ReviewServiceTest { assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) .isInstanceOf(GitHubReviewGroupNotFoundException.class); } + + @Test + void 이미_작성한_리뷰가_있는데_리뷰를_작성할_경우_예외를_발생한다() { + // given + Member reviewee = memberRepository.save(new Member("아루", "aru")); + Member reviewer = memberRepository.save(new Member("테드", "ted")); + ReviewerGroup reviewerGroup = reviewerGroupRepository.save(new ReviewerGroup( + reviewee, + "그룹A", + "그룹 설명", + LocalDateTime.of(2024, 1, 1, 1, 1)) + ); + gitHubReviewGroupRepository.save(new GitHubReviewGroup("ted", reviewerGroup)); + + Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); + Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); + + CreateReviewContentRequest contentRequest1 = new CreateReviewContentRequest( + 1L, "소프트스킬이 어떤가요?", "소통을 잘해요" + ); + CreateReviewContentRequest contentRequest2 = new CreateReviewContentRequest( + 2L, "기술역량이 어떤가요?", "스트림을 잘다뤄요" + ); + CreateReviewRequest createReviewRequest = new CreateReviewRequest( + reviewer.getId(), + reviewerGroup.getId(), + List.of(contentRequest1, contentRequest2), + List.of(keyword1.getId(), keyword2.getId()) + ); + + reviewService.createReview(createReviewRequest); + + // when, then + assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) + .isInstanceOf(ReviewContentExistException.class); + } } From 7c4f7dbf75de760c22abea4e8b2ec202df8b9b0f Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 18 Jul 2024 19:21:36 +0900 Subject: [PATCH 04/16] =?UTF-8?q?refactor:=20Review=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=EC=9D=98=20reviewer=EC=99=80=EC=9D=98=20=EC=97=B0?= =?UTF-8?q?=EA=B4=80=EA=B4=80=EA=B3=84=20ManyToOne=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/java/reviewme/review/domain/Review.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/main/java/reviewme/review/domain/Review.java b/backend/src/main/java/reviewme/review/domain/Review.java index 43f0e5cae..c841eba4e 100644 --- a/backend/src/main/java/reviewme/review/domain/Review.java +++ b/backend/src/main/java/reviewme/review/domain/Review.java @@ -6,7 +6,6 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; -import jakarta.persistence.OneToOne; import jakarta.persistence.Table; import lombok.AccessLevel; import lombok.Getter; @@ -24,7 +23,7 @@ public class Review { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @OneToOne + @ManyToOne @JoinColumn(name = "reviewer_id", nullable = false) private Member reviewer; From ca454df5949e5c12531b90ddde35ec93a2ead009 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Thu, 18 Jul 2024 19:22:00 +0900 Subject: [PATCH 05/16] =?UTF-8?q?refactor:=20=EC=BB=AC=EB=9F=BC=EB=AA=85?= =?UTF-8?q?=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/reviewme/member/domain/GitHubReviewGroup.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java b/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java index a50cf6bb8..4d8cd4bfd 100644 --- a/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java +++ b/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java @@ -24,7 +24,7 @@ public class GitHubReviewGroup { private String gitHubId; @ManyToOne - @JoinColumn(name = "reviewer_group") + @JoinColumn(name = "reviewer_group_id") private ReviewerGroup reviewerGroup; public GitHubReviewGroup(String gitHubId, ReviewerGroup reviewerGroup) { From 7201ff004eb2f3f2d1acf3c9dc35e1dd1183c49c Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 10:40:28 +0900 Subject: [PATCH 06/16] =?UTF-8?q?refactor:=20gitHub=20=ED=91=9C=EA=B8=B0?= =?UTF-8?q?=20->=20github=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tHubReviewGroup.java => GithubReviewGroup.java} | 10 +++++----- .../main/java/reviewme/member/domain/Member.java | 8 ++++---- ...itory.java => GithubReviewGroupRepository.java} | 6 +++--- ...ava => GithubReviewGroupNotFoundException.java} | 4 ++-- .../reviewme/review/service/ReviewService.java | 12 ++++++------ .../java/reviewme/review/ReviewServiceTest.java | 14 +++++++------- 6 files changed, 27 insertions(+), 27 deletions(-) rename backend/src/main/java/reviewme/member/domain/{GitHubReviewGroup.java => GithubReviewGroup.java} (77%) rename backend/src/main/java/reviewme/member/repository/{GitHubReviewGroupRepository.java => GithubReviewGroupRepository.java} (53%) rename backend/src/main/java/reviewme/review/exception/{GitHubReviewGroupNotFoundException.java => GithubReviewGroupNotFoundException.java} (64%) diff --git a/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java b/backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java similarity index 77% rename from backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java rename to backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java index 4d8cd4bfd..c54161fac 100644 --- a/backend/src/main/java/reviewme/member/domain/GitHubReviewGroup.java +++ b/backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java @@ -12,23 +12,23 @@ import lombok.NoArgsConstructor; @Entity -@Table(name = "git_hub_review_group") +@Table(name = "github_review_group") @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter -public class GitHubReviewGroup { +public class GithubReviewGroup { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - private String gitHubId; + private String githubId; @ManyToOne @JoinColumn(name = "reviewer_group_id") private ReviewerGroup reviewerGroup; - public GitHubReviewGroup(String gitHubId, ReviewerGroup reviewerGroup) { - this.gitHubId = gitHubId; + public GithubReviewGroup(String githubId, ReviewerGroup reviewerGroup) { + this.githubId = githubId; this.reviewerGroup = reviewerGroup; } } diff --git a/backend/src/main/java/reviewme/member/domain/Member.java b/backend/src/main/java/reviewme/member/domain/Member.java index 6aaf6da65..f86f0f67e 100644 --- a/backend/src/main/java/reviewme/member/domain/Member.java +++ b/backend/src/main/java/reviewme/member/domain/Member.java @@ -23,11 +23,11 @@ public class Member { @Column(name = "name", nullable = false) private String name; - @Column(name = "git_hub_id", nullable = false) - private String gitHubId; + @Column(name = "github_id", nullable = false) + private String githubId; - public Member(String name, String gitHubId) { + public Member(String name, String githubId) { this.name = name; - this.gitHubId = gitHubId; + this.githubId = githubId; } } diff --git a/backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java b/backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java similarity index 53% rename from backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java rename to backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java index c11f2320b..67449040f 100644 --- a/backend/src/main/java/reviewme/member/repository/GitHubReviewGroupRepository.java +++ b/backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java @@ -2,11 +2,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import reviewme.member.domain.GitHubReviewGroup; +import reviewme.member.domain.GithubReviewGroup; import reviewme.member.domain.ReviewerGroup; @Repository -public interface GitHubReviewGroupRepository extends JpaRepository { +public interface GithubReviewGroupRepository extends JpaRepository { - boolean existsByGitHubIdAndReviewerGroup(String gitHubId, ReviewerGroup reviewerGroup); + boolean existsByGithubIdAndReviewerGroup(String githubId, ReviewerGroup reviewerGroup); } diff --git a/backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java b/backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java similarity index 64% rename from backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java rename to backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java index 55e92e787..4740266e5 100644 --- a/backend/src/main/java/reviewme/review/exception/GitHubReviewGroupNotFoundException.java +++ b/backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java @@ -2,9 +2,9 @@ import reviewme.global.exception.NotFoundException; -public class GitHubReviewGroupNotFoundException extends NotFoundException { +public class GithubReviewGroupNotFoundException extends NotFoundException { - public GitHubReviewGroupNotFoundException() { + public GithubReviewGroupNotFoundException() { super("일치하는 깃헙 사용자와 리뷰어 그룹이 존재하지 않습니다."); } } diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index 1ba43304d..4f90771b6 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -11,7 +11,7 @@ import reviewme.member.domain.ReviewerGroup; import reviewme.member.dto.response.MemberResponse; import reviewme.member.dto.response.ReviewerGroupResponse; -import reviewme.member.repository.GitHubReviewGroupRepository; +import reviewme.member.repository.GithubReviewGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; @@ -20,7 +20,7 @@ import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewContentResponse; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GitHubReviewGroupNotFoundException; +import reviewme.review.exception.GithubReviewGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewKeywordRepository; @@ -33,7 +33,7 @@ public class ReviewService { private final ReviewRepository reviewRepository; private final MemberRepository memberRepository; private final ReviewerGroupRepository reviewerGroupRepository; - private final GitHubReviewGroupRepository gitHubReviewGroupRepository; + private final GithubReviewGroupRepository githubReviewGroupRepository; private final ReviewContentRepository reviewContentRepository; private final KeywordRepository keywordRepository; private final ReviewKeywordRepository reviewKeywordRepository; @@ -44,12 +44,12 @@ public Long createReview(CreateReviewRequest request) { ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(request.reviewerGroupId()); Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); - boolean isValidReviewer = gitHubReviewGroupRepository.existsByGitHubIdAndReviewerGroup( - reviewer.getGitHubId(), + boolean isValidReviewer = githubReviewGroupRepository.existsByGithubIdAndReviewerGroup( + reviewer.getGithubId(), reviewerGroup ); if (!isValidReviewer) { - throw new GitHubReviewGroupNotFoundException(); + throw new GithubReviewGroupNotFoundException(); } if (reviewContentRepository.existsById(review.getId())) { diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 89d01f259..954d4e46f 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -9,17 +9,17 @@ import org.springframework.beans.factory.annotation.Autowired; import reviewme.keyword.domain.Keyword; import reviewme.keyword.repository.KeywordRepository; -import reviewme.member.domain.GitHubReviewGroup; +import reviewme.member.domain.GithubReviewGroup; import reviewme.member.domain.Member; import reviewme.member.domain.ReviewerGroup; -import reviewme.member.repository.GitHubReviewGroupRepository; +import reviewme.member.repository.GithubReviewGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; import reviewme.review.dto.request.CreateReviewContentRequest; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GitHubReviewGroupNotFoundException; +import reviewme.review.exception.GithubReviewGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewRepository; @@ -42,7 +42,7 @@ class ReviewServiceTest { ReviewerGroupRepository reviewerGroupRepository; @Autowired - GitHubReviewGroupRepository gitHubReviewGroupRepository; + GithubReviewGroupRepository githubReviewGroupRepository; @Autowired KeywordRepository keywordRepository; @@ -115,7 +115,7 @@ class ReviewServiceTest { "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); - gitHubReviewGroupRepository.save(new GitHubReviewGroup("kirby", reviewerGroup)); + githubReviewGroupRepository.save(new GithubReviewGroup("kirby", reviewerGroup)); Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); @@ -135,7 +135,7 @@ class ReviewServiceTest { // when, then assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) - .isInstanceOf(GitHubReviewGroupNotFoundException.class); + .isInstanceOf(GithubReviewGroupNotFoundException.class); } @Test @@ -149,7 +149,7 @@ class ReviewServiceTest { "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); - gitHubReviewGroupRepository.save(new GitHubReviewGroup("ted", reviewerGroup)); + githubReviewGroupRepository.save(new GithubReviewGroup("ted", reviewerGroup)); Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); From e016c8ed0ed8e844550530e2aa25e63654b138dc Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 10:43:16 +0900 Subject: [PATCH 07/16] =?UTF-8?q?refactor:=20GithubReviewGroup=20->=20Gith?= =?UTF-8?q?ubReviewGroup=20=ED=81=B4=EB=9E=98=EC=8A=A4=EB=AA=85=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ubReviewGroup.java => GithubReviewerGroup.java} | 6 +++--- ...ory.java => GithubReviewerGroupRepository.java} | 4 ++-- ...a => GithubReviewerGroupNotFoundException.java} | 4 ++-- .../reviewme/review/service/ReviewService.java | 10 +++++----- .../java/reviewme/review/ReviewServiceTest.java | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) rename backend/src/main/java/reviewme/member/domain/{GithubReviewGroup.java => GithubReviewerGroup.java} (83%) rename backend/src/main/java/reviewme/member/repository/{GithubReviewGroupRepository.java => GithubReviewerGroupRepository.java} (66%) rename backend/src/main/java/reviewme/review/exception/{GithubReviewGroupNotFoundException.java => GithubReviewerGroupNotFoundException.java} (60%) diff --git a/backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java b/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java similarity index 83% rename from backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java rename to backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java index c54161fac..a22ae27bc 100644 --- a/backend/src/main/java/reviewme/member/domain/GithubReviewGroup.java +++ b/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java @@ -12,10 +12,10 @@ import lombok.NoArgsConstructor; @Entity -@Table(name = "github_review_group") +@Table(name = "github_reviewer_group") @NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter -public class GithubReviewGroup { +public class GithubReviewerGroup { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -27,7 +27,7 @@ public class GithubReviewGroup { @JoinColumn(name = "reviewer_group_id") private ReviewerGroup reviewerGroup; - public GithubReviewGroup(String githubId, ReviewerGroup reviewerGroup) { + public GithubReviewerGroup(String githubId, ReviewerGroup reviewerGroup) { this.githubId = githubId; this.reviewerGroup = reviewerGroup; } diff --git a/backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java b/backend/src/main/java/reviewme/member/repository/GithubReviewerGroupRepository.java similarity index 66% rename from backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java rename to backend/src/main/java/reviewme/member/repository/GithubReviewerGroupRepository.java index 67449040f..71ce55744 100644 --- a/backend/src/main/java/reviewme/member/repository/GithubReviewGroupRepository.java +++ b/backend/src/main/java/reviewme/member/repository/GithubReviewerGroupRepository.java @@ -2,11 +2,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import reviewme.member.domain.GithubReviewGroup; +import reviewme.member.domain.GithubReviewerGroup; import reviewme.member.domain.ReviewerGroup; @Repository -public interface GithubReviewGroupRepository extends JpaRepository { +public interface GithubReviewerGroupRepository extends JpaRepository { boolean existsByGithubIdAndReviewerGroup(String githubId, ReviewerGroup reviewerGroup); } diff --git a/backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java b/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java similarity index 60% rename from backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java rename to backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java index 4740266e5..58a6f249d 100644 --- a/backend/src/main/java/reviewme/review/exception/GithubReviewGroupNotFoundException.java +++ b/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java @@ -2,9 +2,9 @@ import reviewme.global.exception.NotFoundException; -public class GithubReviewGroupNotFoundException extends NotFoundException { +public class GithubReviewerGroupNotFoundException extends NotFoundException { - public GithubReviewGroupNotFoundException() { + public GithubReviewerGroupNotFoundException() { super("일치하는 깃헙 사용자와 리뷰어 그룹이 존재하지 않습니다."); } } diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index 4f90771b6..d55d63bc0 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -11,7 +11,7 @@ import reviewme.member.domain.ReviewerGroup; import reviewme.member.dto.response.MemberResponse; import reviewme.member.dto.response.ReviewerGroupResponse; -import reviewme.member.repository.GithubReviewGroupRepository; +import reviewme.member.repository.GithubReviewerGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; @@ -20,7 +20,7 @@ import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewContentResponse; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GithubReviewGroupNotFoundException; +import reviewme.review.exception.GithubReviewerGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewKeywordRepository; @@ -33,7 +33,7 @@ public class ReviewService { private final ReviewRepository reviewRepository; private final MemberRepository memberRepository; private final ReviewerGroupRepository reviewerGroupRepository; - private final GithubReviewGroupRepository githubReviewGroupRepository; + private final GithubReviewerGroupRepository githubReviewerGroupRepository; private final ReviewContentRepository reviewContentRepository; private final KeywordRepository keywordRepository; private final ReviewKeywordRepository reviewKeywordRepository; @@ -44,12 +44,12 @@ public Long createReview(CreateReviewRequest request) { ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(request.reviewerGroupId()); Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); - boolean isValidReviewer = githubReviewGroupRepository.existsByGithubIdAndReviewerGroup( + boolean isValidReviewer = githubReviewerGroupRepository.existsByGithubIdAndReviewerGroup( reviewer.getGithubId(), reviewerGroup ); if (!isValidReviewer) { - throw new GithubReviewGroupNotFoundException(); + throw new GithubReviewerGroupNotFoundException(); } if (reviewContentRepository.existsById(review.getId())) { diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 954d4e46f..e0ff2025c 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -9,17 +9,17 @@ import org.springframework.beans.factory.annotation.Autowired; import reviewme.keyword.domain.Keyword; import reviewme.keyword.repository.KeywordRepository; -import reviewme.member.domain.GithubReviewGroup; +import reviewme.member.domain.GithubReviewerGroup; import reviewme.member.domain.Member; import reviewme.member.domain.ReviewerGroup; -import reviewme.member.repository.GithubReviewGroupRepository; +import reviewme.member.repository.GithubReviewerGroupRepository; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; import reviewme.review.domain.Review; import reviewme.review.dto.request.CreateReviewContentRequest; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GithubReviewGroupNotFoundException; +import reviewme.review.exception.GithubReviewerGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewRepository; @@ -42,7 +42,7 @@ class ReviewServiceTest { ReviewerGroupRepository reviewerGroupRepository; @Autowired - GithubReviewGroupRepository githubReviewGroupRepository; + GithubReviewerGroupRepository githubReviewerGroupRepository; @Autowired KeywordRepository keywordRepository; @@ -115,7 +115,7 @@ class ReviewServiceTest { "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); - githubReviewGroupRepository.save(new GithubReviewGroup("kirby", reviewerGroup)); + githubReviewerGroupRepository.save(new GithubReviewerGroup("kirby", reviewerGroup)); Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); @@ -135,7 +135,7 @@ class ReviewServiceTest { // when, then assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) - .isInstanceOf(GithubReviewGroupNotFoundException.class); + .isInstanceOf(GithubReviewerGroupNotFoundException.class); } @Test @@ -149,7 +149,7 @@ class ReviewServiceTest { "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); - githubReviewGroupRepository.save(new GithubReviewGroup("ted", reviewerGroup)); + githubReviewerGroupRepository.save(new GithubReviewerGroup("ted", reviewerGroup)); Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); From c4c481e70684125d4c2c14d5e2f5a12186498f71 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 10:47:34 +0900 Subject: [PATCH 08/16] =?UTF-8?q?refactor:=20=EB=88=84=EB=9D=BD=EB=90=9C?= =?UTF-8?q?=20@Column=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/reviewme/member/domain/GithubReviewerGroup.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java b/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java index a22ae27bc..724c6b3c3 100644 --- a/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java +++ b/backend/src/main/java/reviewme/member/domain/GithubReviewerGroup.java @@ -1,5 +1,6 @@ package reviewme.member.domain; +import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; @@ -21,6 +22,7 @@ public class GithubReviewerGroup { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @Column(name = "github_id", nullable = false) private String githubId; @ManyToOne From e8b13f851bc5c7839de2a05dbb07ce82dfac4735 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 10:56:40 +0900 Subject: [PATCH 09/16] =?UTF-8?q?test:=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=8B=9C,=20?= =?UTF-8?q?=EA=B9=83=ED=97=99=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=EA=B7=B8?= =?UTF-8?q?=EB=A3=B9=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=80=EC=9E=A5=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/java/reviewme/review/ReviewServiceTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index e0ff2025c..4f5e4ff48 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -55,9 +55,10 @@ class ReviewServiceTest { // given memberRepository.save(new Member("산초", "sancho")); Member reviewee = memberRepository.save(new Member("아루", "aru")); - reviewerGroupRepository.save( + ReviewerGroup reviewerGroup = reviewerGroupRepository.save( new ReviewerGroup(reviewee, "그룹A", "그룹 설명", LocalDateTime.of(2024, 1, 1, 1, 1)) ); + githubReviewerGroupRepository.save(new GithubReviewerGroup("sancho", reviewerGroup)); Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); From 0fa761dae611542c64af2a6735914670d6e1a1a5 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 12:01:34 +0900 Subject: [PATCH 10/16] =?UTF-8?q?refactor:=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=EC=9E=91=EC=84=B1=20=EC=8B=9C,=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EB=A6=AC=EB=B7=B0=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/reviewme/review/repository/ReviewRepository.java | 4 ++++ .../src/main/java/reviewme/review/service/ReviewService.java | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/reviewme/review/repository/ReviewRepository.java b/backend/src/main/java/reviewme/review/repository/ReviewRepository.java index b07951f5f..4b485a644 100644 --- a/backend/src/main/java/reviewme/review/repository/ReviewRepository.java +++ b/backend/src/main/java/reviewme/review/repository/ReviewRepository.java @@ -3,6 +3,8 @@ import jakarta.persistence.EntityNotFoundException; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; +import reviewme.member.domain.Member; +import reviewme.member.domain.ReviewerGroup; import reviewme.review.domain.Review; @Repository @@ -11,4 +13,6 @@ public interface ReviewRepository extends JpaRepository { default Review getReviewById(Long id) { return findById(id).orElseThrow(EntityNotFoundException::new); } + + boolean existsByReviewerAndReviewerGroup(Member reviewer, ReviewerGroup reviewerGroup); } diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index d55d63bc0..65eeaaf9c 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -42,7 +42,6 @@ public class ReviewService { public Long createReview(CreateReviewRequest request) { Member reviewer = memberRepository.getMemberById(request.reviewerId()); ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(request.reviewerGroupId()); - Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); boolean isValidReviewer = githubReviewerGroupRepository.existsByGithubIdAndReviewerGroup( reviewer.getGithubId(), @@ -52,10 +51,12 @@ public Long createReview(CreateReviewRequest request) { throw new GithubReviewerGroupNotFoundException(); } - if (reviewContentRepository.existsById(review.getId())) { + if (reviewRepository.existsByReviewerAndReviewerGroup(reviewer, reviewerGroup)) { throw new ReviewContentExistException(); } + Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); + List contents = request.contents() .stream() .map(content -> new ReviewContent(review, content.question(), content.answer())) From 62f52875e6e48970a4f9e8596134b0369c6e8b41 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 12:05:44 +0900 Subject: [PATCH 11/16] =?UTF-8?q?refactor:=20GithubReviewerGroupNotFoundEx?= =?UTF-8?q?ception=EC=9D=84=20UnAuthorizedException=20=EA=B5=AC=ED=98=84?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GithubReviewerGroupNotFoundException.java | 10 ---------- .../GithubReviewerGroupUnAuthorizedException.java | 10 ++++++++++ .../java/reviewme/review/service/ReviewService.java | 3 ++- .../test/java/reviewme/review/ReviewServiceTest.java | 3 ++- 4 files changed, 14 insertions(+), 12 deletions(-) delete mode 100644 backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java create mode 100644 backend/src/main/java/reviewme/review/exception/GithubReviewerGroupUnAuthorizedException.java diff --git a/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java b/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java deleted file mode 100644 index 58a6f249d..000000000 --- a/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupNotFoundException.java +++ /dev/null @@ -1,10 +0,0 @@ -package reviewme.review.exception; - -import reviewme.global.exception.NotFoundException; - -public class GithubReviewerGroupNotFoundException extends NotFoundException { - - public GithubReviewerGroupNotFoundException() { - super("일치하는 깃헙 사용자와 리뷰어 그룹이 존재하지 않습니다."); - } -} diff --git a/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupUnAuthorizedException.java b/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupUnAuthorizedException.java new file mode 100644 index 000000000..6e5ab8749 --- /dev/null +++ b/backend/src/main/java/reviewme/review/exception/GithubReviewerGroupUnAuthorizedException.java @@ -0,0 +1,10 @@ +package reviewme.review.exception; + +import reviewme.global.exception.UnAuthorizedException; + +public class GithubReviewerGroupUnAuthorizedException extends UnAuthorizedException { + + public GithubReviewerGroupUnAuthorizedException() { + super("리뷰어 그룹에 등록되지 않은 github 사용자입니다."); + } +} diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index 65eeaaf9c..c2f70c2b3 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -22,6 +22,7 @@ import reviewme.review.dto.response.ReviewResponse; import reviewme.review.exception.GithubReviewerGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; +import reviewme.review.exception.GithubReviewerGroupUnAuthorizedException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewKeywordRepository; import reviewme.review.repository.ReviewRepository; @@ -48,7 +49,7 @@ public Long createReview(CreateReviewRequest request) { reviewerGroup ); if (!isValidReviewer) { - throw new GithubReviewerGroupNotFoundException(); + throw new GithubReviewerGroupUnAuthorizedException(); } if (reviewRepository.existsByReviewerAndReviewerGroup(reviewer, reviewerGroup)) { diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 4f5e4ff48..227dec55b 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -21,6 +21,7 @@ import reviewme.review.dto.response.ReviewResponse; import reviewme.review.exception.GithubReviewerGroupNotFoundException; import reviewme.review.exception.ReviewContentExistException; +import reviewme.review.exception.GithubReviewerGroupUnAuthorizedException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewRepository; import reviewme.review.service.ReviewService; @@ -136,7 +137,7 @@ class ReviewServiceTest { // when, then assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) - .isInstanceOf(GithubReviewerGroupNotFoundException.class); + .isInstanceOf(GithubReviewerGroupUnAuthorizedException.class); } @Test From 1e71db6b2b4e02bd9defb1ab514050127f6ff2ce Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 12:06:50 +0900 Subject: [PATCH 12/16] =?UTF-8?q?refactor:=20ReviewContentExistException?= =?UTF-8?q?=20->=20ReviewAlreadySubmittedException=20=ED=81=B4=EB=9E=98?= =?UTF-8?q?=EC=8A=A4=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stException.java => ReviewAlreadySubmittedException.java} | 4 ++-- .../src/main/java/reviewme/review/service/ReviewService.java | 5 ++--- backend/src/test/java/reviewme/review/ReviewServiceTest.java | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) rename backend/src/main/java/reviewme/review/exception/{ReviewContentExistException.java => ReviewAlreadySubmittedException.java} (60%) diff --git a/backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java b/backend/src/main/java/reviewme/review/exception/ReviewAlreadySubmittedException.java similarity index 60% rename from backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java rename to backend/src/main/java/reviewme/review/exception/ReviewAlreadySubmittedException.java index bcedf584b..f4ae46187 100644 --- a/backend/src/main/java/reviewme/review/exception/ReviewContentExistException.java +++ b/backend/src/main/java/reviewme/review/exception/ReviewAlreadySubmittedException.java @@ -2,9 +2,9 @@ import reviewme.global.exception.BadRequestException; -public class ReviewContentExistException extends BadRequestException { +public class ReviewAlreadySubmittedException extends BadRequestException { - public ReviewContentExistException() { + public ReviewAlreadySubmittedException() { super("이미 리뷰를 작성한 경우 리뷰를 작성할 수 없습니다."); } } diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index c2f70c2b3..8defb09d9 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -20,9 +20,8 @@ import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewContentResponse; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GithubReviewerGroupNotFoundException; -import reviewme.review.exception.ReviewContentExistException; import reviewme.review.exception.GithubReviewerGroupUnAuthorizedException; +import reviewme.review.exception.ReviewAlreadySubmittedException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewKeywordRepository; import reviewme.review.repository.ReviewRepository; @@ -53,7 +52,7 @@ public Long createReview(CreateReviewRequest request) { } if (reviewRepository.existsByReviewerAndReviewerGroup(reviewer, reviewerGroup)) { - throw new ReviewContentExistException(); + throw new ReviewAlreadySubmittedException(); } Review review = reviewRepository.save(new Review(reviewer, reviewerGroup)); diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 227dec55b..908631277 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -19,9 +19,8 @@ import reviewme.review.dto.request.CreateReviewContentRequest; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewResponse; -import reviewme.review.exception.GithubReviewerGroupNotFoundException; -import reviewme.review.exception.ReviewContentExistException; import reviewme.review.exception.GithubReviewerGroupUnAuthorizedException; +import reviewme.review.exception.ReviewAlreadySubmittedException; import reviewme.review.repository.ReviewContentRepository; import reviewme.review.repository.ReviewRepository; import reviewme.review.service.ReviewService; @@ -173,6 +172,6 @@ class ReviewServiceTest { // when, then assertThatThrownBy(() -> reviewService.createReview(createReviewRequest)) - .isInstanceOf(ReviewContentExistException.class); + .isInstanceOf(ReviewAlreadySubmittedException.class); } } From 26ec62c91da820c6032f7273b38945f9326bd50e Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 13:13:35 +0900 Subject: [PATCH 13/16] =?UTF-8?q?feat:=20UnAuthorizedException=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reviewme/global/exception/UnAuthorizedException.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 backend/src/main/java/reviewme/global/exception/UnAuthorizedException.java diff --git a/backend/src/main/java/reviewme/global/exception/UnAuthorizedException.java b/backend/src/main/java/reviewme/global/exception/UnAuthorizedException.java new file mode 100644 index 000000000..6d4f1e65b --- /dev/null +++ b/backend/src/main/java/reviewme/global/exception/UnAuthorizedException.java @@ -0,0 +1,8 @@ +package reviewme.global.exception; + +public abstract class UnAuthorizedException extends ReviewMeException { + + protected UnAuthorizedException(String errorMessage) { + super(errorMessage); + } +} From 6a9106978648734dc19b1ae2af61d2c50bd9daff Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 13:49:03 +0900 Subject: [PATCH 14/16] =?UTF-8?q?refactor:=20=EB=A9=94=EC=84=9C=EB=93=9C?= =?UTF-8?q?=20=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/reviewme/review/repository/ReviewRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/reviewme/review/repository/ReviewRepository.java b/backend/src/main/java/reviewme/review/repository/ReviewRepository.java index 4b485a644..f00f53bc8 100644 --- a/backend/src/main/java/reviewme/review/repository/ReviewRepository.java +++ b/backend/src/main/java/reviewme/review/repository/ReviewRepository.java @@ -10,9 +10,9 @@ @Repository public interface ReviewRepository extends JpaRepository { + boolean existsByReviewerAndReviewerGroup(Member reviewer, ReviewerGroup reviewerGroup); + default Review getReviewById(Long id) { return findById(id).orElseThrow(EntityNotFoundException::new); } - - boolean existsByReviewerAndReviewerGroup(Member reviewer, ReviewerGroup reviewerGroup); } From 9e7001d0f5919eda3ce21c638177091497616a4f Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 13:49:20 +0900 Subject: [PATCH 15/16] =?UTF-8?q?test:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20given=EC=A0=88=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reviewme/review/ReviewServiceTest.java | 26 +++---------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 908631277..438b6f814 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -118,20 +118,11 @@ class ReviewServiceTest { ); githubReviewerGroupRepository.save(new GithubReviewerGroup("kirby", reviewerGroup)); - Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); - Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); - - CreateReviewContentRequest contentRequest1 = new CreateReviewContentRequest( - 1L, "소프트스킬이 어떤가요?", "소통을 잘해요" - ); - CreateReviewContentRequest contentRequest2 = new CreateReviewContentRequest( - 2L, "기술역량이 어떤가요?", "스트림을 잘다뤄요" - ); CreateReviewRequest createReviewRequest = new CreateReviewRequest( reviewer.getId(), reviewerGroup.getId(), - List.of(contentRequest1, contentRequest2), - List.of(keyword1.getId(), keyword2.getId()) + List.of(), + List.of() ); // when, then @@ -152,20 +143,11 @@ class ReviewServiceTest { ); githubReviewerGroupRepository.save(new GithubReviewerGroup("ted", reviewerGroup)); - Keyword keyword1 = keywordRepository.save(new Keyword("꼼꼼해요")); - Keyword keyword2 = keywordRepository.save(new Keyword("친절해요")); - - CreateReviewContentRequest contentRequest1 = new CreateReviewContentRequest( - 1L, "소프트스킬이 어떤가요?", "소통을 잘해요" - ); - CreateReviewContentRequest contentRequest2 = new CreateReviewContentRequest( - 2L, "기술역량이 어떤가요?", "스트림을 잘다뤄요" - ); CreateReviewRequest createReviewRequest = new CreateReviewRequest( reviewer.getId(), reviewerGroup.getId(), - List.of(contentRequest1, contentRequest2), - List.of(keyword1.getId(), keyword2.getId()) + List.of(), + List.of() ); reviewService.createReview(createReviewRequest); From d221ebe5e008acadaf8382691d6aef99aad33701 Mon Sep 17 00:00:00 2001 From: hyeonjilee Date: Fri, 19 Jul 2024 13:52:53 +0900 Subject: [PATCH 16/16] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= =?UTF-8?q?=EB=A5=BC=20=EC=9C=84=ED=95=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=82=BD=EC=9E=85=20repository=EB=A5=BC=20=ED=99=9C=EC=9A=A9?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/test/java/reviewme/review/ReviewServiceTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/test/java/reviewme/review/ReviewServiceTest.java b/backend/src/test/java/reviewme/review/ReviewServiceTest.java index 438b6f814..70e003ab2 100644 --- a/backend/src/test/java/reviewme/review/ReviewServiceTest.java +++ b/backend/src/test/java/reviewme/review/ReviewServiceTest.java @@ -150,7 +150,7 @@ class ReviewServiceTest { List.of() ); - reviewService.createReview(createReviewRequest); + reviewRepository.save(new Review(reviewer, reviewerGroup)); // when, then assertThatThrownBy(() -> reviewService.createReview(createReviewRequest))