Skip to content

Commit e54ffc1

Browse files
authored
feat(user): 유저 프로필 썸네일화 (#243)
* feat(user): 유저 프로필 썸네일화에 따른 로직 추가 * feat(user): 유저 프로필을 반환하는 모든 dto에 유저 프로필 썸네일 필드도 추가 * feat(user): 유저 프로필 썸네일 추가 * test: 추가된 필드에 맞춰 테스트 수정
1 parent 92b3e95 commit e54ffc1

32 files changed

Lines changed: 152 additions & 40 deletions

src/main/java/org/devkor/apu/saerok_server/domain/admin/application/AdminReportQueryService.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ public ReportedCollectionDetailResponse getReportedCollectionDetail(Long reportI
8888
long likeCount = collectionLikeRepository.countByCollectionId(collection.getId());
8989
long commentCount = collectionCommentRepository.countByCollectionId(collection.getId());
9090
String authorProfileImage = userProfileImageUrlService.getProfileImageUrlFor(collection.getUser());
91+
String thumbnailProfileImage = userProfileImageUrlService.getProfileThumbnailImageUrlFor(collection.getUser());
9192

9293
GetCollectionDetailResponse collectionDetail =
9394
collectionWebMapper.toGetCollectionDetailResponse(
94-
collection, imageUrl, authorProfileImage, likeCount, commentCount, false, false
95+
collection, imageUrl, authorProfileImage, thumbnailProfileImage, likeCount, commentCount, false, false
9596
);
9697

9798
// 댓글 목록 (관리자 기준 isLiked/isMine 계산 불필요)
@@ -114,10 +115,11 @@ public ReportedCommentDetailResponse getReportedCommentDetail(Long reportId) {
114115
long likeCount = collectionLikeRepository.countByCollectionId(parentCollection.getId());
115116
long commentCount = collectionCommentRepository.countByCollectionId(parentCollection.getId());
116117
String authorProfileImage = userProfileImageUrlService.getProfileImageUrlFor(parentCollection.getUser());
118+
String thumbnailProfileImage = userProfileImageUrlService.getProfileThumbnailImageUrlFor(parentCollection.getUser());
117119

118120
GetCollectionDetailResponse collectionDetail =
119121
collectionWebMapper.toGetCollectionDetailResponse(
120-
parentCollection, imageUrl, authorProfileImage, likeCount, commentCount, false, false
122+
parentCollection, imageUrl, authorProfileImage, thumbnailProfileImage, likeCount, commentCount, false, false
121123
);
122124

123125
// 댓글 목록

src/main/java/org/devkor/apu/saerok_server/domain/collection/api/dto/response/GetCollectionCommentsResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public record Item(
2020
String nickname,
2121
@Schema(description = "작성자 프로필 이미지 URL", example = "https://cdn.example.com/user-profile-images/3.jpg", requiredMode = Schema.RequiredMode.REQUIRED)
2222
String profileImageUrl,
23+
@Schema(description = "작성자 썸네일 프로필 이미지 URL (320px 너비)", example = "https://cdn.example.com/thumbnails/user-profile-images/3.webp", requiredMode = Schema.RequiredMode.REQUIRED)
24+
String thumbnailProfileImageUrl,
2325
@Schema(description = "댓글 내용", example = "멋진 관찰 기록이네요!", requiredMode = Schema.RequiredMode.REQUIRED)
2426
String content,
2527
@Schema(description = "좋아요 수", example = "5", requiredMode = Schema.RequiredMode.REQUIRED)

src/main/java/org/devkor/apu/saerok_server/domain/collection/api/dto/response/GetCollectionDetailResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,8 @@ public static class UserInfo {
7979

8080
@Schema(description = "사용자 프로필 이미지 URL", example = "https://cdn.example.com/user-profile-images/10.jpg")
8181
private String profileImageUrl;
82+
83+
@Schema(description = "썸네일 프로필 이미지 URL (320px 너비)", example = "https://cdn.example.com/thumbnails/user-profile-images/10.webp")
84+
private String thumbnailProfileImageUrl;
8285
}
8386
}

src/main/java/org/devkor/apu/saerok_server/domain/collection/api/dto/response/GetCollectionLikersResponse.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ public record Item(
1818
String nickname,
1919

2020
@Schema(description = "사용자 프로필 이미지 URL", example = "https://cdn.example.com/user-profile-images/10.jpg")
21-
String profileImageUrl
21+
String profileImageUrl,
22+
23+
@Schema(description = "썸네일 프로필 이미지 URL (320px 너비)", example = "https://cdn.example.com/thumbnails/user-profile-images/10.webp")
24+
String thumbnailProfileImageUrl
2225
) {}
2326
}

src/main/java/org/devkor/apu/saerok_server/domain/collection/api/dto/response/GetNearbyCollectionsResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,8 @@ public static class UserInfo {
6868

6969
@Schema(description = "소유자 프로필 이미지 URL", example = "https://cdn.example.com/user-profile-images/10.jpg")
7070
private String profileImageUrl;
71+
72+
@Schema(description = "썸네일 프로필 이미지 URL (320px 너비)", example = "https://cdn.example.com/thumbnails/user-profile-images/10.webp")
73+
private String thumbnailProfileImageUrl;
7174
}
7275
}

src/main/java/org/devkor/apu/saerok_server/domain/collection/api/dto/response/GetPendingCollectionsResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public record Item(
2828
@Schema(description = "작성자 프로필 이미지 URL", example = "https://cdn.example.com/user-profile-images/user123.jpg", requiredMode = Schema.RequiredMode.REQUIRED)
2929
String profileImageUrl,
3030

31+
@Schema(description = "작성자 썸네일 프로필 이미지 URL (320px 너비)", example = "https://cdn.example.com/thumbnails/user-profile-images/user123.webp", requiredMode = Schema.RequiredMode.REQUIRED)
32+
String thumbnailProfileImageUrl,
33+
3134
@Schema(description = "동정 의견 요청 시각", example = "2025-07-20T00:23:58.164815", requiredMode = Schema.RequiredMode.REQUIRED)
3235
LocalDateTime birdIdSuggestionRequestedAt
3336
) {}

src/main/java/org/devkor/apu/saerok_server/domain/collection/application/BirdIdSuggestionQueryService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public GetPendingCollectionsResponse getPendingCollections() {
4949
.distinct()
5050
.toList();
5151
Map<Long, String> profileImageUrls = userProfileImageUrlService.getProfileImageUrlsFor(users);
52+
Map<Long, String> thumbnailProfileImageUrls = userProfileImageUrlService.getProfileThumbnailImageUrlsFor(users);
5253

5354
// ── 3.5단계: 열린 동정 요청 히스토리 startedAt 일괄 조회 (기존 c.getBirdIdSuggestionRequestedAt() 대체)
5455
List<Long> ids = collections.stream().map(UserBirdCollection::getId).toList();
@@ -66,6 +67,7 @@ public GetPendingCollectionsResponse getPendingCollections() {
6667
c.getNote(),
6768
c.getUser().getNickname(),
6869
profileImageUrls.get(c.getUser().getId()),
70+
thumbnailProfileImageUrls.get(c.getUser().getId()),
6971
startedAt != null
7072
? OffsetDateTimeLocalizer.toSeoulLocalDateTime(startedAt)
7173
: null

src/main/java/org/devkor/apu/saerok_server/domain/collection/application/CollectionCommentQueryService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public GetCollectionCommentsResponse getComments(Long collectionId, Long userId)
6969
.toList();
7070

7171
Map<Long, String> profileImageUrls = userProfileImageUrlService.getProfileImageUrlsFor(users);
72+
Map<Long, String> thumbnailProfileImageUrls = userProfileImageUrlService.getProfileThumbnailImageUrlsFor(users);
7273

7374
// 7. 응답 생성
74-
return collectionCommentWebMapper.toGetCollectionCommentsResponse(comments, likeCounts, likeStatuses, mineStatuses, profileImageUrls, isMyCollection);
75+
return collectionCommentWebMapper.toGetCollectionCommentsResponse(comments, likeCounts, likeStatuses, mineStatuses, profileImageUrls, thumbnailProfileImageUrls, isMyCollection);
7576
}
7677

7778
/* 댓글 개수 */

src/main/java/org/devkor/apu/saerok_server/domain/collection/application/CollectionLikeQueryService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public GetCollectionLikersResponse getCollectionLikersResponse(Long collectionId
6363

6464
List<User> users = collectionLikeRepository.findLikersByCollectionId(collectionId);
6565
Map<Long, String> profileImageUrls = userProfileImageUrlService.getProfileImageUrlsFor(users);
66-
return collectionLikeWebMapper.toGetCollectionLikersResponse(users, profileImageUrls);
66+
Map<Long, String> thumbnailProfileImageUrls = userProfileImageUrlService.getProfileThumbnailImageUrlsFor(users);
67+
return collectionLikeWebMapper.toGetCollectionLikersResponse(users, profileImageUrls, thumbnailProfileImageUrls);
6768
}
6869
}

src/main/java/org/devkor/apu/saerok_server/domain/collection/application/CollectionQueryService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ public GetCollectionDetailResponse getCollectionDetailResponse(Long userId, Long
125125
boolean isLikedByMe = userId != null && collectionLikeRepository.existsByUserIdAndCollectionId(userId, collectionId);
126126
boolean isMine = userId != null && userId.equals(collection.getUser().getId());
127127
String userProfileImageUrl = userProfileImageUrlService.getProfileImageUrlFor(collection.getUser());
128+
String thumbnailProfileImageUrl = userProfileImageUrlService.getProfileThumbnailImageUrlFor(collection.getUser());
128129

129-
return collectionWebMapper.toGetCollectionDetailResponse(collection, imageUrl, userProfileImageUrl, likeCount, commentCount, isLikedByMe, isMine);
130+
return collectionWebMapper.toGetCollectionDetailResponse(collection, imageUrl, userProfileImageUrl, thumbnailProfileImageUrl, likeCount, commentCount, isLikedByMe, isMine);
130131
}
131132

132133
public GetNearbyCollectionsResponse getNearbyCollections(GetNearbyCollectionsCommand command) {
@@ -168,6 +169,7 @@ public GetNearbyCollectionsResponse getNearbyCollections(GetNearbyCollectionsCom
168169
// 6) 작성자 프로필 이미지 배치 조회
169170
List<User> authors = collections.stream().map(UserBirdCollection::getUser).toList();
170171
Map<Long, String> profileImageMap = userProfileImageUrlService.getProfileImageUrlsFor(authors);
172+
Map<Long, String> thumbnailProfileImageMap = userProfileImageUrlService.getProfileThumbnailImageUrlsFor(authors);
171173

172174
// 7) DTO 조립 (맵에서 누락 시 안전 기본값)
173175
List<GetNearbyCollectionsResponse.Item> items = collections.stream()
@@ -176,12 +178,14 @@ public GetNearbyCollectionsResponse getNearbyCollections(GetNearbyCollectionsCom
176178
long commentCount = commentCounts.getOrDefault(c.getId(), 0L);
177179
boolean isLikedByMe = command.userId() != null && myLikeMap.getOrDefault(c.getId(), false);
178180
String userProfileImageUrl = profileImageMap.get(c.getUser().getId());
181+
String thumbnailProfileImageUrl = thumbnailProfileImageMap.get(c.getUser().getId());
179182

180183
return collectionWebMapper.toGetNearbyCollectionsResponseItem(
181184
c,
182185
urlMap.get(c.getId()),
183186
thumbnailUrlMap.get(c.getId()),
184187
userProfileImageUrl,
188+
thumbnailProfileImageUrl,
185189
likeCount,
186190
commentCount,
187191
isLikedByMe

0 commit comments

Comments
 (0)