From cdf64eca3e6b9b5cc5edd272cca15b380d39414e Mon Sep 17 00:00:00 2001 From: geneaky Date: Tue, 8 Oct 2024 22:36:20 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatroom/repository/ChatRoomHashTagRepository.java | 7 ++++++- .../domain/chatroom/api/v1/request/ChatRoomRequest.java | 2 +- .../domain/chatroom/service/ChatRoomHashTagCleaner.java | 2 +- .../bookchat/domain/chatroom/service/ChatRoomService.java | 6 ++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/toy/bookchat/bookchat/db_module/chatroom/repository/ChatRoomHashTagRepository.java b/src/main/java/toy/bookchat/bookchat/db_module/chatroom/repository/ChatRoomHashTagRepository.java index b60722ce..46011af4 100644 --- a/src/main/java/toy/bookchat/bookchat/db_module/chatroom/repository/ChatRoomHashTagRepository.java +++ b/src/main/java/toy/bookchat/bookchat/db_module/chatroom/repository/ChatRoomHashTagRepository.java @@ -1,9 +1,14 @@ package toy.bookchat.bookchat.db_module.chatroom.repository; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; import toy.bookchat.bookchat.db_module.chatroom.ChatRoomHashTagEntity; public interface ChatRoomHashTagRepository extends JpaRepository { - void deleteAllByChatRoomId(Long chatRoomId); + @Modifying + @Query("delete from ChatRoomHashTagEntity c where c.chatRoomId = :chatRoomId") + void deleteByChatRoomId(@Param("chatRoomId") Long chatRoomId); } diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/api/v1/request/ChatRoomRequest.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/api/v1/request/ChatRoomRequest.java index f3293b0c..b43f2ed0 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/api/v1/request/ChatRoomRequest.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/api/v1/request/ChatRoomRequest.java @@ -48,7 +48,7 @@ public void validate() { return; } - if (!tags.isEmpty()) { + if (tags != null && !tags.isEmpty()) { this.roomName = null; this.title = null; this.isbn = null; diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomHashTagCleaner.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomHashTagCleaner.java index 168d289b..630e5760 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomHashTagCleaner.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomHashTagCleaner.java @@ -13,6 +13,6 @@ public ChatRoomHashTagCleaner(ChatRoomHashTagRepository chatRoomHashTagRepositor } public void cleanAll(Long chatRoomId) { - chatRoomHashTagRepository.deleteAllByChatRoomId(chatRoomId); + chatRoomHashTagRepository.deleteByChatRoomId(chatRoomId); } } diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomService.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomService.java index 92d02be4..b4d14242 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomService.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomService.java @@ -5,7 +5,6 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.List; import java.util.UUID; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.Pageable; @@ -32,11 +31,11 @@ import toy.bookchat.bookchat.domain.participant.service.ParticipantCleaner; import toy.bookchat.bookchat.domain.participant.service.ParticipantReader; import toy.bookchat.bookchat.domain.participant.service.ParticipantValidator; -import toy.bookchat.bookchat.infrastructure.s3.StorageService; import toy.bookchat.bookchat.domain.user.User; import toy.bookchat.bookchat.domain.user.service.UserReader; import toy.bookchat.bookchat.infrastructure.rabbitmq.MessagePublisher; import toy.bookchat.bookchat.infrastructure.rabbitmq.message.NotificationMessage; +import toy.bookchat.bookchat.infrastructure.s3.StorageService; @Service public class ChatRoomService { @@ -151,8 +150,7 @@ public void reviseChatRoom(ReviseChatRoomRequest request, MultipartFile chatRoom if (request.tagExistent()) { chatRoomHashTagCleaner.cleanAll(chatRoom.getId()); - List hashTags = request.createHashTags(); - for (HashTag hashTag : hashTags) { + for (HashTag hashTag : request.createHashTags()) { HashTag storedHashTag = hashTagAppender.append(hashTag); chatRoomHashTagAppender.append(chatRoom.getId(), storedHashTag); }