@@ -155,8 +155,11 @@ public ResponseDto<PostResponse> getDetailPost(Long postId) {
155
155
.orElseThrow (() -> new PostException (LATEST_SNAPSHOT_NOT_FOUND ));
156
156
157
157
List <String > imageList = postImageRepository .findByPostSnapshotId (postSnapshot .getId ())
158
- .stream ()
159
- .map (image -> image .getImageUrl ()).collect (Collectors .toList ());
158
+ .filter (list -> !list .isEmpty ())
159
+ .map (list -> list .stream ()
160
+ .map (imageRow -> imageRow .getImageUrl ())
161
+ .collect (Collectors .toList ()))
162
+ .orElse (null );
160
163
161
164
String workType = getWorkTypeName (postSnapshot .getWorkTypeId ());
162
165
PostResponse postResponse = new PostResponse (postId , post .getCeo ().getId (), post .getStoreName (),
@@ -253,7 +256,7 @@ public ResponseDto<GetAppliedListResponse> getAppliedList(Long userId) {
253
256
.filter (postSnapshot -> postSnapshot .getPost ().getPostId () == apply .getPost ().getPostId ())
254
257
.map (postSnapshot -> new AppliedPost (apply .getPost ().getPostId (), postSnapshot .getTitle (),
255
258
postSnapshot .getPost ().getStoreName (),
256
- postImageRepository . findByPostSnapshotId (postSnapshot .getId ()). get ( 0 ). getImageUrl ( ),
259
+ getFirstImageUrl (postSnapshot .getId ()),
257
260
apply .isRecruited (), postSnapshot .getPost ().getStatus ().equals ("done" ))))
258
261
.collect (Collectors .toList ());
259
262
@@ -265,7 +268,10 @@ public ResponseDto<GetAppliedListResponse> getAppliedList(Long userId) {
265
268
266
269
267
270
private String getFirstImageUrl (Long postSnapshotId ) {
268
- return postImageRepository .findByPostSnapshotId (postSnapshotId ).get (0 ).getImageUrl ();
271
+ return postImageRepository .findByPostSnapshotId (postSnapshotId )
272
+ .filter (list -> !list .isEmpty ())
273
+ .map (list -> list .get (0 ).getImageUrl ())
274
+ .orElse (null );
269
275
}
270
276
271
277
0 commit comments