@@ -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
0 commit comments