Class ArticleController

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

@RequestMapping("/api/article") @RestController public class ArticleController extends ApiController
  • Constructor Details

    • ArticleController

      public ArticleController()
  • Method Details

    • postArticles

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public Article postArticles(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam("localDateTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime localDateTime) throws com.fasterxml.jackson.core.JsonProcessingException
      Throws:
      com.fasterxml.jackson.core.JsonProcessingException
    • allArticles

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("/all") public Iterable<Article> allArticles()
      List all article
      Returns:
      an iterable of Article
    • getById

      @PreAuthorize("hasRole('ROLE_USER')") @GetMapping("") public Article getById(@RequestParam Long id)
      Get a single date by id
      Parameters:
      id - the id of the date
      Returns:
      an article
    • updateArticle

      @PreAuthorize("hasRole('ROLE_ADMIN')") @PutMapping("") public Article updateArticle(@RequestParam Long id, @RequestBody @Valid @Valid Article incoming)
      Update a single date
      Parameters:
      id - id of the article to update
      incoming - the new article
      Returns:
      the updated date object
    • deleteArticle

      @PreAuthorize("hasRole('ROLE_ADMIN')") @DeleteMapping("") public Object deleteArticle(@RequestParam Long id)
      Delete an Article
      Parameters:
      id - the id of the article to delete
      Returns:
      a message indicating the article was deleted