Skip to content

Commit

Permalink
feat: 자신의 리뷰 조회 컨트롤러와 request dto 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
pminsung12 committed Jul 17, 2024
1 parent 620a1a6 commit 1364125
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.depromeet.spot.application.review;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.PositiveOrZero;

import org.depromeet.spot.application.review.dto.request.BlockReviewRequest;
import org.depromeet.spot.application.review.dto.request.MyReviewRequest;
import org.depromeet.spot.application.review.dto.response.ReviewListResponse;
import org.depromeet.spot.domain.review.ReviewListResult;
import org.depromeet.spot.usecase.port.in.review.ReviewReadUsecase;
Expand Down Expand Up @@ -38,21 +38,31 @@ public ReviewListResponse findReviewsByBlockId(
@Positive
@Parameter(description = "블록 PK", required = true)
Long blockId,
@RequestParam(required = false) @Parameter(description = "열 ID (필터링)") Long rowId,
@RequestParam(required = false) @Parameter(description = "좌석 번호 (필터링)") Long seatNumber,
@RequestParam(defaultValue = "0")
@PositiveOrZero
@Parameter(description = "시작 위치 (기본값: 0)")
int offset,
@RequestParam(defaultValue = "10")
@Positive
@Max(50)
@Parameter(description = "조회할 리뷰 수 (기본값: 10, 최대: 50)")
int limit) {

@ModelAttribute BlockReviewRequest request) {
ReviewListResult result =
reviewReadUsecase.findReviewsByBlockId(
stadiumId, blockId, rowId, seatNumber, offset, limit);
stadiumId,
blockId,
request.rowId(),
request.seatNumber(),
request.offset(),
request.limit());
return ReviewListResponse.from(result);
}

@ResponseStatus(HttpStatus.OK)
@GetMapping("/reviews")
@Operation(
summary = " 자신이 작성한 리뷰 목록을 조회한다.",
description = "연도와 월로 필터링할 수 있다. 필터링 없이 전체를 조회하려면 year와 month를 null로 입력한다.")
public ReviewListResponse findMyReviews(@ModelAttribute MyReviewRequest request) {
ReviewListResult result =
reviewReadUsecase.findMyReviews(
request.userId(),
request.offset(),
request.limit(),
request.year(),
request.month());
return ReviewListResponse.from(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.depromeet.spot.application.review.dto.request;

import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.PositiveOrZero;

import io.swagger.v3.oas.annotations.Parameter;

public record MyReviewRequest(
@Parameter(description = "유저 ID") Long userId,
@PositiveOrZero @Parameter(description = "시작 위치 (기본값: 0)") Integer offset,
@Min(1) @Max(50) @Parameter(description = "조회할 리뷰 수 (기본값: 10, 최대: 50)") Integer limit,
@Min(1000) @Max(9999) @Parameter(description = "년도 (4자리 숫자)") Integer year,
@Min(1) @Max(12) @Parameter(description = "월 (1-12)") Integer month) {}

0 comments on commit 1364125

Please sign in to comment.