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 TypeMethodDescriptionThis method returns a list of all articles.deleteArticle(Long id) Delete an ArticleThis method returns a single article.postArticle(String title, String url, String explanation, String email, LocalDateTime dateAdded) Create a new articleupdateArticle(Long id, @Valid Articles incoming) Update a single articleMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException 
- 
Constructor Details
- 
ArticlesController
public ArticlesController() 
 - 
 - 
Method Details
- 
allArticles
This method returns a list of all articles.- Returns:
 - a list of all articles
 
 - 
postArticle
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Articles postArticle(@RequestParam String title, @RequestParam String url, @RequestParam String explanation, @RequestParam String email, @RequestParam LocalDateTime dateAdded) Create a new article- Parameters:
 title- the title of the articleurl- the URL of the articleexplanation- a brief explanation of the articleemail- the email of the person who submitted the articledateAdded- the date the article was added- Returns:
 - the saved Articles object
 
 - 
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public Articles getById(@RequestParam Long id) This method returns a single article.- Parameters:
 id- id of the article to get- Returns:
 - a single article
 
 - 
updateArticle
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Articles updateArticle(@RequestParam Long id, @RequestBody @Valid @Valid Articles incoming) Update a single article- Parameters:
 id- id of the article to updateincoming- the new article- Returns:
 - the updated article 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
 
 
 -