Skip to content

Commit d4ebfeb

Browse files
authored
merge: pull request #56 from fix/chatRoom
[fix] : 채팅방 videoId 추가
2 parents 38a6bb1 + ebc4af1 commit d4ebfeb

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.dfbf.soundlink.domain.chat.dto;
2+
3+
import org.dfbf.soundlink.domain.chat.entity.ChatRoom;
4+
5+
public class ChatRoomWithVideoResDto {
6+
private Long chatRoomId;
7+
private String videoId;
8+
9+
public ChatRoomWithVideoResDto(Long chatRoomId, String videoId) {
10+
this.chatRoomId = chatRoomId;
11+
this.videoId = videoId;
12+
}
13+
// Getters
14+
public Long getChatRoomId() {
15+
return chatRoomId;
16+
}
17+
18+
public String getVideoId() {
19+
return videoId;
20+
}
21+
}

src/main/java/org/dfbf/soundlink/domain/chat/service/ChatRoomService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.dfbf.soundlink.domain.chat.service;
22

33
import lombok.RequiredArgsConstructor;
4+
import org.dfbf.soundlink.domain.chat.dto.ChatRoomWithVideoResDto;
45
import org.dfbf.soundlink.domain.chat.entity.redis.ChatRequest;
56
import org.dfbf.soundlink.domain.chat.dto.ChatReqDto;
67
import org.dfbf.soundlink.domain.chat.entity.ChatRoom;
@@ -16,7 +17,6 @@
1617
import org.dfbf.soundlink.global.comm.enums.RoomStatus;
1718
import org.dfbf.soundlink.global.exception.ErrorCode;
1819
import org.dfbf.soundlink.global.exception.ResponseResult;
19-
import org.springframework.dao.DataIntegrityViolationException;
2020
import org.springframework.data.redis.core.RedisTemplate;
2121
import org.springframework.security.core.annotation.AuthenticationPrincipal;
2222
import org.springframework.stereotype.Service;
@@ -111,6 +111,9 @@ public ResponseResult createChatRoom(Long userId, Long recordId) {
111111

112112
Long responseUserId = emotionRecord.getUser().getUserId();
113113

114+
//비디오아이디 추가
115+
String videoId = emotionRecord.getSpotifyMusic().getVideoId();
116+
114117
ChatRoom chatRoom = ChatRoom.builder()
115118
.requestUserId(requestUserId)
116119
.recordId(emotionRecord)
@@ -123,11 +126,12 @@ public ResponseResult createChatRoom(Long userId, Long recordId) {
123126
chatRoomRepository.save(chatRoom);
124127

125128
ChatReqDto chatReqDto = new ChatReqDto(userId, responseUserId);
126-
129+
130+
ChatRoomWithVideoResDto responseDto = new ChatRoomWithVideoResDto(chatRoom.getChatRoomId(), videoId);
131+
127132
// 레디스에 저장
128133
redisTemplate.opsForValue().set("Room::"+chatRoom.getChatRoomId(), String.valueOf(chatReqDto));
129-
130-
return new ResponseResult(ErrorCode.SUCCESS, chatRoom);
134+
return new ResponseResult(ErrorCode.SUCCESS, responseDto);
131135
} catch (Exception e) {
132136
return new ResponseResult(ErrorCode.INTERNAL_SERVER_ERROR, e.getMessage());
133137
}

0 commit comments

Comments
 (0)