Skip to content

Commit

Permalink
[FEAT #71] 장소 조회 시 썸네일 이미지 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
HunSeongPark committed Oct 18, 2023
1 parent 5fc101d commit c1d9faa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public class PlaceGetResponse {
@Schema(description = "상세 페이지 URL", example = "http://place.map.kakao.com/1520672825")
private String url;

@Schema(description = "썸네일 이미지 url", example = "https://t1.daumcdn.net/place/75B5CF9ACCF84162A7E13CB1FD4D5D43")
private String thumbnailImage;

@Schema(description = "<p>카테고리 그룹 코드. 목록은 다음과 같음</p>" +
"<ul>" +
"<li>MT1 - 대형마트</li>" +
Expand Down Expand Up @@ -132,6 +135,7 @@ public class PlaceGetResponse {

public static PlaceGetResponse of(
KakaoPlaceGetResponse kakaoResponse,
String thumbnailImage,
BookmarkType bookmarkType,
Long bookmarkId
) {
Expand All @@ -145,6 +149,7 @@ public static PlaceGetResponse of(
kakaoResponse.getId(),
kakaoResponse.getPlace_name(),
kakaoResponse.getPlace_url(),
thumbnailImage,
categoryGroupCode,
kakaoResponse.getCategory_name(),
kakaoResponse.getCategory(),
Expand All @@ -159,7 +164,7 @@ public static PlaceGetResponse of(
);
}

public static PlaceGetResponse ofWithoutBookmark(KakaoPlaceGetResponse kakaoResponse) {
return of(kakaoResponse, null, null);
public static PlaceGetResponse ofWithoutBookmark(KakaoPlaceGetResponse kakaoResponse, String thumbnailImage) {
return of(kakaoResponse, thumbnailImage, null, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class PlaceSearchResponse {
@Schema(description = "상세 페이지 URL", example = "http://place.map.kakao.com/1520672825")
private String url;

@Schema(description = "썸네일 이미지 url", example = "https://t1.daumcdn.net/place/75B5CF9ACCF84162A7E13CB1FD4D5D43")
private String thumbnailImage;

@Schema(description = "<p>카테고리 그룹 코드. 목록은 다음과 같음</p>" +
"<ul>" +
"<li>MT1 - 대형마트</li>" +
Expand Down Expand Up @@ -137,6 +140,7 @@ public class PlaceSearchResponse {

public static PlaceSearchResponse of(
KakaoPlaceSearchResponse kakaoResponse,
String thumbnailImage,
BookmarkType bookmarkType,
Long bookmarkId,
Short rate
Expand Down Expand Up @@ -168,6 +172,7 @@ public static PlaceSearchResponse of(
kakaoResponse.getId(),
kakaoResponse.getPlace_name(),
kakaoResponse.getPlace_url(),
thumbnailImage,
categoryGroupCode,
kakaoResponse.getCategory_name(),
category,
Expand All @@ -183,7 +188,7 @@ public static PlaceSearchResponse of(
);
}

public static PlaceSearchResponse ofWithoutBookmark(KakaoPlaceSearchResponse kakaoResponse) {
return of(kakaoResponse, null, null, null);
public static PlaceSearchResponse ofWithoutBookmark(KakaoPlaceSearchResponse kakaoResponse, String thumbnailImage) {
return of(kakaoResponse, thumbnailImage, null, null, null);
}
}
11 changes: 7 additions & 4 deletions src/main/java/com/dnd/reetplace/app/service/PlaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class PlaceService {
private final BookmarkRepository bookmarkRepository;
private final MemberRepository memberRepository;
private final KakaoHttpRequestService kakaoHttpRequestService;
private final ScrapService scrapService;

public static final String MEXICAN_KEYWORD = "멕시칸,브라질";
public static final String ASIA_KEYWORD = "아시아음식";
Expand Down Expand Up @@ -140,7 +141,7 @@ private List<PlaceGetResponse> updateGetPlaceIsBookmark(HttpServletRequest httpS
Member loginMember = findLoginMember(httpServletRequest);
if (loginMember == null) {
return result.stream()
.map(PlaceGetResponse::ofWithoutBookmark)
.map(response -> PlaceGetResponse.ofWithoutBookmark(response, scrapService.getPlaceThumbnailUrl(response.getId())))
.toList();
}
List<Bookmark> bookmarkList = bookmarkRepository.findAllByMember(loginMember.getId());
Expand All @@ -151,9 +152,10 @@ private List<PlaceGetResponse> updateGetPlaceIsBookmark(HttpServletRequest httpS
.findFirst()
.map(bookmark -> PlaceGetResponse.of(
place,
bookmark.getThumbnailUrl(),
bookmark.getType(),
bookmark.getId()))
.orElse(PlaceGetResponse.ofWithoutBookmark(place)))
.orElse(PlaceGetResponse.ofWithoutBookmark(place, scrapService.getPlaceThumbnailUrl(place.getId()))))
.toList();
}

Expand All @@ -170,7 +172,7 @@ private List<PlaceSearchResponse> updateSearchPlaceIsBookmark(HttpServletRequest
Member loginMember = findLoginMember(httpServletRequest);
if (loginMember == null) {
return result.stream()
.map(PlaceSearchResponse::ofWithoutBookmark)
.map(response -> PlaceSearchResponse.ofWithoutBookmark(response, scrapService.getPlaceThumbnailUrl(response.getId())))
.filter(place -> place.getCategory() != null)
.toList();
}
Expand All @@ -182,10 +184,11 @@ private List<PlaceSearchResponse> updateSearchPlaceIsBookmark(HttpServletRequest
.findFirst()
.map(bookmark -> PlaceSearchResponse.of(
place,
bookmark.getThumbnailUrl(),
bookmark.getType(),
bookmark.getId(),
bookmark.getRate()))
.orElse(PlaceSearchResponse.ofWithoutBookmark(place)))
.orElse(PlaceSearchResponse.ofWithoutBookmark(place, scrapService.getPlaceThumbnailUrl(place.getId()))))
.filter(place -> place.getCategory() != null)
.toList();
}
Expand Down

0 comments on commit c1d9faa

Please sign in to comment.