Skip to content

Commit 16104d0

Browse files
authored
Deploy: Merge to main (#81)
* hotfix : jpa 네이밍 및 쿼리 수정
1 parent 8019556 commit 16104d0

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/main/java/ita/tinybite/domain/party/repository/PartyParticipantRepository.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public interface PartyParticipantRepository extends JpaRepository<PartyParticipa
2727
boolean existsByPartyAndUserAndStatus(Party party, User user, ParticipantStatus status);
2828

2929
@Query("SELECT pp FROM PartyParticipant pp " +
30-
"WHERE pp.user.id = :userId " +
30+
"WHERE pp.user.userId = :userId " +
3131
"AND pp.party.status =:partyStatus " +
3232
"AND pp.status = :participantStatus")
3333
List<PartyParticipant> findActivePartiesByUserId(
@@ -82,5 +82,5 @@ List<PartyParticipant> findActivePartiesByUserIdExcludingHost(
8282
@Param("participantStatus") ParticipantStatus participantStatus
8383
);
8484

85-
int countByPartyIdAndStatusAndUserIdNot(Long partyId, ParticipantStatus participantStatus, Long userId);
85+
int countByPartyIdAndStatusAndUser_UserIdNot(Long partyId, ParticipantStatus participantStatus, Long userId);
8686
}

src/main/java/ita/tinybite/domain/party/service/PartyService.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public void updateParty(Long partyId, Long userId, PartyUpdateRequest request) {
345345

346346
// 호스트 제외한 승인된 파티원 수 확인
347347
int approvedParticipantsExcludingHost = participantRepository
348-
.countByPartyIdAndStatusAndUserIdNot(
348+
.countByPartyIdAndStatusAndUser_UserIdNot(
349349
partyId,
350350
ParticipantStatus.APPROVED,
351351
userId
@@ -404,10 +404,15 @@ public void deleteParty(Long partyId, Long userId) {
404404
throw new IllegalStateException("파티장만 삭제할 수 있습니다");
405405
}
406406

407-
// 승인된 파티원 확인
408-
boolean hasApprovedParticipants = party.getCurrentParticipants() > 1;
407+
// 호스트 제외한 승인된 파티원 수 확인
408+
int approvedParticipantsExcludingHost = participantRepository
409+
.countByPartyIdAndStatusAndUser_UserIdNot(
410+
partyId,
411+
ParticipantStatus.APPROVED,
412+
userId
413+
);
409414

410-
if (hasApprovedParticipants) {
415+
if (approvedParticipantsExcludingHost > 0) {
411416
throw new IllegalStateException("승인된 파티원이 있어 삭제할 수 없습니다");
412417
}
413418

0 commit comments

Comments
 (0)