Class RolController

java.lang.Object
com.myfood.controllers.RolController

@RestController @RequestMapping("api/v1") public class RolController extends Object
Controller class for handling role-related operations. This controller provides endpoints for basic CRUD operations on roles.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Void>
    Delete a role.
    org.springframework.http.ResponseEntity<List<com.myfood.dto.Role>>
    Handles HTTP GET requests to retrieve a list of all roles.
    org.springframework.http.ResponseEntity<com.myfood.dto.Role>
    Retrieve a specific role by its ID.
    org.springframework.http.ResponseEntity<?>
    saveRole(com.myfood.dto.Role entity)
    Create a new role.
    org.springframework.http.ResponseEntity<com.myfood.dto.Role>
    updateRole(Long id, com.myfood.dto.Role entity)
    Update an existing role.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RolController

      public RolController()
  • Method Details

    • getAllRole

      @PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/roles") public org.springframework.http.ResponseEntity<List<com.myfood.dto.Role>> getAllRole()
      Handles HTTP GET requests to retrieve a list of all roles.
      Returns:
      ResponseEntity with a list of roles and an HTTP status code.
    • getOneRole

      @PreAuthorize("hasRole(\'ADMIN\')") @GetMapping("/role/{id}") public org.springframework.http.ResponseEntity<com.myfood.dto.Role> getOneRole(@PathVariable(name="id") Long id)
      Retrieve a specific role by its ID.
      Parameters:
      id - The ID of the role to retrieve.
      Returns:
      ResponseEntity containing the requested role or a 404 response if not found.
    • saveRole

      @PreAuthorize("hasRole(\'ADMIN\')") @PostMapping("/role") public org.springframework.http.ResponseEntity<?> saveRole(@RequestBody com.myfood.dto.Role entity)
      Create a new role.
      Parameters:
      entity - The role to be created.
      Returns:
      ResponseEntity containing the created role.
    • updateRole

      @PreAuthorize("hasRole(\'ADMIN\')") @PutMapping("/role/{id}") public org.springframework.http.ResponseEntity<com.myfood.dto.Role> updateRole(@PathVariable(name="id") Long id, @RequestBody com.myfood.dto.Role entity)
      Update an existing role.
      Parameters:
      id - The ID of the role to update.
      entity - The updated role.
      Returns:
      ResponseEntity containing the updated role or a 404 response if not found.
    • deleteRole

      @PreAuthorize("hasRole(\'ADMIN\')") @DeleteMapping("/role/{id}") public org.springframework.http.ResponseEntity<Void> deleteRole(@PathVariable(name="id") Long id)
      Delete a role.
      Parameters:
      id - The ID of the role to delete.
      Returns:
      ResponseEntity indicating success or a 404 response if the role is not found.