diff --git a/be/src/main/java/com/example/be/core/application/AssignmentService.java b/be/src/main/java/com/example/be/core/application/AssignmentService.java index c8cf6eb..e1261a4 100644 --- a/be/src/main/java/com/example/be/core/application/AssignmentService.java +++ b/be/src/main/java/com/example/be/core/application/AssignmentService.java @@ -57,7 +57,7 @@ public AssignmentDetailResponse create(AssignmentRequest assignmentRequest, Long assignmentRequest.getPhoto()) ); - List studyMembers = studyMemberRepository.findStudyMembersByStudyId(assignmentRequest.getStudyId()); + List studyMembers = studyMemberRepository.findStudyMembersByStudy_Id(assignmentRequest.getStudyId()); studyMembers.forEach(studyMember -> assignmentMemberRepository.save( diff --git a/be/src/main/java/com/example/be/core/application/StudyService.java b/be/src/main/java/com/example/be/core/application/StudyService.java index 7510644..42ef259 100644 --- a/be/src/main/java/com/example/be/core/application/StudyService.java +++ b/be/src/main/java/com/example/be/core/application/StudyService.java @@ -27,7 +27,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.SortedMap; import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Sort; @@ -127,7 +126,7 @@ public StudiesResponse find(Long memberId, StudyConditionRequest studyConditionR List studies = studyRepository.findAll(); List studyResponses = studies.stream().map(study -> { - Integer memberCount = studyMemberRepository.countStudyMemberByStudyId(study.getId()); + Integer memberCount = studyMemberRepository.countStudyMemberByStudy_Id(study.getId()); return new StudyResponse( study.getId(), study.getTitle(), @@ -196,7 +195,7 @@ public StudyDetailResponse findById(Long memberId, Long studyId) { public StudyPreviewsResponse findPreview(Long memberId, StudyPreviewConditionRequest studyPreviewConditionRequest) { log.debug("[스터디 미리보기 조회] memberId = {}, StudyPreviewConditionRequest = {}", memberId, studyPreviewConditionRequest); - List studyMembers = studyMemberRepository.findStudyMembersByMemberId(memberId); + List studyMembers = studyMemberRepository.findStudyMembersByMember_Id(memberId); List memberProfiles = new ArrayList<>(); if (studyPreviewConditionRequest.getType().equals(StudyPreviewType.MY)) { @@ -225,7 +224,7 @@ public StudyPreviewsResponse findPreview(Long memberId, StudyPreviewConditionReq List studies = studyRepository.findAll(Sort.by(Direction.DESC, "createdAt")); List randomStudyPreviewResponse = studies.stream().map(study -> { - List members = studyMemberRepository.findStudyMembersByStudyId(study.getId()); + List members = studyMemberRepository.findStudyMembersByStudy_Id(study.getId()); memberProfiles.clear(); for (StudyMember member : members) { @@ -312,7 +311,7 @@ public StudyDetailResponse modify(Long memberId, Long studyId, StudyRequest stud public void delete(Long memberId, Long studyId) { log.debug("[스터디 삭제] studyId = {}", studyId); - StudyMember studyLeader = studyMemberRepository.findStudyMemberByStudyIdAndLeaderIsTrue(studyId); + StudyMember studyLeader = studyMemberRepository.findStudyMemberByStudy_IdAndLeaderIsTrue(studyId); if (!Objects.equals(studyLeader.getMember().getId(), memberId)) { throw new NotMatchStudyAndMemberException(); @@ -351,7 +350,7 @@ private Integer getStudyInterestCount(Study study) { } private boolean isStudyInterested(Long loginMemberId, Study study) { - return studyInterestRepository.findByMemberIdAndStudy(loginMemberId, study).isPresent(); + return studyInterestRepository.findByMember_IdAndStudy(loginMemberId, study).isPresent(); } private static boolean leaderCheck(Long loginMemberId, boolean isLeader, StudyMember member) { @@ -367,7 +366,7 @@ private Study getStudy(Long studyId) { } private List getStudyMembers(Long studyId) { - return studyMemberRepository.findStudyMembersByStudyId( + return studyMemberRepository.findStudyMembersByStudy_Id( studyId); } } diff --git a/be/src/main/java/com/example/be/core/repository/study/StudyInterestRepository.java b/be/src/main/java/com/example/be/core/repository/study/StudyInterestRepository.java index e0e71fc..a75c89b 100644 --- a/be/src/main/java/com/example/be/core/repository/study/StudyInterestRepository.java +++ b/be/src/main/java/com/example/be/core/repository/study/StudyInterestRepository.java @@ -9,7 +9,7 @@ public interface StudyInterestRepository extends JpaRepository findByMemberIdAndStudy(Long memberId, Study study); + Optional findByMember_IdAndStudy(Long memberId, Study study); void deleteByMemberIdAndStudyId(Long memberId, Long studyId); } diff --git a/be/src/main/java/com/example/be/core/repository/study/StudyMemberRepository.java b/be/src/main/java/com/example/be/core/repository/study/StudyMemberRepository.java index 24188e5..439d984 100644 --- a/be/src/main/java/com/example/be/core/repository/study/StudyMemberRepository.java +++ b/be/src/main/java/com/example/be/core/repository/study/StudyMemberRepository.java @@ -3,14 +3,13 @@ import com.example.be.core.domain.study.StudyMember; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; public interface StudyMemberRepository extends JpaRepository { - List findStudyMembersByStudyId(Long studyId); + List findStudyMembersByStudy_Id(Long studyId); - List findStudyMembersByMemberId(Long memberId); + List findStudyMembersByMember_Id(Long memberId); - StudyMember findStudyMemberByStudyIdAndLeaderIsTrue(Long studyId); + StudyMember findStudyMemberByStudy_IdAndLeaderIsTrue(Long studyId); - Integer countStudyMemberByStudyId(Long studyId); + Integer countStudyMemberByStudy_Id(Long studyId); } diff --git a/be/src/test/java/com/example/be/tool/DataBaseConfigurator.java b/be/src/test/java/com/example/be/tool/DataBaseConfigurator.java index 070a2f8..23eb612 100644 --- a/be/src/test/java/com/example/be/tool/DataBaseConfigurator.java +++ b/be/src/test/java/com/example/be/tool/DataBaseConfigurator.java @@ -214,7 +214,7 @@ private void initStudy() { */ private void initAssignment() { Study study = studyRepository.findById(1L).get(); - List studyMembers = studyMemberRepository.findStudyMembersByStudyId( + List studyMembers = studyMemberRepository.findStudyMembersByStudy_Id( study.getId()); for (int i = 1; i <= NUMBER_OF_ASSIGNMENT; i++) { Assignment assignment = assignmentRepository.save(