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 @@ -63,6 +63,7 @@ public static Message toMessageEntity(ChatRequestDTO.ChatMessageRequestDTO reque

public static ChatResponseDTO.SendMessageResponseDTO toSendMessageDTO(Message message) {
return ChatResponseDTO.SendMessageResponseDTO.builder()
.messageId(message.getId())
.roomId(message.getChattingRoom().getId())
.senderId(message.getSender().getId())
.receiverId(message.getReceiver().getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ SELECT MAX(m2.createdAt)
AND m.receiver.id = :memberId
AND m.isRead = false),
CASE
WHEN pm.id IS NULL AND am.id = :memberId THEN NULL
WHEN am.id IS NULL AND pm.id = :memberId THEN NULL
WHEN pm.id IS NULL AND am.id = :memberId THEN -1
WHEN am.id IS NULL AND pm.id = :memberId THEN -1
WHEN pm.id = :memberId THEN a.id
ELSE p.id
END,
CASE
WHEN pm.id IS NULL AND am.id = :memberId THEN NULL
WHEN am.id IS NULL AND pm.id = :memberId THEN NULL
WHEN pm.id IS NULL AND am.id = :memberId THEN -1
WHEN am.id IS NULL AND pm.id = :memberId THEN -1
WHEN pm.id = :memberId THEN a.name
ELSE p.name
END,
CASE
WHEN pm.id IS NULL AND am.id = :memberId THEN NULL
WHEN am.id IS NULL AND pm.id = :memberId THEN NULL
WHEN pm.id IS NULL AND am.id = :memberId THEN -1
WHEN am.id IS NULL AND pm.id = :memberId THEN -1
WHEN pm.id = :memberId THEN am.profileUrl
ELSE pm.profileUrl
END
Expand All @@ -55,6 +55,10 @@ SELECT MAX(m2.createdAt)
LEFT JOIN a.member am
WHERE pm.id = :memberId
OR am.id = :memberId
ORDER BY
(SELECT MAX(m.createdAt)
FROM Message m
WHERE m.chattingRoom.id = r.id) DESC
""")
List<ChatRoomListResultDTO> findChattingRoomsByMemberId(@Param("memberId") Long memberId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,21 @@ public ChatResponseDTO.LeaveChattingRoomResponseDTO leaveChattingRoom(Long roomI
isLeftSuccessfully = true;
chatRepository.save(chattingRoom);
} else if(memberCount == 1) {
isRoomDeleted = true;
if (isAdmin) {
chattingRoom.setAdmin(null);
} else if (isPartner) {
chattingRoom.setPartner(null);
}
chattingRoom.updateMemberCount(0);
isLeftSuccessfully = true;
chatRepository.delete(chattingRoom);

// ✅ 방에 아무도 안 남았을 때만 삭제
if (chattingRoom.getAdmin() == null && chattingRoom.getPartner() == null) {
isRoomDeleted = true;
chatRepository.delete(chattingRoom);
} else {
chatRepository.save(chattingRoom);
}

} else if(memberCount == 0) {
throw new DatabaseException(ErrorStatus.NO_MEMBER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ public static PartnershipResponseDTO.WritePartnershipResponseDTO writePartnershi
.adminId(paper.getAdmin() != null ? paper.getAdmin().getId() : null)
.partnerId(paper.getPartner()!= null ? paper.getPartner().getId() : null) // 수동등록이면 null
.storeId(paper.getStore() != null ? paper.getStore().getId() : null)
.storeName(paper.getStore().getName())
.adminName(paper.getAdmin().getName())
.isActivated(paper.getIsActivated())
.options(optionDTOS)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public static class WritePartnershipResponseDTO {
private Long adminId;
private Long partnerId;
private Long storeId;
private String storeName;
private String adminName;
private Boolean activated;
private ActivationStatus isActivated;
private List<PartnershipOptionResponseDTO> options;
}
Expand Down