Skip to content

Commit 7e62df0

Browse files
Merge pull request #171 from Myaongi/feature/#142-create-chatroom-match
Feature/#142 create chatroom match
2 parents f76557a + d45958c commit 7e62df0

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/main/java/Myaong/Gangajikimi/chatroom/repository/ChatRoomRepositoryImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public List<ChatRoomListResponse> findChatRoomsWithLastMessageAndUnreadCount(Lon
111111
.postImageUrl(postImageUrl)
112112
.postRegion(postRegion)
113113
.postUserTime(postUserTime)
114+
.chatContext(room.getContext())
114115
.build();
115116
}).toList();
116117
}

src/main/java/Myaong/Gangajikimi/chatroom/service/ChatRoomServiceImpl.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public ChatRoomResponse createChatRoom(ChatRoomCreateRequest req, Long memberId)
9696
Long opponentPostId;
9797
PostType opponentType;
9898
String title, region, dogType, dogColor;
99+
String image; // 이미지
99100
String timeAgo = null; // 필요 없으면 제거
100101

101102
if (iAmLostOwner) {
@@ -106,6 +107,7 @@ public ChatRoomResponse createChatRoom(ChatRoomCreateRequest req, Long memberId)
106107
dogType = (found.getDogType() != null) ? found.getDogType().getType() : null;
107108
dogColor = found.getDogColor();
108109
timeAgo = TimeUtil.getTimeAgo(found.getFoundTime());
110+
image = pickImage(found);
109111
} else { // iAmFoundOwner
110112
opponentPostId = lost.getId();
111113
opponentType = PostType.LOST;
@@ -114,6 +116,7 @@ public ChatRoomResponse createChatRoom(ChatRoomCreateRequest req, Long memberId)
114116
dogType = (lost.getDogType() != null) ? lost.getDogType().getType() : null;
115117
dogColor = lost.getDogColor();
116118
timeAgo = TimeUtil.getTimeAgo(lost.getLostTime());
119+
image = pickImage(lost);
117120
}
118121

119122
// 2-3) 응답을 서비스에서 직접 빌드(컨버터 손 안 댐)
@@ -131,6 +134,7 @@ public ChatRoomResponse createChatRoom(ChatRoomCreateRequest req, Long memberId)
131134
.opponentDogType(dogType)
132135
.opponentDogColor(dogColor)
133136
.opponentTimeAgo(timeAgo)
137+
.opponentImage(image)
134138
.build();
135139
}
136140

@@ -206,7 +210,9 @@ public ChatRoomResponse getRoomAndMatchCard(Long chatRoomId, Long requesterId) {
206210
.opponentRegion(found.getFoundRegion())
207211
.opponentDogType(found.getDogType()!=null?found.getDogType().getType():null)
208212
.opponentDogColor(found.getDogColor())
209-
.opponentTimeAgo(TimeUtil.getTimeAgo(found.getFoundTime()));
213+
.opponentTimeAgo(TimeUtil.getTimeAgo(found.getFoundTime()))
214+
.opponentImage(pickImage(found))
215+
.dogName(lost.getDogName()); // dogName 반환
210216
} else { // 내가 FOUND 주인 → 상대 LOST 카드
211217
b.matchingRatio(ratio)
212218
.opponentPostId(lost.getId())
@@ -215,14 +221,37 @@ public ChatRoomResponse getRoomAndMatchCard(Long chatRoomId, Long requesterId) {
215221
.opponentRegion(lost.getLostRegion())
216222
.opponentDogType(lost.getDogType()!=null?lost.getDogType().getType():null)
217223
.opponentDogColor(lost.getDogColor())
218-
.opponentTimeAgo(TimeUtil.getTimeAgo(lost.getLostTime()));
224+
.opponentTimeAgo(TimeUtil.getTimeAgo(lost.getLostTime()))
225+
.opponentImage(pickImage(lost));
219226
}
220227
}
221228
}
222229

223230
return b.build();
224231
}
225232

233+
private String pickImage(PostFound found) {
234+
if (found.getAiImage() != null && !found.getAiImage().isBlank()) {
235+
return found.getAiImage();
236+
}
237+
var real = found.getRealImage();
238+
if (real != null && !real.isEmpty() && real.get(0) != null && !real.get(0).isBlank()) {
239+
return real.get(0);
240+
}
241+
return null;
242+
}
243+
244+
private String pickImage(PostLost lost) {
245+
if (lost.getAiImage() != null && !lost.getAiImage().isBlank()) {
246+
return lost.getAiImage();
247+
}
248+
var real = lost.getRealImage();
249+
if (real != null && !real.isEmpty() && real.get(0) != null && !real.get(0).isBlank()) {
250+
return real.get(0);
251+
}
252+
return null;
253+
}
254+
226255

227256

228257

src/main/java/Myaong/Gangajikimi/chatroom/web/dto/ChatRoomListResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.time.LocalDateTime;
44

5+
import Myaong.Gangajikimi.common.enums.ChatContext;
56
import Myaong.Gangajikimi.common.enums.PostType;
67
import lombok.AllArgsConstructor;
78
import lombok.Builder;
@@ -27,6 +28,7 @@ public class ChatRoomListResponse {
2728
private String postImageUrl;
2829
private String postRegion;
2930
private LocalDateTime postUserTime;
31+
private ChatContext chatContext;
3032

3133

3234
}

src/main/java/Myaong/Gangajikimi/chatroom/web/dto/ChatRoomResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ public class ChatRoomResponse {
2525
private String opponentDogType;
2626
private String opponentDogColor;
2727
private String opponentTimeAgo; // "3분 전" 등 (선택)
28+
private String opponentImage;
29+
private String dogName;
2830
}

0 commit comments

Comments
 (0)