diff --git a/src/main/java/shop/cazait/domain/cafe/dto/GetCafesRes.java b/src/main/java/shop/cazait/domain/cafe/dto/GetCafesRes.java index 4683a81d..66da41fa 100644 --- a/src/main/java/shop/cazait/domain/cafe/dto/GetCafesRes.java +++ b/src/main/java/shop/cazait/domain/cafe/dto/GetCafesRes.java @@ -6,7 +6,6 @@ import lombok.Builder; import lombok.Getter; import shop.cazait.domain.cafe.entity.Cafe; -import shop.cazait.domain.cafeimage.dto.GetCafeImageRes; import shop.cazait.domain.congestion.entity.CongestionStatus; import java.util.List; @@ -35,7 +34,7 @@ public class GetCafesRes { private String latitude; @JsonProperty @Schema(description = "이미지 url") - private List getCafeImageRes; + private List cafeImages; @JsonProperty @Schema(description = "거리", example = "200m") private int distance; @@ -43,7 +42,7 @@ public class GetCafesRes { @Schema(description = "관심 카페 여부", example = "true") private boolean favorite; - public static GetCafesRes of(Cafe cafe, List getCafeImageRes, int distance, boolean favorite) { + public static GetCafesRes of(Cafe cafe, List cafeImages, int distance, boolean favorite) { return GetCafesRes.builder() .cafeId(cafe.getId()) .congestionStatus(cafe.getCongestion().getCongestionStatus()) @@ -51,7 +50,7 @@ public static GetCafesRes of(Cafe cafe, List getCafeImageRes, i .address(cafe.getAddress()) .longitude(cafe.getCoordinate().getLongitude()) .latitude(cafe.getCoordinate().getLatitude()) - .getCafeImageRes(getCafeImageRes) + .cafeImages(cafeImages) .distance(distance) .favorite(favorite) .build(); diff --git a/src/main/java/shop/cazait/domain/cafe/service/CafeService.java b/src/main/java/shop/cazait/domain/cafe/service/CafeService.java index f0f172fa..3dff22eb 100644 --- a/src/main/java/shop/cazait/domain/cafe/service/CafeService.java +++ b/src/main/java/shop/cazait/domain/cafe/service/CafeService.java @@ -190,7 +190,7 @@ private List readCafeList(List cafeList, String longitude, St List cafeResList = cafeList.stream() .map(cafe -> { boolean favorite = false; - List getCafeImageResList = cafeImageService.readCafeImageList(cafe.getId()); + List getCafeImageResList = cafeImageService.readCafeImageOnlyList(cafe.getId()); int distance = DistanceService.distance(cafe.getCoordinate().getLatitude(), cafe.getCoordinate().getLongitude(), @@ -213,7 +213,7 @@ private List readCafeList(Long userId, List cafeList, String break; } } - List getCafeImageResList = cafeImageService.readCafeImageList(cafe.getId()); + List getCafeImageResList = cafeImageService.readCafeImageOnlyList(cafe.getId()); int distance = DistanceService.distance(cafe.getCoordinate().getLatitude(), cafe.getCoordinate().getLongitude(), diff --git a/src/main/java/shop/cazait/domain/cafeimage/service/CafeImageService.java b/src/main/java/shop/cazait/domain/cafeimage/service/CafeImageService.java index 92c460a1..371a3670 100644 --- a/src/main/java/shop/cazait/domain/cafeimage/service/CafeImageService.java +++ b/src/main/java/shop/cazait/domain/cafeimage/service/CafeImageService.java @@ -90,6 +90,15 @@ public List readCafeImageList(Long cafeId) { return getCafeImageResList; } + public List readCafeImageOnlyList(Long cafeId) { + List cafeImageList = cafeImageRepository.findByCafeId(cafeId); + List getCafeImageResList = new ArrayList<>(); + for (CafeImage cafeImage : cafeImageList) { + getCafeImageResList.add(cafeImage.getImageUrl()); + } + return getCafeImageResList; + } + public void deleteCafeImage(Long cafeImageId, Long masterId) throws CafeImageException { CafeImage cafeImage = cafeImageRepository.findById(cafeImageId).orElseThrow(() -> new CafeImageException(ErrorStatus.NOT_EXIST_IMAGE)); Master master = masterRepository.findById(masterId).orElseThrow(() -> new CafeException(NOT_EXIST_MASTER));