Class AdminPostManagementController

java.lang.Object
io.github.navjotsrakhra.eventmanager.controller.AdminPostManagementController

@RestController @RequestMapping("/admin/events") public class AdminPostManagementController extends Object
The AdminPostManagementController class handles HTTP requests related to event posts by admin users.
  • Constructor Details

    • AdminPostManagementController

      public AdminPostManagementController(EventPostEditService eventPostEditService, EventPostGetService eventPostGetService)
      Constructor for the AdminPostManagementController class.
      Parameters:
      eventPostEditService - Service for editing event posts.
      eventPostGetService -
  • Method Details

    • getAllEvents

      @GetMapping public org.springframework.http.ResponseEntity<org.springframework.data.domain.Page<EventPostAdminDTO>> getAllEvents(@PageableDefault(size=5,sort="postedAt",direction=DESC) org.springframework.data.domain.Pageable pageable)
    • deleteEventPost

      @DeleteMapping("/delete/{id}") public org.springframework.http.ResponseEntity<?> deleteEventPost(@PathVariable Long id)
      Handles DELETE requests for the "/admin/events/delete/{id}" URL to delete an event post.
      Parameters:
      id - The ID of the event post to delete.
      Returns:
      ResponseEntity indicating the result of the deletion operation.
    • editEventPost

      @PostMapping("/edit/{id}") public org.springframework.http.ResponseEntity<?> editEventPost(@PathVariable Long id, @RequestBody EventPostDTO eventPostDTO) throws DateValidationFailedException
      Handles POST requests for the "/admin/events/edit/{id}" URL to edit an event post.
      Parameters:
      id - The ID of the event post to edit.
      eventPostDTO - The updated event post data.
      Returns:
      ResponseEntity indicating the result of the update operation.
      Throws:
      DateValidationFailedException - Thrown if the event post's start date is after its end date.
    • handleDateValidationFailedException

      @ExceptionHandler(DateValidationFailedException.class) public org.springframework.http.ResponseEntity<?> handleDateValidationFailedException(DateValidationFailedException e)
      Handles exceptions thrown by the EventPostEditService class.
      Parameters:
      e - The exception thrown.
      Returns:
      ResponseEntity containing the exception message.