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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondeleteArticle
(Long id) Delete an ArticlepostArticles
(String title, String url, String explanation, String email, LocalDateTime dateAdded) updateaArticles
(Long id, @Valid Articles incoming) Update a single dateMethods inherited from class edu.ucsb.cs156.example.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
ArticlesController
public ArticlesController()
-
-
Method Details
-
allArticles
-
getById
-
postArticles
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public Articles postArticles(@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 - Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
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
-
updateaArticles
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public Articles updateaArticles(@RequestParam Long id, @RequestBody @Valid @Valid Articles incoming) Update a single date- Parameters:
id
- id of the date to updateincoming
- the new date- Returns:
- the updated date object
-