Skip to content

Commit

Permalink
채팅방 조회 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
sokft committed Feb 18, 2025
1 parent 99d619d commit 30f4a14
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Service
Expand Down Expand Up @@ -64,8 +65,18 @@ public ChattingResponseDTO.ChattingRoomMakeResponseDTO createChattingRoom(Long m
.tradeTitle(tradeTitle)
.otherMemberImgUrl(otherMemberImgUrl)
.otherLocation(otherLocation)
.chattings(new ArrayList<>())
.build();

// 생성한 유저를 채팅방과 연결
Chatting chatting = Chatting.builder()
.chattingRoom(chattingRoom)
.member(memberRepository.findById(myId).orElseThrow(() -> new RuntimeException("Member not found")))
.build();

chattingRoom.getChattings().add(chatting);
chattingRoomRepository.save(chattingRoom);

ChattingRoom savedRoom = chattingRoomRepository.save(chattingRoom);

return chattingConverter.toResponseDTO(savedRoom);
Expand Down

0 comments on commit 30f4a14

Please sign in to comment.