Skip to content

Commit

Permalink
refactor: 보유견종 상세조회시 이미지id값 조회될 수 있도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Suxxxxhyun committed Feb 5, 2024
1 parent 86c46f6 commit 4b95e73
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.example.petree.domain.dog.dto;

import com.example.petree.domain.adopter.dto.ReviewDto;
import com.example.petree.domain.dog.domain.Dog;
import com.example.petree.domain.dog.domain.DogImgFile;
import com.example.petree.domain.dog.domain.Gender;
Expand Down Expand Up @@ -49,22 +50,26 @@ public class PossessionDogDto {
@Schema(description = "보유 견종 입양 진행 상태",example = "AVAILABLE")
private Status status;

@Schema(description = "보유견종 이미지 리스트",example = "{https://petree-bucket.s3.ap-northeast-2.amazonaws.com/dog-img/3eaa46ee-5187-4cb9-9195-1b6231709a83.jpg}")
private List<String> dogImgUrl;
@Schema(description = "보유견종 이미지 리스트",example = "아이디값 + {https://petree-bucket.s3.ap-northeast-2.amazonaws.com/dog-img/3eaa46ee-5187-4cb9-9195-1b6231709a83.jpg}")
private List<PossesionDogImgResponseDto> dogImgId;


public PossessionDogDto(Dog dog) {
List<PossesionDogImgResponseDto> imgResponseDtos = dog.getDogImgFiles().stream()
.map(imgFile -> PossesionDogImgResponseDto.builder()
.id(imgFile.getId())
.fileUrl(imgFile.getFileUrl())
.build())
.collect(Collectors.toList());

this.id=dog.getId();
this.dogType=dog.getDogType().getName();
this.gender=dog.getGender();
this.status=dog.getStatus();
this.birthDate=dog.getBirthDate();
this.name=dog.getName();
this.management=dog.getManagement();
this.dogImgUrl=dog.getDogImgFiles()
.stream()
.map(DogImgFile::getFileUrl)
.collect(Collectors.toList());
this.dogImgId = imgResponseDtos;
}

@Getter
Expand Down Expand Up @@ -184,6 +189,16 @@ public void patch(Dog dog) {

}

@Data
@Builder
public static class PossesionDogImgResponseDto {

@Schema(description = "보유견종이미지 파일의 PK", example = "1")
private Long id;
@Schema(description = "S3에 저장되는 파일 경로", example = "s3://<bucket-name>/<file-path>/<file-name>\n")
private String fileUrl;
}


/**
* packageName : com.example.petree.global
Expand Down

0 comments on commit 4b95e73

Please sign in to comment.