From cf31fd64b20087fee8d5b724d489b49c02b6dcff Mon Sep 17 00:00:00 2001 From: Lee Da-hyeon Date: Fri, 15 Nov 2024 01:03:47 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20ChatService.java=20=ED=8C=8C=EC=9D=BC?= =?UTF-8?q?=20=EC=9C=84=EC=B9=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chatting/dto/service/ChatService.java | 42 ------------------- 1 file changed, 42 deletions(-) delete mode 100644 src/main/java/com/hyunsolution/dangu/chatting/dto/service/ChatService.java diff --git a/src/main/java/com/hyunsolution/dangu/chatting/dto/service/ChatService.java b/src/main/java/com/hyunsolution/dangu/chatting/dto/service/ChatService.java deleted file mode 100644 index ed4b757..0000000 --- a/src/main/java/com/hyunsolution/dangu/chatting/dto/service/ChatService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.hyunsolution.dangu.chatting.dto.service; - -import com.hyunsolution.dangu.chatting.domain.ChatRepository; -import com.hyunsolution.dangu.chatting.domain.Chatting; -import com.hyunsolution.dangu.chatting.dto.response.ChatMessageDetailResponse; -import com.hyunsolution.dangu.user.domain.User; -import com.hyunsolution.dangu.user.domain.UserRepository; -import com.hyunsolution.dangu.workspace.domain.Workspace; -import com.hyunsolution.dangu.workspace.domain.WorkspaceRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class ChatService { - private final ChatRepository chatRepository; - private final WorkspaceRepository workspaceRepository; - private final UserRepository userRepository; - - @Transactional - public ChatMessageDetailResponse sendMessage(Long chatRoomId, String message, Long userPk) { - - Workspace workspace = - workspaceRepository - .findById(chatRoomId) - .orElseThrow(() -> new IllegalArgumentException("유효하지 않은 채팅방 id입니다.")); - User user = - userRepository - .findById(userPk) - .orElseThrow(() -> new IllegalArgumentException("유효하지 않은 사용자 id입니다.")); - - Chatting chatMessage = - Chatting.builder().workspace(workspace).user(user).content(message).build(); - - chatRepository.save(chatMessage); - - ChatMessageDetailResponse detailResponse = - new ChatMessageDetailResponse(message, user.getUid(), chatMessage.getCreatedAt()); - return detailResponse; - } -}