Skip to content

Commit

Permalink
fix : 방명록조회 API 플로어이름 response 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kim-wonjin committed Jul 5, 2023
1 parent 45c050f commit 2cb91fa
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.curator.oeuvre.domain.User;
import com.curator.oeuvre.dto.comment.reqeust.PostCommentRequestDto;
import com.curator.oeuvre.dto.comment.response.GetCommentResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorCommentsResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorToMoveResponseDto;
import com.curator.oeuvre.dto.comment.response.PostCommentResponseDto;
import com.curator.oeuvre.dto.common.response.PageResponseDto;
Expand Down Expand Up @@ -65,15 +66,15 @@ public CommonResponse<String> deleteComment(@AuthenticationPrincipal User authUs
@Operation(summary = "플로어 방명록 조회", description = "플로어 방명록 조회 API 입니다.\n" +
"댓글들을 최신순으로 size개씩 페이지네이션 해서 보여줍니다.\n" +
"page는 0부터 시작합니다. size는 10-50 가능합니다.")
public CommonResponse<PageResponseDto<List<GetCommentResponseDto>>> getFloorComments(
public CommonResponse<GetFloorCommentsResponseDto> getFloorComments(
@AuthenticationPrincipal User authUser,
@PathVariable Long floorNo,
@Parameter(description = "페이지", example = "0") @RequestParam(required = true) @Min(value = 0) Integer page,
@Parameter(description = "페이지 사이즈", example = "10") @RequestParam(required = true) @Min(value = 10) @Max(value = 50) Integer size) {
log.info("get-floor-comments");
log.info("api = 플로어 방명록 조회, user = {}", authUser.getNo());

PageResponseDto<List<GetCommentResponseDto>> result = commentService.getFloorComments(authUser, floorNo, page, size);
GetFloorCommentsResponseDto result = commentService.getFloorComments(authUser, floorNo, page, size);
return CommonResponse.onSuccess(result);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.curator.oeuvre.dto.comment.response;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;

import java.util.List;

@Getter
@ToString
@EqualsAndHashCode
@ApiModel(value = "플로어조회 API Response")
public class GetFloorCommentsResponseDto {

@ApiModelProperty(notes = "플로어 이름", example = "제주여행")
private final String floorName;

@ApiModelProperty(notes = "마지막 페이지 여부", example = "false")
private final Boolean isLastPage;

@ApiModelProperty(notes = "내용", example = "[]")
private final List<GetCommentResponseDto> contents;

public GetFloorCommentsResponseDto(String floorName, Boolean isLastPage, List<GetCommentResponseDto> contents) {
this.floorName = floorName;
this.isLastPage = isLastPage;
this.contents = contents;
}

}
3 changes: 2 additions & 1 deletion src/main/java/com/curator/oeuvre/service/CommentService.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.curator.oeuvre.domain.User;
import com.curator.oeuvre.dto.comment.reqeust.PostCommentRequestDto;
import com.curator.oeuvre.dto.comment.response.GetCommentResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorCommentsResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorToMoveResponseDto;
import com.curator.oeuvre.dto.comment.response.PostCommentResponseDto;
import com.curator.oeuvre.dto.common.response.PageResponseDto;
Expand All @@ -17,7 +18,7 @@ public interface CommentService {

void deleteComment(User user, Long commentNo);

PageResponseDto<List<GetCommentResponseDto>> getFloorComments(User user, Long floorNo, Integer page, Integer size);
GetFloorCommentsResponseDto getFloorComments(User user, Long floorNo, Integer page, Integer size);

List<GetFloorToMoveResponseDto> getFloorsToMove(User user, Long floorNo);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.curator.oeuvre.domain.User;
import com.curator.oeuvre.dto.comment.reqeust.PostCommentRequestDto;
import com.curator.oeuvre.dto.comment.response.GetCommentResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorCommentsResponseDto;
import com.curator.oeuvre.dto.comment.response.GetFloorToMoveResponseDto;
import com.curator.oeuvre.dto.comment.response.PostCommentResponseDto;
import com.curator.oeuvre.dto.common.response.PageResponseDto;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void deleteComment(User user, Long commentNo) {

@Override
@Transactional
public PageResponseDto<List<GetCommentResponseDto>> getFloorComments(User user, Long floorNo, Integer page, Integer size) {
public GetFloorCommentsResponseDto getFloorComments(User user, Long floorNo, Integer page, Integer size) {

Floor floor = floorRepository.findByNoAndStatus(floorNo, 1).orElseThrow(() ->
new NotFoundException(FLOOR_NOT_FOUND));
Expand All @@ -114,7 +115,7 @@ public PageResponseDto<List<GetCommentResponseDto>> getFloorComments(User user,
notificationRepository.saveAll(notifications);
}

return new PageResponseDto<>(comments.isLast(), result);
return new GetFloorCommentsResponseDto(floor.getName(), comments.isLast(), result);
}

@Override
Expand Down

0 comments on commit 2cb91fa

Please sign in to comment.