Skip to content

Commit

Permalink
Merge pull request #271 from Geek-sasaeng/debin
Browse files Browse the repository at this point in the history
Debin
  • Loading branch information
happysubin authored Jan 15, 2023
2 parents 087ef7e + 0c9e04f commit c8a708d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public enum BaseResponseStatus {
NOT_EXIST_CHAT_ROOM_CHIEF(false,2024,"배달 파티 채팅방 방장이 존재하지 않습니다."),
NOT_CHAT_ROOM_CHIEF(false,2025,"배달 파티 채팅방 방장이 아닙니다."),
CANT_REMOVE_REMIT_MEMBER(false,2026,"송금을 완료한 멤버는 방에서 퇴장시킬 수 없습니다."),
ALREADY_PARTY_FINISH(false, 2027 , "이미 마감한 파티입니다."),



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,24 @@ public class GetPartyChatRoomDetailRes {
@ApiModelProperty(example = "88", value = "채팅방 방장 id")
private int chiefId;

@ApiModelProperty(example = "34", value = "채팅방 id")
private int partyId;

@ApiModelProperty(example = "true", value = "배달 파티 매칭 완료 여부")
private Boolean isMatchingFinish;

@Builder
public GetPartyChatRoomDetailRes(Boolean isRemittanceFinish, Boolean isChief, Boolean isOrderFinish, String accountNumber, String bank, LocalDateTime enterTime, int chiefId) {
public GetPartyChatRoomDetailRes(Boolean isRemittanceFinish, Boolean isChief, Boolean isOrderFinish, String accountNumber, String bank, LocalDateTime enterTime,
int chiefId, int partyId, boolean isMatchingFinish) {
this.isRemittanceFinish = isRemittanceFinish;
this.isChief = isChief;
this.isOrderFinish = isOrderFinish;
this.accountNumber = accountNumber;
this.bank = bank;
this.enterTime = enterTime;
this.chiefId = chiefId;
this.partyId = partyId;
this.isMatchingFinish = isMatchingFinish;
}

public static GetPartyChatRoomDetailRes toDto(PartyChatRoom partyChatRoom, PartyChatRoomMember partyChatRoomMember,Boolean isChief,Boolean isOrderFinish){
Expand All @@ -56,6 +64,8 @@ public static GetPartyChatRoomDetailRes toDto(PartyChatRoom partyChatRoom, Party
.bank(partyChatRoom.getBank())
.enterTime(partyChatRoomMember.getEnterTime())
.chiefId(partyChatRoom.getChief().getMemberId())
.partyId(partyChatRoom.getDeliveryPartyId())
.isMatchingFinish(partyChatRoom.getIsFinish())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ public PartyChatRoomMemberRes joinPartyChatRoom(int memberId, String chatRoomId,
Member member = memberRepository.findMemberById(memberId)
.orElseThrow(() -> new BaseException(NOT_EXIST_USER));

String email = member.getEmail().getAddress();
String profileImgUrl = member.getProfileImgUrl();

PartyChatRoom partyChatRoom = partyChatRoomRepository.findByPartyChatRoomId(new ObjectId(chatRoomId))
.orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM));

//이미 마감했는지
if(partyChatRoom.getIsFinish()){
throw new BaseException(ALREADY_PARTY_FINISH);
}

//Validation 기존의 멤버인지 예외 처리
if (partyChatRoom.getParticipants().stream().anyMatch(participant -> participant.getMemberId() == memberId)) {
throw new BaseException(ALREADY_PARTICIPATE_CHATROOM);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package shop.geeksasang.service.deliveryparty;

import lombok.RequiredArgsConstructor;
import org.bson.types.ObjectId;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -312,10 +313,17 @@ public PatchLeaveChiefRes chiefLeaveDeliveryParty(String uuid, String nickName,
@Transactional(readOnly = false)
public PatchDeliveryPartyMatchingStatusRes patchDeliveryPartyMatchingStatus(Integer partyId, int userId) {

//여기서 방장 인증을 진행함.
DeliveryParty deliveryParty = deliveryPartyRepository.findDeliveryPartyByIdAndUserIdAndMatchingStatus(partyId, userId).
orElseThrow(() -> new BaseException(BaseResponseStatus.CAN_NOT_FINISH_DELIVERY_PARTY));

deliveryParty.changeMatchingStatusToFinish();

//그러므로 여기서 방장 인증을 진행할 필요가 없음.
PartyChatRoom partyChatRoom = partyChatRoomRepository.findByDeliveryPartyId(partyId)
.orElseThrow(() -> new BaseException(NOT_EXISTS_CHAT_ROOM));

partyChatRoomRepository.changeIsFinish(new ObjectId(partyChatRoom.getId()));

return PatchDeliveryPartyMatchingStatusRes.builder()
.deliveryPartyId(deliveryParty.getId())
.matchingStatus(deliveryParty.getMatchingStatus().toString())
Expand Down

0 comments on commit c8a708d

Please sign in to comment.