From 077b5023942d00fc0f355944dd5e0df822c13eb5 Mon Sep 17 00:00:00 2001 From: nonaninona Date: Sat, 17 Feb 2024 21:19:22 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20=EC=9D=BC=EA=B8=B0=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=20ChatID=20=EA=B8=B0=EC=A4=80=EA=B3=BC=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/kuit/chatdiary/repository/ChatRepository.java | 4 ++-- src/main/java/com/kuit/chatdiary/service/ChatService.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java b/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java index 1b534bee..e516bf13 100644 --- a/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java +++ b/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java @@ -10,7 +10,7 @@ public interface ChatRepository extends JpaRepository { List findTop10ByMember_UserIdOrderByChatIdDesc(Long userId); - @Query("SELECT c FROM chat c WHERE c.member.userId = :userId AND c.chatId > :lastChatId ORDER BY c.chatId DESC") - List findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdDesc(@Param("userId") Long userId, @Param("lastChatId") Long lastChatId); + @Query("SELECT c FROM chat c WHERE c.member.userId = :userId AND c.chatId < :lastChatId ORDER BY c.chatId ASC") + List findTop10ByUserIdAndChatIdLessThanOrderByChatIdDesc(@Param("userId") Long userId, @Param("lastChatId") Long lastChatId); List findTopByMember_UserIdOrderByChatIdDesc(Long userId); } diff --git a/src/main/java/com/kuit/chatdiary/service/ChatService.java b/src/main/java/com/kuit/chatdiary/service/ChatService.java index 5f558f51..d84e7ceb 100644 --- a/src/main/java/com/kuit/chatdiary/service/ChatService.java +++ b/src/main/java/com/kuit/chatdiary/service/ChatService.java @@ -71,7 +71,7 @@ public String extractGptResponse(String jsonResponse) throws JsonProcessingExcep } public List getChats(Long userId, Long lastChatId) { - List chats = chatRepository.findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdDesc(userId, lastChatId); + List chats = chatRepository.findTop10ByUserIdAndChatIdLessThanOrderByChatIdDesc(userId, lastChatId); if (chats.isEmpty()) { return null; }