Skip to content

Commit

Permalink
refactor: 메시지 저장 방식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Lujaec committed Mar 22, 2024
1 parent 6f925c9 commit 2139448
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/teamkrews/chat/service/MessageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.teamkrews.chat.repository.ChatRoomRepository;
import com.teamkrews.chat.repository.MessageRepository;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

import java.util.List;
Expand All @@ -17,6 +18,7 @@ public class MessageService {
private final MessageRepository messageRepository;
private final ChatRoomRepository chatRoomRepository;
private final ChatRoomService chatRoomService;
private final ModelMapper mapper;


// 특정 유저의 특정 워크스페이스의 특정 채팅방의 메시지 조회
Expand All @@ -29,8 +31,7 @@ public List<Message> getMessages(ChatRoom chatRoom) {
public Message saveMessage(Long chatRoomId, MessageDTO messageDTO) {
ChatRoom chatRoom = chatRoomService.findById(chatRoomId);

Message message = new Message();
message.setContent(messageDTO.getContent());
Message message = mapper.map(messageDTO, Message.class);
message.setChatRoom(chatRoom);

return messageRepository.save(message);
Expand Down

0 comments on commit 2139448

Please sign in to comment.