Skip to content

Commit 938c24f

Browse files
authored
Merge pull request #71 from MoCo-v2/feat/MOCO-122
feat : limit validation 적용
2 parents 651bb5f + b3f9ce5 commit 938c24f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/com/moco/moco/controller/PostController.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import org.springframework.http.HttpStatus;
88
import org.springframework.http.ResponseEntity;
9+
import org.springframework.validation.annotation.Validated;
910
import org.springframework.web.bind.annotation.DeleteMapping;
1011
import org.springframework.web.bind.annotation.GetMapping;
1112
import org.springframework.web.bind.annotation.PatchMapping;
@@ -23,12 +24,14 @@
2324
import com.moco.moco.service.post.PostService;
2425

2526
import jakarta.validation.Valid;
27+
import jakarta.validation.constraints.Max;
2628
import lombok.AllArgsConstructor;
2729
import lombok.extern.slf4j.Slf4j;
2830

2931
@Slf4j
3032
@AllArgsConstructor
3133
@RestController
34+
@Validated
3235
public class PostController {
3336
private final PostService postService;
3437

@@ -39,7 +42,7 @@ public class PostController {
3942
@GetMapping("/public/posts")
4043
public ResponseEntity<PostDto.Response> getPosts(
4144
@RequestParam(value = "offset", required = false, defaultValue = OFFSET) Integer offset,
42-
@RequestParam(value = "limit", required = false, defaultValue = LIMIT) Integer limit,
45+
@RequestParam(value = "limit", required = false, defaultValue = LIMIT) @Max(value = 100) Integer limit,
4346
@RequestParam(value = "recruit", required = false, defaultValue = RECRUIT) String recruit,
4447
@RequestParam(value = "username", required = false) String username,
4548
@RequestParam(value = "type", required = false) String type,
@@ -55,7 +58,7 @@ public ResponseEntity<PostDto.Response> getPosts(
5558
@GetMapping("/private/posts")
5659
public ResponseEntity<PostDto.Response> getMyBookmarkPosts(
5760
@RequestParam(value = "offset", required = false, defaultValue = OFFSET) Integer offset,
58-
@RequestParam(value = "limit", required = false, defaultValue = LIMIT) Integer limit,
61+
@RequestParam(value = "limit", required = false, defaultValue = LIMIT) @Max(100) Integer limit,
5962
@RequestParam(value = "recruit", required = false, defaultValue = RECRUIT) String recruit,
6063
@CurrentLoginUser UserInfo userInfo) {
6164
PostDto.Response postDto = postService.getMyBookmarkPosts(offset, limit, recruit, userInfo.getId());

0 commit comments

Comments
 (0)