Skip to content

Commit

Permalink
feat: 포토가이드 상세조회 리메이크 api
Browse files Browse the repository at this point in the history
  • Loading branch information
daeunkwak committed Oct 29, 2023
1 parent bd4d516 commit 093ab98
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,21 @@ public ResponseEntity<List<PhotoGuideResponseDto>> getSpotList(@PathVariable("ph
@Tag(name = "photoGuide")
@GetMapping("/{photoGuideId}")
@ApiOperation(value = "포토 가이드 상세 조회 api") // TODO : 더미데이터 테스트
@Deprecated
public ResponseEntity<PhotoGuideDetailResponseDto> 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<PhotoGuideDetailResponseDto> getPhotoGuideV2(@PathVariable("photoGuideId") Long photoGuideId) {

PhotoGuide photoGuide = photoGuideService.getPhotoGuide(photoGuideId);
return ResponseEntity.ok(PhotoGuideDetailResponseDto.from(photoGuide));
}

}

Original file line number Diff line number Diff line change
@@ -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<String> 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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 093ab98

Please sign in to comment.