Package com.myfood.controllers
Class SlotController
java.lang.Object
com.myfood.controllers.SlotController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?>
deleteSlot
(Long id) Deletes an existing time slot based on the provided time slot ID.org.springframework.http.ResponseEntity<List<com.myfood.dto.Slot>>
Retrieves a list of all available time slots.org.springframework.http.ResponseEntity<List<com.myfood.dto.SlotUserDTO>>
Retrieves a list of available time slots for users.org.springframework.http.ResponseEntity<?>
getOneSlot
(Long id) Retrieves details of a specific time slot identified by its ID.org.springframework.http.ResponseEntity<com.myfood.dto.Slot>
saveSlot
(com.myfood.dto.Slot entity) Creates a new time slot based on the provided details.org.springframework.http.ResponseEntity<com.myfood.dto.Slot>
Scheduled task to reset the actual count of slots every day at 15:00.org.springframework.http.ResponseEntity<?>
updateSlot
(Long id, com.myfood.dto.Slot entity) Updates an existing time slot with the provided details.
-
Constructor Details
-
SlotController
public SlotController()
-
-
Method Details
-
getAllSlots
@PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/slots") public org.springframework.http.ResponseEntity<List<com.myfood.dto.Slot>> getAllSlots()Retrieves a list of all available time slots. It's for ADMIN.- Returns:
- ResponseEntity containing a list of
Slot
objects. - See Also:
-
SlotService#getAllSlots()
Slot
-
getOneSlot
@PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/slot/{id}") public org.springframework.http.ResponseEntity<?> getOneSlot(@PathVariable(name="id") Long id) Retrieves details of a specific time slot identified by its ID. It's for ADMIN- Parameters:
id
- The unique identifier of the time slot.- Returns:
- ResponseEntity containing the details of the time slot as a
Slot
object. - Throws:
DataNotFoundException
- If the specified time slot does not exist.- See Also:
-
SlotService#getOneSlot(Long)
Slot
-
saveSlot
@PreAuthorize("hasRole(\'ADMIN\')") @PostMapping("/slot") public org.springframework.http.ResponseEntity<com.myfood.dto.Slot> saveSlot(@RequestBody com.myfood.dto.Slot entity) Creates a new time slot based on the provided details. It's for ADMIN.- Parameters:
entity
- The time slot details provided in the request body.- Returns:
- ResponseEntity containing the details of the created time slot as a
Slot
object. - See Also:
-
SlotService#createSlot(Slot)
Slot
-
updateSlot
@PreAuthorize("hasRole(\'ADMIN\')") @PutMapping("/slot/{id}") public org.springframework.http.ResponseEntity<?> updateSlot(@PathVariable(name="id") Long id, @RequestBody com.myfood.dto.Slot entity) Updates an existing time slot with the provided details. It's for ADMIN.- Parameters:
id
- The identifier of the time slot to be updated.entity
- The updated time slot details provided in the request body.- Returns:
- ResponseEntity containing a message and the details of the updated
time slot as a
Slot
object. - See Also:
-
SlotService#getOneSlot(Long)
SlotService#updateSlot(Slot)
Slot
-
deleteSlot
@PreAuthorize("hasRole(\'ADMIN\')") @DeleteMapping("/slot/{id}") public org.springframework.http.ResponseEntity<?> deleteSlot(@PathVariable(name="id") Long id) Deletes an existing time slot based on the provided time slot ID. It's for ADMIN.- Parameters:
id
- The identifier of the time slot to be deleted.- Returns:
- ResponseEntity indicating the success or failure of the delete operation.
- See Also:
-
SlotService#getOneSlot(Long)
SlotService#deleteSlot(Long)
-
getAvailableSlots
@GetMapping("/slots/available") public org.springframework.http.ResponseEntity<List<com.myfood.dto.SlotUserDTO>> getAvailableSlots()Retrieves a list of available time slots for users. It's for USER.- Returns:
- ResponseEntity containing a list of SlotUserDTO representing available time slots.
- See Also:
-
SlotService#getAllSlots()
SlotUserDTO
-
updateSlot
@Scheduled(cron="0 0 15 * * ?", zone="Europe/Madrid") public org.springframework.http.ResponseEntity<com.myfood.dto.Slot> updateSlot()Scheduled task to reset the actual count of slots every day at 15:00. It's for SYSTEM.- Returns:
- ResponseEntity with status 204 (No Content) after updating the actual count of all slots.
- See Also:
-
Scheduled
SlotService#updateSlot(Slot)
-