Class ArticlesController
java.lang.Object
edu.ucsb.cs156.example.controllers.ApiController
edu.ucsb.cs156.example.controllers.ArticlesController
@RequestMapping("/api/articles")
@RestController
public class ArticlesController
extends ApiController
This is a REST controller for Articles
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionList all articlesGet a single article by idpostArticle(String title, String url, String explanation, String email, LocalDateTime dateAdded) Create a new articleupdateArticle(Long id, @Valid Article incoming) Update a single articleMethods inherited from class ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
ArticlesController
public ArticlesController()
-
-
Method Details
-
allArticles
-
postArticle
@PreAuthorize("hasRole('ROLE_ADMIN')") @PostMapping("/post") public Article postArticle(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam("dateAdded") @DateTimeFormat(iso=DATE_TIME) LocalDateTime dateAdded) throws com.fasterxml.jackson.core.JsonProcessingException Create a new article- Parameters:
title- the title of the articleurl- the url of the articleexplanation- an explanation of the articleemail- the email of the person who submitted the articledateAdded- the date the article was published (YYYY-mm-dd)- Returns:
- the saved article
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
getById
-
updateArticle
-