diff --git a/src/main/java/app/gangdan/please/api/PhotoGuideController.java b/src/main/java/app/gangdan/please/api/PhotoGuideController.java index 72c7528..69b691b 100644 --- a/src/main/java/app/gangdan/please/api/PhotoGuideController.java +++ b/src/main/java/app/gangdan/please/api/PhotoGuideController.java @@ -140,12 +140,21 @@ public ResponseEntity> getSpotList(@PathVariable("ph @Tag(name = "photoGuide") @GetMapping("/{photoGuideId}") @ApiOperation(value = "포토 가이드 상세 조회 api") // TODO : 더미데이터 테스트 + @Deprecated public ResponseEntity getPhotoGuide(@PathVariable("photoGuideId") Long photoGuideId) { PhotoGuide photoGuide = photoGuideService.getPhotoGuide(photoGuideId); return ResponseEntity.ok(PhotoGuideDetailResponseDto.from(photoGuide)); } + @Tag(name = "photoGuide") + @GetMapping("/v2/{photoGuideId}") + @ApiOperation(value = "포토 가이드 상세 조회 리메이크 api") // TODO : 더미데이터 테스트 + public ResponseEntity getPhotoGuideV2(@PathVariable("photoGuideId") Long photoGuideId) { + + PhotoGuide photoGuide = photoGuideService.getPhotoGuide(photoGuideId); + return ResponseEntity.ok(PhotoGuideDetailResponseDto.from(photoGuide)); + } } diff --git a/src/main/java/app/gangdan/please/dto/photoGuide/response/PhotoGuideDetailResponseDtoV2.java b/src/main/java/app/gangdan/please/dto/photoGuide/response/PhotoGuideDetailResponseDtoV2.java new file mode 100644 index 0000000..a49a949 --- /dev/null +++ b/src/main/java/app/gangdan/please/dto/photoGuide/response/PhotoGuideDetailResponseDtoV2.java @@ -0,0 +1,118 @@ +package app.gangdan.please.dto.photoGuide.response; + +import app.gangdan.please.domain.hashtag.Hashtag; +import app.gangdan.please.domain.photoGuide.PhotoGuide; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.util.List; +import java.util.stream.Collectors; + +@Data +@Builder +@AllArgsConstructor +@ApiModel(value = "포토 가이드 상세 조회 응답 객체 v2") +public class PhotoGuideDetailResponseDtoV2 { + + @ApiModelProperty(value = "포토 가이드 id") + private Long photoGuideId; + + @ApiModelProperty(value = "멤버 id") + private Long memberId; + + @ApiModelProperty(value = "포토 가이드 original 이미지") + private String originalImage; + + @ApiModelProperty(value = "포토 가이드 contour 이미지") + private String contourImage; + + @ApiModelProperty(value = "포토 가이드 contourTrans 이미지") + private String contourTransImage; + + @ApiModelProperty(value = "포토 가이드 mask 이미지") + private String maskImage; + +// @ApiModelProperty(value = "가로") +// private String width; +// +// @ApiModelProperty(value = "세로") +// private String height; + +// @ApiModelProperty(value = "외곽선 json") +// private String guideLine; + + @ApiModelProperty(value = "위도") + private Double latitude; + + @ApiModelProperty(value = "경도") + private Double longitude; + + @ApiModelProperty(value = "포토 스팟 이름") + private String photoSpotName; + + @ApiModelProperty(value = "해시태그 리스트") + private List hashtags; + + @ApiModelProperty(value = "좋아요 개수") + private Integer heartNum; + + + public static PhotoGuideDetailResponseDtoV2 from(PhotoGuide photoGuide){ + + return new PhotoGuideDetailResponseDtoV2.PhotoGuideDetailResponseDtoV2Builder() + .photoGuideId(photoGuide.getPhotoGuideId()) + .memberId(photoGuide.getMember().getMemberId()) + .originalImage(getOriginalImage(photoGuide)) + .contourImage(getContourImage(photoGuide)) + .contourTransImage(getContourTransImage(photoGuide)) + .maskImage(getMaskImage(photoGuide)) +// .guideLine(photoGuide.getGuideLine()) +// .width(photoGuide.getGuideImageList().get(0).getWidth()) +// .height(photoGuide.getGuideImageList().get(0).getHeight()) + .latitude(photoGuide.getPhotoSpot().getLatitude()) + .longitude(photoGuide.getPhotoSpot().getLongitude()) + .photoSpotName(photoGuide.getPhotoSpot().getPhotoSpotName()) + .hashtags(photoGuide.getHashtagList().stream().map(Hashtag::getHashtagName).collect(Collectors.toList())) + .heartNum(photoGuide.getHeartList().size()) + .build(); + } + + private static String getOriginalImage(PhotoGuide photoGuide){ + + if(photoGuide.getOriginalImageList().size() == 0){ + return ""; + }else { + return photoGuide.getOriginalImageList().get(0).getImageUrl(); + } + } + + private static String getContourImage(PhotoGuide photoGuide){ + + if(photoGuide.getContourImageList().size() == 0){ + return ""; + }else { + return photoGuide.getContourImageList().get(0).getImageUrl(); + } + } + + private static String getContourTransImage(PhotoGuide photoGuide){ + + if(photoGuide.getContourTransImageList().size() == 0){ + return ""; + }else { + return photoGuide.getContourTransImageList().get(0).getImageUrl(); + } + } + + private static String getMaskImage(PhotoGuide photoGuide){ + + if(photoGuide.getMaskImageList().size() == 0){ + return ""; + }else { + return photoGuide.getMaskImageList().get(0).getImageUrl(); + } + } +} diff --git a/src/main/java/app/gangdan/please/service/image/ImageService.java b/src/main/java/app/gangdan/please/service/image/ImageService.java index 17f8f0b..3a03722 100644 --- a/src/main/java/app/gangdan/please/service/image/ImageService.java +++ b/src/main/java/app/gangdan/please/service/image/ImageService.java @@ -66,6 +66,8 @@ public void saveOriginalImageV2(PhotoGuide photoGuide, String base64) { OriginalImage originalImage = new OriginalImage(photoGuide, imageUrl); originalImageRepository.save(originalImage); + photoGuide.getOriginalImageList().add(originalImage); + System.out.println("File 객체로 변환되었습니다."); } catch (Exception e) { e.printStackTrace(); @@ -93,6 +95,8 @@ public void saveContourImageV2(PhotoGuide photoGuide, String base64) { ContourImage contourImage = new ContourImage(photoGuide, imageUrl); contourImageRepository.save(contourImage); + photoGuide.getContourImageList().add(contourImage); + System.out.println("File 객체로 변환되었습니다."); } catch (Exception e) { e.printStackTrace(); @@ -120,6 +124,8 @@ public void saveContourTransImageV2(PhotoGuide photoGuide, String base64) { ContourTransImage contourTransImage = new ContourTransImage(photoGuide, imageUrl); contourTransImageRepository.save(contourTransImage); + photoGuide.getContourTransImageList().add(contourTransImage); + System.out.println("File 객체로 변환되었습니다."); } catch (Exception e) { e.printStackTrace(); @@ -147,6 +153,8 @@ public void saveMaskImageV2(PhotoGuide photoGuide, String base64) { MaskImage maskImage = new MaskImage(photoGuide, imageUrl); maskImageRepository.save(maskImage); + photoGuide.getMaskImageList().add(maskImage); + System.out.println("File 객체로 변환되었습니다."); } catch (Exception e) { e.printStackTrace();