forked from hanghae-skillup/redis_1st
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowingController.java
More file actions
44 lines (37 loc) · 1.52 KB
/
ShowingController.java
File metadata and controls
44 lines (37 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package module.controller;
import java.util.List;
import org.hibernate.validator.constraints.Range;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import dto.movie.MovieShowingResponse;
import jakarta.annotation.Nullable;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Size;
import lombok.RequiredArgsConstructor;
import module.config.ratelimit.limiters.ShowingSearchRateLimiter;
import module.config.ratelimit.RateLimitWith;
import module.service.showing.ShowingService;
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "/api/v1/showings")
public class ShowingController {
private final ShowingService showingService;
@GetMapping("/all")
@RateLimitWith(rateLimiter = ShowingSearchRateLimiter.class)
public ResponseEntity<List<MovieShowingResponse>> getTodayShowing(
@Valid @Size(max = 10, message = "제목 최대 길이는 255자 이내 입니다.")
@Nullable @RequestParam String title,
@Valid @Range(min = 2, max = 10, message = "존재하지 않는 장르 입니다.")
@Nullable @RequestParam Long genreId
) {
List<MovieShowingResponse> allShowingList = showingService.getTodayShowing(title, genreId);
if (allShowingList.isEmpty()) {
return ResponseEntity.noContent().build();
} else {
return ResponseEntity.ok(allShowingList);
}
}
}