Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,7 @@ List<PartyParticipant> findActivePartiesByUserIdExcludingHost(
@Param("userId") Long userId,
@Param("partyStatus") PartyStatus partyStatus,
@Param("participantStatus") ParticipantStatus participantStatus
);}
);

int countByPartyIdAndStatusAndUserIdNot(Long partyId, ParticipantStatus participantStatus, Long userId);
}
20 changes: 11 additions & 9 deletions src/main/java/ita/tinybite/domain/party/service/PartyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ private PartyDetailResponse convertToDetailResponse(Party party, double distance
.build();
}

@Transactional
public void updateParty(Long partyId, Long userId, PartyUpdateRequest request) {
Party party = partyRepository.findById(partyId)
.orElseThrow(() -> new IllegalArgumentException("파티를 찾을 수 없습니다"));
Expand All @@ -344,30 +343,33 @@ public void updateParty(Long partyId, Long userId, PartyUpdateRequest request) {
throw new IllegalStateException("파티장만 수정할 수 있습니다");
}

// 승인된 파티원 확인
boolean hasApprovedParticipants = party.getCurrentParticipants() > 1;
// 호스트 제외한 승인된 파티원 수 확인
int approvedParticipantsExcludingHost = participantRepository
.countByPartyIdAndStatusAndUserIdNot(
partyId,
ParticipantStatus.APPROVED,
userId
);

if (hasApprovedParticipants) {
// 승인된 파티원이 있는 경우: 설명과 이미지만 수정 가능
if (approvedParticipantsExcludingHost > 0) {
// 다른 승인된 파티원이 있는 경우: 설명과 이미지만 수정 가능
party.updateLimitedFields(
request.getDescription(),
request.getImages()
);
} else {
// 승인된 파티원이 없는 경우: 모든 항목 수정 가능
// 승인된 파티원이 없는 경우, 호스트 혼자인 경우: 모든 항목 수정 가능
party.updateAllFields(
request.getTitle(),
request.getTotalPrice(),
request.getMaxParticipants(),
getPickUpLocationIfExists(request,party),
// new PickupLocation(request.getPickupLocation()),
getPickUpLocationIfExists(request, party),
request.getProductLink(),
request.getDescription(),
request.getImages()
);
}
}

private PickupLocation getPickUpLocationIfExists(PartyUpdateRequest request, Party currentParty) {
if (request.getPickupLocation() == null) {
return currentParty.getPickupLocation();
Expand Down