Skip to content

Commit

Permalink
#70 refactor: GetAllBoardRes의 게시판 이미지리스트 -> 한개의 이미지Url,ID 로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
xhaktmchl committed Nov 27, 2022
1 parent 698c50d commit aa9edda
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Data
@NoArgsConstructor
Expand Down Expand Up @@ -48,19 +46,19 @@ public class GetAllBoardRes {
@ApiParam(value = "모임 카테고리 ID")
private Long categoryId;

@ApiModelProperty(example = "['이미지 url','이미지2 url']")
@ApiParam(value = "게시글 이미지 url 리스트")
private List<String> imageUrls;
@ApiModelProperty(example = "이미지 url")
@ApiParam(value = "게시글 첫번째 이미지 url")
private String imageUrl;

@ApiModelProperty(example = "[1,2,3]")
@ApiParam(value = "게시글 이미지 ID 리스트")
private List<Long> imageIds;
@ApiModelProperty(example = "1")
@ApiParam(value = "게시글 첫번째 이미지 ID")
private Long imageId;

@ApiModelProperty(example = "ACTIVE")
@ApiParam(value = "객체 상태")
private BaseStatus status;

public static GetAllBoardRes toDto(Board board, List<String> imageUrls, String profileImgUrl){
public static GetAllBoardRes toDto(Board board, String imageUrl, String profileImgUrl){
return GetAllBoardRes.builder()
.boardId(board.getId())
.cityId(board.getCity().getId())
Expand All @@ -70,14 +68,14 @@ public static GetAllBoardRes toDto(Board board, List<String> imageUrls, String p
.currentMember(board.getCurrentMember())
.totalMember(board.getTotalMember())
.categoryId(board.getCategory().getId())
.imageUrls(imageUrls)
.imageIds(board.getBoardImages().stream().map(image -> image.getId()).collect(Collectors.toList()))
.imageUrl(imageUrl)
.imageId(board.getBoardImages().get(0).getId())
.status(board.getStatus())
.build();
}

@Builder
public GetAllBoardRes(Long boardId, Long cityId, String profileImgUrl, String title, LocalDateTime date, int currentMember, int totalMember, Long categoryId, List<String> imageUrls, List<Long> imageIds, BaseStatus status) {
public GetAllBoardRes(Long boardId, Long cityId, String profileImgUrl, String title, LocalDateTime date, int currentMember, int totalMember, Long categoryId, String imageUrl, Long imageId, BaseStatus status) {
this.boardId = boardId;
this.cityId = cityId;
this.profileImgUrl = profileImgUrl;
Expand All @@ -86,8 +84,8 @@ public GetAllBoardRes(Long boardId, Long cityId, String profileImgUrl, String ti
this.currentMember = currentMember;
this.totalMember = totalMember;
this.categoryId = categoryId;
this.imageUrls = imageUrls;
this.imageIds = imageIds;
this.imageUrl = imageUrl;
this.imageId = imageId;
this.status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public ApplicationResponse<List<List<GetAllBoardRes>>> findAllBoards(GetAllBoard
Slice<Board> boards = boardRepository.findAllBoardsByCategory(pageRequest, categoryList.get(i).getId());
// 보드 res에 이미지uuid -> aws s3 url로 변환
List<GetAllBoardRes> boardsRes = boards.stream()
.map(board -> GetAllBoardRes.toDto(board, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(user.getProfileImg())))
.map(board -> GetAllBoardRes.toDto(board, awsS3Service.makeUrlOfFilename(board.getBoardImagesUUids().get(0)), awsS3Service.makeUrlOfFilename(user.getProfileImg())))
.collect(Collectors.toList());
// 전체 리스트에 카테고리 별 리스트 추가
res.add(boardsRes);
Expand Down

0 comments on commit aa9edda

Please sign in to comment.