From b72282728d24fa215a155923b957303296bb4870 Mon Sep 17 00:00:00 2001 From: HyemIin Date: Thu, 1 Feb 2024 23:57:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Refactor=20:=20ChatRoom=20=EB=A6=AC?= =?UTF-8?q?=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 미사용 import 정리 - DTO accessLEVEL 수정 - 미사용 entity 삭제 --- .../chatroom/dto/ChatRoomListGetResponse.java | 8 +++--- .../chat/chatroom/entity/ChatRoom.java | 25 ------------------- .../repository/ChatRoomRedisRepository.java | 20 ++++----------- .../chat/message/service/ChatService.java | 8 +----- .../ChatRoomRedisRepositoryTest.java | 3 --- 5 files changed, 9 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/com/catchroom/chat/chatroom/entity/ChatRoom.java diff --git a/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java b/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java index 582c9c4..d24bddb 100644 --- a/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java +++ b/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java @@ -5,15 +5,13 @@ import com.catchroom.chat.message.dto.ChatMessageDto; import com.catchroom.chat.message.type.UserIdentity; import java.io.Serializable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; + +import lombok.*; @Builder @Getter +@NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor -@NoArgsConstructor public class ChatRoomListGetResponse implements Serializable { private String chatRoomNumber; diff --git a/src/main/java/com/catchroom/chat/chatroom/entity/ChatRoom.java b/src/main/java/com/catchroom/chat/chatroom/entity/ChatRoom.java deleted file mode 100644 index ed81bd4..0000000 --- a/src/main/java/com/catchroom/chat/chatroom/entity/ChatRoom.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.catchroom.chat.chatroom.entity; - -import com.catchroom.chat.message.type.UserIdentity; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.io.Serializable; - -@Getter -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class ChatRoom implements Serializable { - - - private Long id; - private Long sellerId; - private Long buyerId; - private Long productId; - private String chatRoomNumber; - private UserIdentity loginUserIdentity; - -} diff --git a/src/main/java/com/catchroom/chat/message/repository/ChatRoomRedisRepository.java b/src/main/java/com/catchroom/chat/message/repository/ChatRoomRedisRepository.java index 6631403..5acc33a 100644 --- a/src/main/java/com/catchroom/chat/message/repository/ChatRoomRedisRepository.java +++ b/src/main/java/com/catchroom/chat/message/repository/ChatRoomRedisRepository.java @@ -5,37 +5,27 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.annotation.Resource; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.concurrent.TimeUnit; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.ListOperations; import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.ValueOperations; -import org.springframework.stereotype.Service; -import org.springframework.util.StringUtils; +import org.springframework.stereotype.Repository; + +import java.util.List; +import java.util.Optional; /** redis 와 관련된 메소드들 */ -@Service +@Repository @RequiredArgsConstructor @Slf4j public class ChatRoomRedisRepository { private static final String CHAT_ROOM_KEY = "_CHAT_ROOM_RESPONSE_LIST"; - private static final String CHAT_ROOM = "CHAT_ROOM_LAST_MSG"; //채팅방 마지막 메시지 저장 - - - private final RedisTemplate redisTemplate; - private final ObjectMapper objectMapper; @Resource(name = "redisTemplate") diff --git a/src/main/java/com/catchroom/chat/message/service/ChatService.java b/src/main/java/com/catchroom/chat/message/service/ChatService.java index f526a3c..59b13a8 100644 --- a/src/main/java/com/catchroom/chat/message/service/ChatService.java +++ b/src/main/java/com/catchroom/chat/message/service/ChatService.java @@ -2,19 +2,13 @@ import com.catchroom.chat.chatroom.dto.ChatRoomListGetResponse; import com.catchroom.chat.chatroom.service.ChatRoomService; -import com.catchroom.chat.feign.client.MainFeignClient; -import com.catchroom.chat.global.common.SuccessMessage; import com.catchroom.chat.message.dto.ChatMessageDto; import com.catchroom.chat.global.pubsub.RedisPublisher; import com.catchroom.chat.message.dto.MessageSubDto; -import com.catchroom.chat.message.entity.ChatMessage; -import com.catchroom.chat.message.repository.ChatMessageRepository; import com.catchroom.chat.message.repository.ChatRoomRedisRepository; import com.catchroom.chat.message.type.MessageType; import com.catchroom.chat.message.type.UserIdentity; -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.Comparator; + import java.util.List; import lombok.RequiredArgsConstructor; diff --git a/src/test/java/com/catchroom/chat/message/repository/ChatRoomRedisRepositoryTest.java b/src/test/java/com/catchroom/chat/message/repository/ChatRoomRedisRepositoryTest.java index ba9df8a..1303527 100644 --- a/src/test/java/com/catchroom/chat/message/repository/ChatRoomRedisRepositoryTest.java +++ b/src/test/java/com/catchroom/chat/message/repository/ChatRoomRedisRepositoryTest.java @@ -1,9 +1,6 @@ package com.catchroom.chat.message.repository; -import static org.junit.jupiter.api.Assertions.*; - import com.catchroom.chat.chatroom.dto.ChatRoomListGetResponse; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; import org.junit.jupiter.api.Test; From 50f75f6d0e8e034adc17684e74c8e0418c270f0b Mon Sep 17 00:00:00 2001 From: sungjiwoon Date: Fri, 2 Feb 2024 00:35:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?deploy=20:=20=EC=84=9C=EB=B2=84=202?= =?UTF-8?q?=EA=B0=9C=20=EB=9D=84=EC=9A=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d4725db..4c467f3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,6 +49,10 @@ jobs: username: ${{ secrets.USER_NAME }} key: ${{ secrets.PRIVATE_KEY }} script: | + sudo docker image prune -af sudo docker pull ${{ secrets.DOCKER_IMAGE_NAME }} - sudo docker stop chat-server - sudo docker run -d --rm --name chat-server -p 8080:8080 ${{ secrets.DOCKER_IMAGE_NAME }} + sudo docker stop chat-server1 + sudo docker run -d --rm --name chat-server-1 -p 8080:8080 ${{ secrets.DOCKER_IMAGE_NAME }} + sleep 30 + sudo docker stop chat-server2 + sudo docker run -d --rm --name chat-server-2 -p 8081:8081 ${{ secrets.DOCKER_IMAGE_NAME }}