Skip to content

Commit

Permalink
[merge] 모임에 해당하는 신청자 전체 조회 api 및 에러 수정
Browse files Browse the repository at this point in the history
[fix] 모임에 해당하는 신청자 전체 조회 api 및 에러 수정
  • Loading branch information
bo-ram-bo-ram authored Oct 6, 2024
2 parents 9a59152 + 8926e2d commit d122781
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private int attendeeCounter(Long hostId) {
.map(Moim::getId) // Moim 엔티티에서 id를 추출
.collect(Collectors.toList());

return moimSubmissionRepository.countApprovedSubmissionsByMoimIds(moimIds);
return moimSubmissionRepository.countCompletedSubmissionsByMoimIds(moimIds);
}

private boolean checkVeteran(Long hostId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,19 @@ default MoimSubmission findMoimSubmissionByIdOrThrow(Long id) {

MoimSubmission findByMoimIdAndGuestId(Long moimId, Long guestId);

List<MoimSubmission> findBymoimId(Long moimId);
List<MoimSubmission> findMoimSubmissionByMoimId(Long moimId);

List<MoimSubmission> findMoimListByMoimId(Long moimId);

@Query("SELECT ms FROM MoimSubmission ms WHERE ms.moim.id = :moimId AND ms.moimSubmissionState IN ('pendingApproval', 'approved', 'rejected')")
@Query("SELECT ms FROM MoimSubmission ms WHERE ms.moim.id = :moimId AND ms.moimSubmissionState IN ('pendingApproval', 'approved', 'rejected','completed')")
List<MoimSubmission> findMoimListByMoimIdAndMoimSubmissionState(@Param("moimId") Long moimId);

@Query("SELECT ms FROM MoimSubmission ms WHERE ms.guestId = :guestId AND ms.moimSubmissionState = 'completed'")
List<MoimSubmission> findCompletedMoimSubmissionsByGuest(@Param("guestId") Long guestId);

@Query(value = "SELECT COUNT(*) FROM moim_submissions WHERE moim_id = :moimId AND moim_submission_state = 'approved'", nativeQuery = true)
@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id = :moimId AND ms.moimSubmissionState = 'approved'")
long countApprovedMoimSubmissions(@Param("moimId") Long moimId);

@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id IN :moimIds AND ms.moimSubmissionState = 'approved'")
int countApprovedSubmissionsByMoimIds(@Param("moimIds") List<Long> moimIds);
@Query("SELECT COUNT(ms) FROM MoimSubmission ms WHERE ms.moim.id IN :moimIds AND ms.moimSubmissionState = 'completed'")
int countCompletedSubmissionsByMoimIds(@Param("moimIds") List<Long> moimIds);

boolean existsByMoimIdAndGuestIdAndMoimSubmissionState(Long moimId, Long guestId, String MoimSubmissionState);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void isDuplicatedMoimSubmission(MoimSubmission moimSubmission) {
}

public void updateSubmissionState(Long moimId, List<Long> submitterIdList) {
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository.findBymoimId(moimId);
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository.findMoimSubmissionByMoimId(moimId);

for (MoimSubmission moimSubmission : moimSubmissionList) {
if (submitterIdList.contains(moimSubmission.getGuestId())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public MoimSubmissionByMoimResponse getSubmitterListByMoim(Long moimId) {
Moim moim = moimRepository.findMoimByIdOrThrow(moimId);

// moimSubmissionList 가져오기
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository.findMoimListByMoimIdAndMoimSubmissionState(
moimId);
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository
.findMoimListByMoimIdAndMoimSubmissionState(moimId);

// guestId를 이용하여 SubmitterInfo 객체 생성 후 리스트에 저장
List<SubmitterInfo> submitterInfoList = moimSubmissionList.stream()
Expand Down Expand Up @@ -178,8 +178,7 @@ public SubmitterInfo getSubmitterInfo(Long guestId, Long moimId) {
}

public boolean isMoimSubmissonApproved(Long moimId) {
Moim moim = moimRepository.findMoimByIdOrThrow(moimId);
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository.findMoimListByMoimId(moimId);
List<MoimSubmission> moimSubmissionList = moimSubmissionRepository.findMoimSubmissionByMoimId(moimId);

//모임에 해당하는 신청 내역 중 approved or rejected가 있는 경우 true 리턴
for (MoimSubmission moimSubmission : moimSubmissionList) {
Expand Down

0 comments on commit d122781

Please sign in to comment.