Class BookController

java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.BookController

@RequestMapping("/api/books") @RestController public class BookController extends ApiController
  • Constructor Details

    • BookController

      public BookController()
  • Method Details

    • allBooks

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<Book> allBooks()
    • getById

      @PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Book getById(@RequestParam Long id)
    • postBook

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Book postBook(@RequestParam String title, @RequestParam String author, @RequestParam String year) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • deleteBook

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteBook(@RequestParam Long id)
    • updateBook

      @PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Book updateBook(@RequestParam Long id, @RequestBody @Valid @Valid Book incoming)