Skip to content

Commit

Permalink
refactor: 피드 Get Method Parameter Validation 코드 리팩토링 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwanok authored Aug 24, 2024
1 parent cab800d commit 7b78ae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.depromeet.stonebed.domain.feed.dto.response.FeedGetResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

Expand All @@ -17,11 +18,7 @@ public class FeedController {

@Operation(summary = "피드 조회", description = "내 피드를 조회하는 API입니다.")
@GetMapping
public FeedGetResponse getFeed(
@RequestParam(required = false) String cursor,
@RequestParam(required = false) Long memberId,
@RequestParam int limit) {
FeedGetRequest request = new FeedGetRequest(cursor, memberId, limit);
public FeedGetResponse getFeed(@Valid FeedGetRequest request) {
return feedService.getFeed(request);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.depromeet.stonebed.domain.feed.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;

public record FeedGetRequest(
@Schema(description = "커서 위치", example = "1") String cursor,
@Schema(description = "작성자 ID", example = "1") Long memberId,
@Schema(description = "피드 당 항목 수", example = "5") int limit) {}
@Schema(description = "작성자 ID", example = "1") @Min(1) Long memberId,
@Schema(description = "피드 당 항목 수", example = "5") @Min(1) @Max(50) int limit) {}

0 comments on commit 7b78ae4

Please sign in to comment.