Class UCSBDatesController
java.lang.Object
edu.ucsb.cs156.dining.controllers.ApiController
edu.ucsb.cs156.dining.controllers.UCSBDatesController
@RequestMapping("/api/ucsbdates")
@RestController
public class UCSBDatesController
extends ApiController
This is a REST controller for UCSBDates
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionList all UCSB datesdeleteUCSBDate
(Long id) Delete a UCSBDateGet a single date by idpostUCSBDate
(String quarterYYYYQ, String name, LocalDateTime localDateTime) Create a new dateupdateUCSBDate
(Long id, @Valid UCSBDate incoming) Update a single dateMethods inherited from class edu.ucsb.cs156.dining.controllers.ApiController
genericMessage, getCurrentUser, handleGenericException
-
Constructor Details
-
UCSBDatesController
public UCSBDatesController()
-
-
Method Details
-
allUCSBDates
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("/all") public Iterable<UCSBDate> allUCSBDates()List all UCSB dates- Returns:
- an iterable of UCSBDate
-
getById
@PreAuthorize("hasRole(\'ROLE_USER\')") @GetMapping("") public UCSBDate getById(@RequestParam Long id) Get a single date by id- Parameters:
id
- the id of the date- Returns:
- a UCSBDate
-
postUCSBDate
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PostMapping("/post") public UCSBDate postUCSBDate(@RequestParam String quarterYYYYQ, @RequestParam String name, @RequestParam("localDateTime") @DateTimeFormat(iso=DATE_TIME) LocalDateTime localDateTime) throws com.fasterxml.jackson.core.JsonProcessingException Create a new date- Parameters:
quarterYYYYQ
- the quarter in the format YYYYQname
- the name of the datelocalDateTime
- the date- Returns:
- the saved ucsbdate
- Throws:
com.fasterxml.jackson.core.JsonProcessingException
-
deleteUCSBDate
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @DeleteMapping("") public Object deleteUCSBDate(@RequestParam Long id) Delete a UCSBDate- Parameters:
id
- the id of the date to delete- Returns:
- a message indicating the date was deleted
-
updateUCSBDate
@PreAuthorize("hasRole(\'ROLE_ADMIN\')") @PutMapping("") public UCSBDate updateUCSBDate(@RequestParam Long id, @RequestBody @Valid @Valid UCSBDate incoming) Update a single date- Parameters:
id
- id of the date to updateincoming
- the new date- Returns:
- the updated date object
-