Skip to content

Commit c1d9faa

Browse files
committed
[FEAT #71] 장소 조회 시 썸네일 이미지 추가
1 parent 5fc101d commit c1d9faa

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

src/main/java/com/dnd/reetplace/app/dto/place/response/PlaceGetResponse.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class PlaceGetResponse {
2222
@Schema(description = "상세 페이지 URL", example = "http://place.map.kakao.com/1520672825")
2323
private String url;
2424

25+
@Schema(description = "썸네일 이미지 url", example = "https://t1.daumcdn.net/place/75B5CF9ACCF84162A7E13CB1FD4D5D43")
26+
private String thumbnailImage;
27+
2528
@Schema(description = "<p>카테고리 그룹 코드. 목록은 다음과 같음</p>" +
2629
"<ul>" +
2730
"<li>MT1 - 대형마트</li>" +
@@ -132,6 +135,7 @@ public class PlaceGetResponse {
132135

133136
public static PlaceGetResponse of(
134137
KakaoPlaceGetResponse kakaoResponse,
138+
String thumbnailImage,
135139
BookmarkType bookmarkType,
136140
Long bookmarkId
137141
) {
@@ -145,6 +149,7 @@ public static PlaceGetResponse of(
145149
kakaoResponse.getId(),
146150
kakaoResponse.getPlace_name(),
147151
kakaoResponse.getPlace_url(),
152+
thumbnailImage,
148153
categoryGroupCode,
149154
kakaoResponse.getCategory_name(),
150155
kakaoResponse.getCategory(),
@@ -159,7 +164,7 @@ public static PlaceGetResponse of(
159164
);
160165
}
161166

162-
public static PlaceGetResponse ofWithoutBookmark(KakaoPlaceGetResponse kakaoResponse) {
163-
return of(kakaoResponse, null, null);
167+
public static PlaceGetResponse ofWithoutBookmark(KakaoPlaceGetResponse kakaoResponse, String thumbnailImage) {
168+
return of(kakaoResponse, thumbnailImage, null, null);
164169
}
165170
}

src/main/java/com/dnd/reetplace/app/dto/place/response/PlaceSearchResponse.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public class PlaceSearchResponse {
2424
@Schema(description = "상세 페이지 URL", example = "http://place.map.kakao.com/1520672825")
2525
private String url;
2626

27+
@Schema(description = "썸네일 이미지 url", example = "https://t1.daumcdn.net/place/75B5CF9ACCF84162A7E13CB1FD4D5D43")
28+
private String thumbnailImage;
29+
2730
@Schema(description = "<p>카테고리 그룹 코드. 목록은 다음과 같음</p>" +
2831
"<ul>" +
2932
"<li>MT1 - 대형마트</li>" +
@@ -137,6 +140,7 @@ public class PlaceSearchResponse {
137140

138141
public static PlaceSearchResponse of(
139142
KakaoPlaceSearchResponse kakaoResponse,
143+
String thumbnailImage,
140144
BookmarkType bookmarkType,
141145
Long bookmarkId,
142146
Short rate
@@ -168,6 +172,7 @@ public static PlaceSearchResponse of(
168172
kakaoResponse.getId(),
169173
kakaoResponse.getPlace_name(),
170174
kakaoResponse.getPlace_url(),
175+
thumbnailImage,
171176
categoryGroupCode,
172177
kakaoResponse.getCategory_name(),
173178
category,
@@ -183,7 +188,7 @@ public static PlaceSearchResponse of(
183188
);
184189
}
185190

186-
public static PlaceSearchResponse ofWithoutBookmark(KakaoPlaceSearchResponse kakaoResponse) {
187-
return of(kakaoResponse, null, null, null);
191+
public static PlaceSearchResponse ofWithoutBookmark(KakaoPlaceSearchResponse kakaoResponse, String thumbnailImage) {
192+
return of(kakaoResponse, thumbnailImage, null, null, null);
188193
}
189194
}

src/main/java/com/dnd/reetplace/app/service/PlaceService.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class PlaceService {
3333
private final BookmarkRepository bookmarkRepository;
3434
private final MemberRepository memberRepository;
3535
private final KakaoHttpRequestService kakaoHttpRequestService;
36+
private final ScrapService scrapService;
3637

3738
public static final String MEXICAN_KEYWORD = "멕시칸,브라질";
3839
public static final String ASIA_KEYWORD = "아시아음식";
@@ -140,7 +141,7 @@ private List<PlaceGetResponse> updateGetPlaceIsBookmark(HttpServletRequest httpS
140141
Member loginMember = findLoginMember(httpServletRequest);
141142
if (loginMember == null) {
142143
return result.stream()
143-
.map(PlaceGetResponse::ofWithoutBookmark)
144+
.map(response -> PlaceGetResponse.ofWithoutBookmark(response, scrapService.getPlaceThumbnailUrl(response.getId())))
144145
.toList();
145146
}
146147
List<Bookmark> bookmarkList = bookmarkRepository.findAllByMember(loginMember.getId());
@@ -151,9 +152,10 @@ private List<PlaceGetResponse> updateGetPlaceIsBookmark(HttpServletRequest httpS
151152
.findFirst()
152153
.map(bookmark -> PlaceGetResponse.of(
153154
place,
155+
bookmark.getThumbnailUrl(),
154156
bookmark.getType(),
155157
bookmark.getId()))
156-
.orElse(PlaceGetResponse.ofWithoutBookmark(place)))
158+
.orElse(PlaceGetResponse.ofWithoutBookmark(place, scrapService.getPlaceThumbnailUrl(place.getId()))))
157159
.toList();
158160
}
159161

@@ -170,7 +172,7 @@ private List<PlaceSearchResponse> updateSearchPlaceIsBookmark(HttpServletRequest
170172
Member loginMember = findLoginMember(httpServletRequest);
171173
if (loginMember == null) {
172174
return result.stream()
173-
.map(PlaceSearchResponse::ofWithoutBookmark)
175+
.map(response -> PlaceSearchResponse.ofWithoutBookmark(response, scrapService.getPlaceThumbnailUrl(response.getId())))
174176
.filter(place -> place.getCategory() != null)
175177
.toList();
176178
}
@@ -182,10 +184,11 @@ private List<PlaceSearchResponse> updateSearchPlaceIsBookmark(HttpServletRequest
182184
.findFirst()
183185
.map(bookmark -> PlaceSearchResponse.of(
184186
place,
187+
bookmark.getThumbnailUrl(),
185188
bookmark.getType(),
186189
bookmark.getId(),
187190
bookmark.getRate()))
188-
.orElse(PlaceSearchResponse.ofWithoutBookmark(place)))
191+
.orElse(PlaceSearchResponse.ofWithoutBookmark(place, scrapService.getPlaceThumbnailUrl(place.getId()))))
189192
.filter(place -> place.getCategory() != null)
190193
.toList();
191194
}

0 commit comments

Comments
 (0)