diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 5b4629a9..eafcdc6f 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -2,7 +2,7 @@ name: Java CI/CD with Gradle on: push: - branches: [ "develop" ] + branches: [ "develop", "CHAT-314-채팅-조회-역순-수정" ] pull_request: branches: [ ] diff --git a/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java b/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java index 1b534bee..3d80f1e0 100644 --- a/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java +++ b/src/main/java/com/kuit/chatdiary/repository/ChatRepository.java @@ -10,7 +10,6 @@ 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); + List findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdAsc(Long userId, Long ChatId); 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..613d9880 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.findTop10ByUserIdAndChatIdGreaterThanOrderByChatIdAsc(userId, lastChatId); if (chats.isEmpty()) { return null; }