Skip to content

Commit

Permalink
refactor: 타입 캐스팅으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook02 committed Oct 11, 2024
1 parent bcf85b2 commit 30757ee
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

public interface StudyHistoryCustomRepository {

Long countByStudyIdAndStudentIds(Long studyId, List<Long> studentIds);
long countByStudyIdAndStudentIds(Long studyId, List<Long> studentIds);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public class StudyHistoryCustomRepositoryImpl implements StudyHistoryCustomRepos
private final JPAQueryFactory queryFactory;

@Override
public Long countByStudyIdAndStudentIds(Long studyId, List<Long> studentIds) {
return queryFactory
public long countByStudyIdAndStudentIds(Long studyId, List<Long> studentIds) {
return (long) queryFactory
.select(studyHistory.count())
.from(studyHistory)
.where(eqStudyId(studyId), studyHistory.student.id.in(studentIds))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 30757ee

Please sign in to comment.