From 5ab0ac9b063c65df3c6c55e8e94960701704aa24 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Sun, 6 Oct 2024 01:44:12 +0900 Subject: [PATCH 1/9] =?UTF-8?q?feat:=20=EC=9A=B0=EC=88=98=20=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=EC=9B=90=20=EC=A7=80=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EC=B2=A0=ED=9A=8C=20API=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/MentorStudyAchievementController.java | 40 +++++++++++++++++ .../MentorStudyAchievementService.java | 44 +++++++++++++++++++ .../request/OutstandingStudentRequest.java | 5 +++ 3 files changed, 89 insertions(+) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyAchievementController.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyAchievementController.java b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyAchievementController.java new file mode 100644 index 000000000..6b1f26455 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/api/MentorStudyAchievementController.java @@ -0,0 +1,40 @@ +package com.gdschongik.gdsc.domain.study.api; + +import com.gdschongik.gdsc.domain.study.application.MentorStudyAchievementService; +import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Mentor StudyAchievement", description = "멘토 스터디 우수 스터디원 관리 API입니다.") +@RestController +@RequestMapping("/mentor/study-achievements") +@RequiredArgsConstructor +public class MentorStudyAchievementController { + + private final MentorStudyAchievementService mentorStudyAchievementService; + + @Operation(summary = "우수 스터디원 지정", description = "우수 스터디원으로 지정합니다.") + @PostMapping + public ResponseEntity designateOutstandingStudent( + @RequestParam(name = "studyId") Long studyId, @Valid @RequestBody OutstandingStudentRequest request) { + mentorStudyAchievementService.designateOutstandingStudent(studyId, request); + return ResponseEntity.ok().build(); + } + + @Operation(summary = "우수 스터디원 철회", description = "우수 스터디원 지정을 철회합니다.") + @DeleteMapping + public ResponseEntity withdrawOutstandingStudent( + @RequestParam(name = "studyId") Long studyId, @Valid @RequestBody OutstandingStudentRequest request) { + mentorStudyAchievementService.withdrawOutstandingStudent(studyId, request); + return ResponseEntity.ok().build(); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java new file mode 100644 index 000000000..f0fbf7a4c --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -0,0 +1,44 @@ +package com.gdschongik.gdsc.domain.study.application; + +import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.study.dao.StudyRepository; +import com.gdschongik.gdsc.domain.study.domain.Study; +import com.gdschongik.gdsc.domain.study.domain.StudyValidator; +import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; +import com.gdschongik.gdsc.global.util.MemberUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Slf4j +@Service +@RequiredArgsConstructor +public class MentorStudyAchievementService { + + private final MemberUtil memberUtil; + private final StudyValidator studyValidator; + private final StudyRepository studyRepository; + + @Transactional + public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest request) { + Member currentMember = memberUtil.getCurrentMember(); + Study study = studyRepository.getById(studyId); + studyValidator.validateStudyMentor(currentMember, study); + + // todo: 지정 로직 추가 + log.info( + "[MentorStudyAchievementService] 우수 스터디원 지정: studyId={}, studentIds={}", studyId, request.studentIds()); + } + + @Transactional + public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest request) { + Member currentMember = memberUtil.getCurrentMember(); + Study study = studyRepository.getById(studyId); + studyValidator.validateStudyMentor(currentMember, study); + + // todo: 철회 로직 추가 + log.info( + "[MentorStudyAchievementService] 우수 스터디원 철회: studyId={}, studentIds={}", studyId, request.studentIds()); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java new file mode 100644 index 000000000..371a4eb81 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java @@ -0,0 +1,5 @@ +package com.gdschongik.gdsc.domain.study.dto.request; + +import java.util.List; + +public record OutstandingStudentRequest(List studentIds) {} From 35b1e51bec22b507e709603629fb63ef92ef8783 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 8 Oct 2024 22:19:45 +0900 Subject: [PATCH 2/9] =?UTF-8?q?feat:=20=EC=9A=B0=EC=88=98=20=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=EC=9B=90=20=EC=A7=80=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EC=B2=A0=ED=9A=8C=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MentorStudyAchievementService.java | 17 +++++++++++++++-- .../dao/StudyAchievementCustomRepository.java | 4 ++++ .../StudyAchievementCustomRepositoryImpl.java | 13 +++++++++++++ .../dto/request/OutstandingStudentRequest.java | 3 ++- 4 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java index f0fbf7a4c..226cd2fd0 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -1,11 +1,15 @@ package com.gdschongik.gdsc.domain.study.application; +import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.study.dao.StudyAchievementRepository; import com.gdschongik.gdsc.domain.study.dao.StudyRepository; import com.gdschongik.gdsc.domain.study.domain.Study; +import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; import com.gdschongik.gdsc.domain.study.domain.StudyValidator; import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; import com.gdschongik.gdsc.global.util.MemberUtil; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -19,6 +23,8 @@ public class MentorStudyAchievementService { private final MemberUtil memberUtil; private final StudyValidator studyValidator; private final StudyRepository studyRepository; + private final StudyAchievementRepository studyAchievementRepository; + private final MemberRepository memberRepository; @Transactional public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest request) { @@ -26,7 +32,12 @@ public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest Study study = studyRepository.getById(studyId); studyValidator.validateStudyMentor(currentMember, study); - // todo: 지정 로직 추가 + List outstandingStudents = memberRepository.findAllById(request.studentIds()); + List studyAchievements = outstandingStudents.stream() + .map(member -> StudyAchievement.create(member, study, request.achievementType())) + .toList(); + studyAchievementRepository.saveAll(studyAchievements); + log.info( "[MentorStudyAchievementService] 우수 스터디원 지정: studyId={}, studentIds={}", studyId, request.studentIds()); } @@ -37,7 +48,9 @@ public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest r Study study = studyRepository.getById(studyId); studyValidator.validateStudyMentor(currentMember, study); - // todo: 철회 로직 추가 + studyAchievementRepository.deleteByStudyAndAchievementTypeAndMemberIds( + studyId, request.achievementType(), request.studentIds()); + log.info( "[MentorStudyAchievementService] 우수 스터디원 철회: studyId={}, studentIds={}", studyId, request.studentIds()); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepository.java index 2b14404f6..a6ad466ec 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepository.java @@ -1,8 +1,12 @@ package com.gdschongik.gdsc.domain.study.dao; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; import java.util.List; public interface StudyAchievementCustomRepository { List findByStudyIdAndMemberIds(Long studyId, List memberIds); + + void deleteByStudyAndAchievementTypeAndMemberIds( + Long studyId, AchievementType achievementType, List memberIds); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepositoryImpl.java index 8eb3a9f46..0f8945573 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyAchievementCustomRepositoryImpl.java @@ -2,6 +2,7 @@ import static com.gdschongik.gdsc.domain.study.domain.QStudyAchievement.*; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -21,6 +22,18 @@ public List findByStudyIdAndMemberIds(Long studyId, List .fetch(); } + @Override + public void deleteByStudyAndAchievementTypeAndMemberIds( + Long studyId, AchievementType achievementType, List memberIds) { + queryFactory + .delete(studyAchievement) + .where( + eqStudyId(studyId), + studyAchievement.achievementType.eq(achievementType), + studyAchievement.student.id.in(memberIds)) + .execute(); + } + private BooleanExpression eqStudyId(Long studyId) { return studyId != null ? studyAchievement.study.id.eq(studyId) : null; } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java b/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java index 371a4eb81..771d09eef 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dto/request/OutstandingStudentRequest.java @@ -1,5 +1,6 @@ package com.gdschongik.gdsc.domain.study.dto.request; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; import java.util.List; -public record OutstandingStudentRequest(List studentIds) {} +public record OutstandingStudentRequest(List studentIds, AchievementType achievementType) {} From ec201370434dc52269a301053ef1c255a5a30e78 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 9 Oct 2024 11:48:24 +0900 Subject: [PATCH 3/9] =?UTF-8?q?test:=20=EC=9A=B0=EC=88=98=20=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=EC=9B=90=20=EC=A7=80=EC=A0=95=20=EB=B0=8F=20?= =?UTF-8?q?=EC=B2=A0=ED=9A=8C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=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 --- .../MentorStudyAchievementServiceTest.java | 81 +++++++++++++++++++ .../gdsc/helper/IntegrationTest.java | 21 +++++ 2 files changed, 102 insertions(+) create mode 100644 src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java new file mode 100644 index 000000000..6e12addf0 --- /dev/null +++ b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java @@ -0,0 +1,81 @@ +package com.gdschongik.gdsc.domain.study.application; + +import static com.gdschongik.gdsc.domain.study.domain.AchievementType.*; +import static org.assertj.core.api.Assertions.*; + +import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period; +import com.gdschongik.gdsc.domain.study.domain.Study; +import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; +import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; +import com.gdschongik.gdsc.helper.IntegrationTest; +import java.time.LocalDateTime; +import java.util.List; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +public class MentorStudyAchievementServiceTest extends IntegrationTest { + + @Autowired + private MentorStudyAchievementService mentorStudyAchievementService; + + @Nested + class 우수_스터디원_지정시 { + + @Test + void 성공한다() { + // given + LocalDateTime now = LocalDateTime.now(); + Member mentor = createMentor(); + Study study = createStudy( + mentor, + Period.createPeriod(now.plusDays(5), now.plusDays(10)), + Period.createPeriod(now.minusDays(5), now)); + + Member student = createRegularMember(); + createStudyHistory(student, study); + + logoutAndReloginAs(mentor.getId(), mentor.getRole()); + OutstandingStudentRequest request = + new OutstandingStudentRequest(List.of(student.getId()), FIRST_ROUND_OUTSTANDING_STUDENT); + + // when + mentorStudyAchievementService.designateOutstandingStudent(study.getId(), request); + + // then + List studyAchievements = + studyAchievementRepository.findByStudyIdAndMemberIds(study.getId(), request.studentIds()); + assertThat(studyAchievements).hasSize(request.studentIds().size()); + } + } + + @Nested + class 우수_스터디원_철회시 { + + @Test + void 성공한다() { + // given + Member student = createRegularMember(); + LocalDateTime now = LocalDateTime.now(); + Member mentor = createMentor(); + Study study = createStudy( + mentor, + Period.createPeriod(now.plusDays(5), now.plusDays(10)), + Period.createPeriod(now.minusDays(5), now)); + createStudyAchievement(student, study, FIRST_ROUND_OUTSTANDING_STUDENT); + + logoutAndReloginAs(mentor.getId(), mentor.getRole()); + OutstandingStudentRequest request = + new OutstandingStudentRequest(List.of(student.getId()), FIRST_ROUND_OUTSTANDING_STUDENT); + + // when + mentorStudyAchievementService.withdrawOutstandingStudent(study.getId(), request); + + // then + List studyAchievements = + studyAchievementRepository.findByStudyIdAndMemberIds(study.getId(), request.studentIds()); + assertThat(studyAchievements).isEmpty(); + } + } +} diff --git a/src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java b/src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java index dbd8c601b..c2c7deed9 100644 --- a/src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java +++ b/src/test/java/com/gdschongik/gdsc/helper/IntegrationTest.java @@ -30,10 +30,15 @@ import com.gdschongik.gdsc.domain.recruitment.domain.RecruitmentRound; import com.gdschongik.gdsc.domain.recruitment.domain.RoundType; import com.gdschongik.gdsc.domain.recruitment.domain.vo.Period; +import com.gdschongik.gdsc.domain.study.dao.StudyAchievementRepository; import com.gdschongik.gdsc.domain.study.dao.StudyDetailRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository; import com.gdschongik.gdsc.domain.study.dao.StudyRepository; +import com.gdschongik.gdsc.domain.study.domain.AchievementType; import com.gdschongik.gdsc.domain.study.domain.Study; +import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; import com.gdschongik.gdsc.domain.study.domain.StudyDetail; +import com.gdschongik.gdsc.domain.study.domain.StudyHistory; import com.gdschongik.gdsc.global.security.PrincipalDetails; import com.gdschongik.gdsc.infra.feign.payment.client.PaymentClient; import com.gdschongik.gdsc.infra.github.client.GithubClient; @@ -81,6 +86,12 @@ public abstract class IntegrationTest { @Autowired protected StudyDetailRepository studyDetailRepository; + @Autowired + protected StudyHistoryRepository studyHistoryRepository; + + @Autowired + protected StudyAchievementRepository studyAchievementRepository; + @MockBean protected OnboardingRecruitmentService onboardingRecruitmentService; @@ -262,6 +273,16 @@ protected StudyDetail createNewStudyDetail(Long week, Study study, LocalDateTime return studyDetailRepository.save(studyDetail); } + protected StudyHistory createStudyHistory(Member member, Study study) { + StudyHistory studyHistory = StudyHistory.create(member, study); + return studyHistoryRepository.save(studyHistory); + } + + protected StudyAchievement createStudyAchievement(Member member, Study study, AchievementType achievementType) { + StudyAchievement studyAchievement = StudyAchievement.create(member, study, achievementType); + return studyAchievementRepository.save(studyAchievement); + } + protected StudyDetail publishAssignment(StudyDetail studyDetail) { studyDetail.publishAssignment(ASSIGNMENT_TITLE, studyDetail.getPeriod().getEndDate(), DESCRIPTION_LINK); return studyDetailRepository.save(studyDetail); From d85696d761088b63aafa44786cded8a8a3cc27a7 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 9 Oct 2024 12:27:21 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20=EC=88=98=EA=B0=95=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=20=EC=97=AC=EB=B6=80=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MentorStudyAchievementService.java | 12 ++++++++ .../dao/StudyHistoryCustomRepository.java | 8 ++++++ .../dao/StudyHistoryCustomRepositoryImpl.java | 28 +++++++++++++++++++ .../study/dao/StudyHistoryRepository.java | 2 +- .../study/domain/StudyHistoryValidator.java | 6 ++++ .../gdsc/global/exception/ErrorCode.java | 1 + .../MentorStudyAchievementServiceTest.java | 1 + 7 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java index 226cd2fd0..66c9d0a3e 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -3,9 +3,11 @@ import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.dao.StudyAchievementRepository; +import com.gdschongik.gdsc.domain.study.dao.StudyHistoryRepository; import com.gdschongik.gdsc.domain.study.dao.StudyRepository; import com.gdschongik.gdsc.domain.study.domain.Study; import com.gdschongik.gdsc.domain.study.domain.StudyAchievement; +import com.gdschongik.gdsc.domain.study.domain.StudyHistoryValidator; import com.gdschongik.gdsc.domain.study.domain.StudyValidator; import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; import com.gdschongik.gdsc.global.util.MemberUtil; @@ -22,7 +24,9 @@ public class MentorStudyAchievementService { private final MemberUtil memberUtil; private final StudyValidator studyValidator; + private final StudyHistoryValidator studyHistoryValidator; private final StudyRepository studyRepository; + private final StudyHistoryRepository studyHistoryRepository; private final StudyAchievementRepository studyAchievementRepository; private final MemberRepository memberRepository; @@ -30,7 +34,11 @@ public class MentorStudyAchievementService { public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); Study study = studyRepository.getById(studyId); + boolean isAllAppliedToStudy = + studyHistoryRepository.existsByStudyIdAndStudentIds(studyId, request.studentIds()); + studyValidator.validateStudyMentor(currentMember, study); + studyHistoryValidator.validateAppliedToStudy(isAllAppliedToStudy); List outstandingStudents = memberRepository.findAllById(request.studentIds()); List studyAchievements = outstandingStudents.stream() @@ -46,7 +54,11 @@ public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); Study study = studyRepository.getById(studyId); + boolean isAllAppliedToStudy = + studyHistoryRepository.existsByStudyIdAndStudentIds(studyId, request.studentIds()); + studyValidator.validateStudyMentor(currentMember, study); + studyHistoryValidator.validateAppliedToStudy(isAllAppliedToStudy); studyAchievementRepository.deleteByStudyAndAchievementTypeAndMemberIds( studyId, request.achievementType(), request.studentIds()); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java new file mode 100644 index 000000000..0a5fbe7bf --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java @@ -0,0 +1,8 @@ +package com.gdschongik.gdsc.domain.study.dao; + +import java.util.List; + +public interface StudyHistoryCustomRepository { + + boolean existsByStudyIdAndStudentIds(Long studyId, List studentIds); +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java new file mode 100644 index 000000000..f41c28250 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java @@ -0,0 +1,28 @@ +package com.gdschongik.gdsc.domain.study.dao; + +import static com.gdschongik.gdsc.domain.study.domain.QStudyHistory.*; + +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public class StudyHistoryCustomRepositoryImpl implements StudyHistoryCustomRepository { + + private final JPAQueryFactory queryFactory; + + @Override + public boolean existsByStudyIdAndStudentIds(Long studyId, List studentIds) { + Long count = queryFactory + .select(studyHistory.count()) + .from(studyHistory) + .where(eqStudyId(studyId), studyHistory.student.id.in(studentIds)) + .fetchOne(); + return count != null && count == studentIds.size(); + } + + private BooleanExpression eqStudyId(Long studyId) { + return studyHistory.study.id.eq(studyId); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryRepository.java index 02b61fceb..6e2dbb2cf 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryRepository.java @@ -9,7 +9,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; -public interface StudyHistoryRepository extends JpaRepository { +public interface StudyHistoryRepository extends JpaRepository, StudyHistoryCustomRepository { List findAllByStudent(Member member); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java index 2376df7b4..b92b59331 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java @@ -51,4 +51,10 @@ public void validateUpdateRepository( throw new CustomException(STUDY_HISTORY_REPOSITORY_NOT_UPDATABLE_OWNER_MISMATCH); } } + + public void validateAppliedToStudy(boolean isAllAppliedToStudy) { + if (!isAllAppliedToStudy) { + throw new CustomException(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS); + } + } } diff --git a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java index 76ac38309..e0f5ac309 100644 --- a/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java +++ b/src/main/java/com/gdschongik/gdsc/global/exception/ErrorCode.java @@ -124,6 +124,7 @@ public enum ErrorCode { STUDY_HISTORY_REPOSITORY_NOT_UPDATABLE_ASSIGNMENT_ALREADY_SUBMITTED( HttpStatus.CONFLICT, "이미 제출한 과제가 있으므로 레포지토리를 수정할 수 없습니다."), STUDY_HISTORY_REPOSITORY_NOT_UPDATABLE_OWNER_MISMATCH(HttpStatus.CONFLICT, "레포지토리 소유자가 현재 멤버와 다릅니다."), + STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS(HttpStatus.CONFLICT, "해당 스터디에 신청하지 않은 멤버가 있습니다."), // StudyAnnouncement STUDY_ANNOUNCEMENT_NOT_FOUND(HttpStatus.NOT_FOUND, "존재하지 않는 스터디 공지입니다."), diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java index 6e12addf0..6fea5b242 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementServiceTest.java @@ -63,6 +63,7 @@ class 우수_스터디원_철회시 { mentor, Period.createPeriod(now.plusDays(5), now.plusDays(10)), Period.createPeriod(now.minusDays(5), now)); + createStudyHistory(student, study); createStudyAchievement(student, study, FIRST_ROUND_OUTSTANDING_STUDENT); logoutAndReloginAs(mentor.getId(), mentor.getRole()); From 8d63cdd218bc228e3a00ac2f1e9d08977d886707 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 9 Oct 2024 12:32:21 +0900 Subject: [PATCH 5/9] =?UTF-8?q?test:=20=EC=88=98=EA=B0=95=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=20=EC=97=AC=EB=B6=80=20=EA=B2=80=EC=A6=9D=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/domain/StudyHistoryValidatorTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java index 5e6dcb2f1..8e74ef8be 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java @@ -124,4 +124,16 @@ class 레포지토리_입력시 { .hasMessage(STUDY_HISTORY_REPOSITORY_NOT_UPDATABLE_OWNER_MISMATCH.getMessage()); } } + + @Nested + class 스터디_수강신청_여부_확인시 { + + @Test + void 해당_스터디를_신청하지_않은_멤버가_있다면_실패한다() { + // when & then + assertThatThrownBy(() -> studyHistoryValidator.validateAppliedToStudy(false)) + .isInstanceOf(CustomException.class) + .hasMessage(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS.getMessage()); + } + } } From 00352c3882c2968dc34f82101a40f12d26f59e42 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 9 Oct 2024 21:06:05 +0900 Subject: [PATCH 6/9] =?UTF-8?q?refactor:=20=EB=A0=88=ED=8F=AC=EC=A7=80?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EB=A9=94=EC=84=9C=EB=93=9C=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 --- .../application/MentorStudyAchievementService.java | 14 ++++++++------ .../study/dao/StudyHistoryCustomRepository.java | 2 +- .../dao/StudyHistoryCustomRepositoryImpl.java | 5 ++--- .../domain/study/domain/StudyHistoryValidator.java | 4 ++-- .../study/domain/StudyHistoryValidatorTest.java | 7 ++++++- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java index 66c9d0a3e..bcb1970ab 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -34,11 +34,12 @@ public class MentorStudyAchievementService { public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); Study study = studyRepository.getById(studyId); - boolean isAllAppliedToStudy = - studyHistoryRepository.existsByStudyIdAndStudentIds(studyId, request.studentIds()); + Long countByStudyIdAndStudentIds = + studyHistoryRepository.countByStudyIdAndStudentIds(studyId, request.studentIds()); studyValidator.validateStudyMentor(currentMember, study); - studyHistoryValidator.validateAppliedToStudy(isAllAppliedToStudy); + studyHistoryValidator.validateAppliedToStudy( + countByStudyIdAndStudentIds, request.studentIds().size()); List outstandingStudents = memberRepository.findAllById(request.studentIds()); List studyAchievements = outstandingStudents.stream() @@ -54,11 +55,12 @@ public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); Study study = studyRepository.getById(studyId); - boolean isAllAppliedToStudy = - studyHistoryRepository.existsByStudyIdAndStudentIds(studyId, request.studentIds()); + Long countByStudyIdAndStudentIds = + studyHistoryRepository.countByStudyIdAndStudentIds(studyId, request.studentIds()); studyValidator.validateStudyMentor(currentMember, study); - studyHistoryValidator.validateAppliedToStudy(isAllAppliedToStudy); + studyHistoryValidator.validateAppliedToStudy( + countByStudyIdAndStudentIds, request.studentIds().size()); studyAchievementRepository.deleteByStudyAndAchievementTypeAndMemberIds( studyId, request.achievementType(), request.studentIds()); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java index 0a5fbe7bf..4ec8b10bc 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java @@ -4,5 +4,5 @@ public interface StudyHistoryCustomRepository { - boolean existsByStudyIdAndStudentIds(Long studyId, List studentIds); + Long countByStudyIdAndStudentIds(Long studyId, List studentIds); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java index f41c28250..e827b330f 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java @@ -13,13 +13,12 @@ public class StudyHistoryCustomRepositoryImpl implements StudyHistoryCustomRepos private final JPAQueryFactory queryFactory; @Override - public boolean existsByStudyIdAndStudentIds(Long studyId, List studentIds) { - Long count = queryFactory + public Long countByStudyIdAndStudentIds(Long studyId, List studentIds) { + return queryFactory .select(studyHistory.count()) .from(studyHistory) .where(eqStudyId(studyId), studyHistory.student.id.in(studentIds)) .fetchOne(); - return count != null && count == studentIds.size(); } private BooleanExpression eqStudyId(Long studyId) { diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java index b92b59331..67a1c397b 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java @@ -52,8 +52,8 @@ public void validateUpdateRepository( } } - public void validateAppliedToStudy(boolean isAllAppliedToStudy) { - if (!isAllAppliedToStudy) { + public void validateAppliedToStudy(Long countStudyHistory, int studentCount) { + if (countStudyHistory != studentCount) { throw new CustomException(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS); } } diff --git a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java index 8e74ef8be..7ddc02778 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidatorTest.java @@ -130,8 +130,13 @@ class 스터디_수강신청_여부_확인시 { @Test void 해당_스터디를_신청하지_않은_멤버가_있다면_실패한다() { + // given + Long countStudyHistory = 1L; + int requestStudentCount = 2; + // when & then - assertThatThrownBy(() -> studyHistoryValidator.validateAppliedToStudy(false)) + assertThatThrownBy( + () -> studyHistoryValidator.validateAppliedToStudy(countStudyHistory, requestStudentCount)) .isInstanceOf(CustomException.class) .hasMessage(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS.getMessage()); } From c40b53fd71a74d5103e284a0179e356ef9390525 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Wed, 9 Oct 2024 21:08:21 +0900 Subject: [PATCH 7/9] =?UTF-8?q?refactor:=20getById=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=EB=A5=BC=20findById=EB=A1=9C=20=EB=8C=80=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../study/application/MentorStudyAchievementService.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java index bcb1970ab..efb0de43b 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -1,5 +1,7 @@ package com.gdschongik.gdsc.domain.study.application; +import static com.gdschongik.gdsc.global.exception.ErrorCode.*; + import com.gdschongik.gdsc.domain.member.dao.MemberRepository; import com.gdschongik.gdsc.domain.member.domain.Member; import com.gdschongik.gdsc.domain.study.dao.StudyAchievementRepository; @@ -10,6 +12,7 @@ import com.gdschongik.gdsc.domain.study.domain.StudyHistoryValidator; import com.gdschongik.gdsc.domain.study.domain.StudyValidator; import com.gdschongik.gdsc.domain.study.dto.request.OutstandingStudentRequest; +import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.util.MemberUtil; import java.util.List; import lombok.RequiredArgsConstructor; @@ -33,7 +36,7 @@ public class MentorStudyAchievementService { @Transactional public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); - Study study = studyRepository.getById(studyId); + Study study = studyRepository.findById(studyId).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND)); Long countByStudyIdAndStudentIds = studyHistoryRepository.countByStudyIdAndStudentIds(studyId, request.studentIds()); @@ -54,7 +57,7 @@ public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest @Transactional public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); - Study study = studyRepository.getById(studyId); + Study study = studyRepository.findById(studyId).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND)); Long countByStudyIdAndStudentIds = studyHistoryRepository.countByStudyIdAndStudentIds(studyId, request.studentIds()); From bcf85b2b256fb0652bb675341c70a1ab451b27a5 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Thu, 10 Oct 2024 23:04:26 +0900 Subject: [PATCH 8/9] =?UTF-8?q?refactor:=20NPE=20=EB=B0=A9=EC=A7=80=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gdsc/domain/study/domain/StudyHistoryValidator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java index 67a1c397b..391925c89 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java @@ -53,6 +53,10 @@ public void validateUpdateRepository( } public void validateAppliedToStudy(Long countStudyHistory, int studentCount) { + if (countStudyHistory == null) { + throw new CustomException(STUDY_HISTORY_NOT_FOUND); + } + if (countStudyHistory != studentCount) { throw new CustomException(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS); } From 30757eeedcfc1a69d7dafd4dfcb4b8a25ba172c8 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Fri, 11 Oct 2024 13:12:50 +0900 Subject: [PATCH 9/9] =?UTF-8?q?refactor:=20=ED=83=80=EC=9E=85=20=EC=BA=90?= =?UTF-8?q?=EC=8A=A4=ED=8C=85=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 --- .../study/application/MentorStudyAchievementService.java | 2 +- .../gdsc/domain/study/dao/StudyHistoryCustomRepository.java | 2 +- .../domain/study/dao/StudyHistoryCustomRepositoryImpl.java | 4 ++-- .../gdsc/domain/study/domain/StudyHistoryValidator.java | 6 +----- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java index efb0de43b..c639129a5 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/application/MentorStudyAchievementService.java @@ -58,7 +58,7 @@ public void designateOutstandingStudent(Long studyId, OutstandingStudentRequest public void withdrawOutstandingStudent(Long studyId, OutstandingStudentRequest request) { Member currentMember = memberUtil.getCurrentMember(); Study study = studyRepository.findById(studyId).orElseThrow(() -> new CustomException(STUDY_NOT_FOUND)); - Long countByStudyIdAndStudentIds = + long countByStudyIdAndStudentIds = studyHistoryRepository.countByStudyIdAndStudentIds(studyId, request.studentIds()); studyValidator.validateStudyMentor(currentMember, study); diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java index 4ec8b10bc..f64f7be6a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepository.java @@ -4,5 +4,5 @@ public interface StudyHistoryCustomRepository { - Long countByStudyIdAndStudentIds(Long studyId, List studentIds); + long countByStudyIdAndStudentIds(Long studyId, List studentIds); } diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java index e827b330f..32232e65c 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/dao/StudyHistoryCustomRepositoryImpl.java @@ -13,8 +13,8 @@ public class StudyHistoryCustomRepositoryImpl implements StudyHistoryCustomRepos private final JPAQueryFactory queryFactory; @Override - public Long countByStudyIdAndStudentIds(Long studyId, List studentIds) { - return queryFactory + public long countByStudyIdAndStudentIds(Long studyId, List studentIds) { + return (long) queryFactory .select(studyHistory.count()) .from(studyHistory) .where(eqStudyId(studyId), studyHistory.student.id.in(studentIds)) diff --git a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java index 391925c89..6a21b0f44 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java +++ b/src/main/java/com/gdschongik/gdsc/domain/study/domain/StudyHistoryValidator.java @@ -52,11 +52,7 @@ public void validateUpdateRepository( } } - public void validateAppliedToStudy(Long countStudyHistory, int studentCount) { - if (countStudyHistory == null) { - throw new CustomException(STUDY_HISTORY_NOT_FOUND); - } - + public void validateAppliedToStudy(long countStudyHistory, int studentCount) { if (countStudyHistory != studentCount) { throw new CustomException(STUDY_HISTORY_NOT_APPLIED_STUDENT_EXISTS); }