Skip to content

Instantly share code, notes, and snippets.

@b1a9id

b1a9id/SakeController.java Secret

Created Sep 13, 2020
Embed
What would you like to do?
springdoc-openapiサンプルのSakeController.java
@RestController
@RequestMapping("/sakes")
@RequiredArgsConstructor
public class SakeController {
private final SakeService sakeService;
@GetMapping
public Page<SakeResponse> page(@PageableDefault Pageable pageable) {
return sakeService.page(pageable);
}
@GetMapping("list")
public List<SakeResponse> list() {
return sakeService.list();
}
@GetMapping("{id}")
public SakeResponse get(@PathVariable Integer id) {
return sakeService.get(id);
}
@PostMapping
public SakeResponse create(@RequestBody @Validated SakeCreateRequest request) {
return sakeService.create(request);
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(NotFoundException.class)
public ResponseEntity<ErrorResponse> handleException(NotFoundException e) {
return ResponseEntity.of(Optional.of(new ErrorResponse(e.getMessage())));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.