From 776a37c5abaddb8e5da2c657a5c4639504d7b6b8 Mon Sep 17 00:00:00 2001 From: hej090224 Date: Sat, 27 Dec 2025 21:56:03 +0900 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=EC=96=B4=EB=93=9C=EB=AF=BC=20?= =?UTF-8?q?=EC=8B=A0=EA=B3=A0=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/admin/dto/response/AdminReportResponse.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/team/cklob/gami/domain/admin/dto/response/AdminReportResponse.java b/src/main/java/com/team/cklob/gami/domain/admin/dto/response/AdminReportResponse.java index 9a38e81e..ca7f0f20 100644 --- a/src/main/java/com/team/cklob/gami/domain/admin/dto/response/AdminReportResponse.java +++ b/src/main/java/com/team/cklob/gami/domain/admin/dto/response/AdminReportResponse.java @@ -1,6 +1,7 @@ package com.team.cklob.gami.domain.admin.dto.response; import com.team.cklob.gami.domain.report.entity.Report; +import com.team.cklob.gami.domain.report.entity.constant.ReportResult; import com.team.cklob.gami.domain.report.entity.constant.ReportType; import lombok.Builder; import lombok.Getter; @@ -11,11 +12,17 @@ public class AdminReportResponse { private final Long id; private final ReportType reportType; + private final ReportResult reportResult; + private final String reporterName; + private final Long reportedPostId; public static AdminReportResponse from(Report report) { return AdminReportResponse.builder() .id(report.getId()) .reportType(report.getReportType()) + .reportResult(report.getResult()) + .reporterName(report.getReporter().getName()) + .reportedPostId(report.getPost().getId()) .build(); } } From 6a131c02a9bc30f305a5f293f8268e030a3f4f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=ED=95=98=EB=AF=BC?= Date: Sat, 27 Dec 2025 21:58:59 +0900 Subject: [PATCH 2/5] =?UTF-8?q?add=20::=20findAllByMentorIdOrMenteeId=20?= =?UTF-8?q?=EC=B5=9C=EC=8B=A0=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=9C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EC=A0=95=EB=A0=AC=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/repository/ChatRoomRepository.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java b/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java index a73e23cf..d2bb0eb3 100644 --- a/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java +++ b/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java @@ -29,5 +29,13 @@ boolean existsByRoomIdAndMemberId( Optional findOtherMemberInRoom(@Param("roomId") Long roomId, @Param("memberId") Long memberId); - List findAllByMentorIdOrMenteeId(Long mentorId, Long menteeId); + @Query(""" + select cr from ChatRoom cr + where cr.mentor.id = :memberId or cr.mentee.id = :memberId + order by cr.lastMessageAt desc nulls last + """) + List findAllByMentorIdOrMenteeId( + @Param("memberId") Long mentorId, + @Param("memberId") Long menteeId + ); } From aa14783d4c44f9c388eee9b80ded820d9d2e206b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=ED=95=98=EB=AF=BC?= Date: Sat, 27 Dec 2025 21:59:18 +0900 Subject: [PATCH 3/5] =?UTF-8?q?add=20::=20lastMessageAt=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/team/cklob/gami/domain/chat/entity/ChatRoom.java | 6 +++++- .../domain/chat/service/impl/ChatMessageServiceImpl.java | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/team/cklob/gami/domain/chat/entity/ChatRoom.java b/src/main/java/com/team/cklob/gami/domain/chat/entity/ChatRoom.java index 9e2b3720..f8824481 100644 --- a/src/main/java/com/team/cklob/gami/domain/chat/entity/ChatRoom.java +++ b/src/main/java/com/team/cklob/gami/domain/chat/entity/ChatRoom.java @@ -47,6 +47,9 @@ public class ChatRoom { @Column(name = "last_message", nullable = false) private String lastMessage; + @Column(name = "last_message_at") + private LocalDateTime lastMessageAt; + @CreatedDate @Column(name = "created_at", updatable = false, nullable = false) private LocalDateTime createdAt; @@ -103,7 +106,8 @@ public boolean isMember(Member member) { || member.getId().equals(mentee.getId()); } - public void updateLastMessage(String message) { + public void updateLastMessage(String message, LocalDateTime lastMessageAt) { this.lastMessage = message; + this.lastMessageAt = lastMessageAt; } } diff --git a/src/main/java/com/team/cklob/gami/domain/chat/service/impl/ChatMessageServiceImpl.java b/src/main/java/com/team/cklob/gami/domain/chat/service/impl/ChatMessageServiceImpl.java index 7f668765..847d4cdc 100644 --- a/src/main/java/com/team/cklob/gami/domain/chat/service/impl/ChatMessageServiceImpl.java +++ b/src/main/java/com/team/cklob/gami/domain/chat/service/impl/ChatMessageServiceImpl.java @@ -68,7 +68,7 @@ public void execute(Long roomId, ChatMessageRequest request, Principal principal .build(); chatMessageRepository.save(message); - chatRoom.updateLastMessage(request.message()); + chatRoom.updateLastMessage(request.message(), message.getCreatedAt()); ChatMessageResponse response = new ChatMessageResponse( message.getId(), From 1f0d60a5b21c2cbbc03d7d74c19e9bcd494c68a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=ED=95=98=EB=AF=BC?= Date: Sat, 27 Dec 2025 23:18:08 +0900 Subject: [PATCH 4/5] =?UTF-8?q?refactor=20::=20=EC=B1=84=ED=8C=85=EB=B0=A9?= =?UTF-8?q?=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=EC=BF=BC=EB=A6=AC?= =?UTF-8?q?=20=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=20=EC=A4=91=EB=B3=B5=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0=20=EB=B0=8F=20=EC=A0=95=EB=A0=AC=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cklob/gami/domain/chat/repository/ChatRoomRepository.java | 3 +-- .../domain/chat/service/impl/GetChatRoomListServiceImpl.java | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java b/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java index d2bb0eb3..c84f745f 100644 --- a/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java +++ b/src/main/java/com/team/cklob/gami/domain/chat/repository/ChatRoomRepository.java @@ -35,7 +35,6 @@ Optional findOtherMemberInRoom(@Param("roomId") Long roomId, order by cr.lastMessageAt desc nulls last """) List findAllByMentorIdOrMenteeId( - @Param("memberId") Long mentorId, - @Param("memberId") Long menteeId + @Param("memberId") Long memberId ); } diff --git a/src/main/java/com/team/cklob/gami/domain/chat/service/impl/GetChatRoomListServiceImpl.java b/src/main/java/com/team/cklob/gami/domain/chat/service/impl/GetChatRoomListServiceImpl.java index 94834d04..0ee5a4a9 100644 --- a/src/main/java/com/team/cklob/gami/domain/chat/service/impl/GetChatRoomListServiceImpl.java +++ b/src/main/java/com/team/cklob/gami/domain/chat/service/impl/GetChatRoomListServiceImpl.java @@ -31,7 +31,7 @@ public List execute() { Member member = memberUtil.getCurrentMember(); List chatRoomList = chatRoomRepository - .findAllByMentorIdOrMenteeId(member.getId(), member.getId()); + .findAllByMentorIdOrMenteeId(member.getId()); List otherMemberIds = chatRoomList.stream() .map(chatRoom -> { From 0418ef36a23e6110a9ffab016d7746cd50004211 Mon Sep 17 00:00:00 2001 From: hej090224 Date: Sat, 27 Dec 2025 23:22:41 +0900 Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=EC=8B=A0=EA=B3=A0=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20N+1=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0=EC=9D=84=20=EC=9C=84=ED=95=B4=20fetch=20join?= =?UTF-8?q?=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/AdminReportListServiceImpl.java | 2 +- .../domain/report/repository/ReportRepository.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/team/cklob/gami/domain/admin/service/impl/AdminReportListServiceImpl.java b/src/main/java/com/team/cklob/gami/domain/admin/service/impl/AdminReportListServiceImpl.java index a70e47d4..236b7be9 100644 --- a/src/main/java/com/team/cklob/gami/domain/admin/service/impl/AdminReportListServiceImpl.java +++ b/src/main/java/com/team/cklob/gami/domain/admin/service/impl/AdminReportListServiceImpl.java @@ -18,7 +18,7 @@ public class AdminReportListServiceImpl implements AdminReportListService { @Override public List getReports() { - return reportRepository.findAll() + return reportRepository.findAllWithReporterAndPost() .stream() .map(AdminReportResponse::from) .toList(); diff --git a/src/main/java/com/team/cklob/gami/domain/report/repository/ReportRepository.java b/src/main/java/com/team/cklob/gami/domain/report/repository/ReportRepository.java index 040b584f..d1313f85 100644 --- a/src/main/java/com/team/cklob/gami/domain/report/repository/ReportRepository.java +++ b/src/main/java/com/team/cklob/gami/domain/report/repository/ReportRepository.java @@ -3,6 +3,9 @@ import com.team.cklob.gami.domain.report.entity.Report; import com.team.cklob.gami.domain.report.entity.constant.ReportType; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; public interface ReportRepository extends JpaRepository { @@ -11,4 +14,12 @@ boolean existsByReporterIdAndPostIdAndReportType( Long postId, ReportType reportType ); + + @Query(""" + SELECT r + FROM Report r + JOIN FETCH r.reporter + JOIN FETCH r.post + """) + List findAllWithReporterAndPost(); }