diff --git a/server/src/main/java/com/yogit/server/board/dto/response/GetBoardRes.java b/server/src/main/java/com/yogit/server/board/dto/response/GetBoardRes.java index f0fc60f..ed2973f 100644 --- a/server/src/main/java/com/yogit/server/board/dto/response/GetBoardRes.java +++ b/server/src/main/java/com/yogit/server/board/dto/response/GetBoardRes.java @@ -112,6 +112,9 @@ public class GetBoardRes { @ApiParam(value = "참여 유저 이미지 url 리스트") private List userImageUrls; + @ApiModelProperty(example = "false", value = "요청 유저의 보드 참여 여부") + private Boolean isJoinedUser; + @ApiModelProperty(example = "ACTIVE") @ApiParam(value = "객체 상태") private BaseStatus status; @@ -128,7 +131,7 @@ public class GetBoardRes { 연관관계 편의 메서드 */ @Builder - public GetBoardRes(Long boardId, Long cityId, String cityName, Long hostId, String hostName, String profileImgUrl, String title, String address, String addressDetail, float longitute, float latitude, LocalDateTime date, String notice, String introduction, String kindOfPerson, int currentMember, int totalMember, Long categoryId, String categoryName, List imageUrls, List imageIds, List userIds, List userImageUrls, BaseStatus status, String createdAt, String updatedAt) { + public GetBoardRes(Long boardId, Long cityId, String cityName, Long hostId, String hostName, String profileImgUrl, String title, String address, String addressDetail, float longitute, float latitude, LocalDateTime date, String notice, String introduction, String kindOfPerson, int currentMember, int totalMember, Long categoryId, String categoryName, List imageUrls, List imageIds, List userIds, List userImageUrls, Boolean isJoinedUser, BaseStatus status, String createdAt, String updatedAt) { this.boardId = boardId; this.cityId = cityId; this.cityName = cityName; @@ -152,13 +155,14 @@ public GetBoardRes(Long boardId, Long cityId, String cityName, Long hostId, Stri this.imageIds = imageIds; this.userIds = userIds; this.userImageUrls = userImageUrls; + this.isJoinedUser = isJoinedUser; this.status = status; this.createdAt = createdAt; this.updatedAt = updatedAt; } - public static GetBoardRes toDto(Board board, List imageUrls, String profileImgUrl, List users, List userImageUrls){ + public static GetBoardRes toDto(Board board, List imageUrls, String profileImgUrl, List users, List userImageUrls, User user){ return GetBoardRes.builder() .boardId(board.getId()) .cityId(board.getCity().getId()) @@ -185,6 +189,7 @@ public static GetBoardRes toDto(Board board, List imageUrls, String prof .map(image -> image.getId()).collect(Collectors.toList())) .userIds(users.stream().map(User::getId).collect(Collectors.toList())) .userImageUrls(userImageUrls) + .isJoinedUser(users.contains(user)) .status(board.getStatus()) .createdAt(board.getCreatedAt()) .updatedAt(board.getUpdatedAt()) diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index 3f31262..8cf92ae 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -356,16 +356,14 @@ public ApplicationResponse findBoard(GetBoardReq dto){ .orElseThrow(() -> new NotFoundBoardException()); List participants = board.getBoardUsers().stream() - .filter(boardUser -> !boardUser.getUser().equals(board.getHost())) .map(boardUser -> boardUser.getUser()) .collect(Collectors.toList()); List participantsImageUUIds = board.getBoardUsers().stream() - .filter(boardUser -> !boardUser.getUser().equals(board.getHost())) .map(boardUser -> boardUser.getUser().getProfileImg()) .collect(Collectors.toList()); - GetBoardRes res = GetBoardRes.toDto(board, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(board.getHost().getProfileImg()), participants, awsS3Service.makeUrlsOfFilenames(participantsImageUUIds)); + GetBoardRes res = GetBoardRes.toDto(board, awsS3Service.makeUrlsOfFilenames(board.getBoardImagesUUids()), awsS3Service.makeUrlOfFilename(board.getHost().getProfileImg()), participants, awsS3Service.makeUrlsOfFilenames(participantsImageUUIds), user); return ApplicationResponse.ok(res); }