Class RoleController
java.lang.Object
com.needleandstitch.pavuk.controller.RoleController
REST controller for managing Role objects.
This class provides endpoints for handling role-related operations such as retrieving roles, creating new roles, updating existing roles, and deleting roles.
Endpoints:
- GET /roles Retrieve all roles
- GET /roles/{id} Retrieve a role by its ID
- GET /roles/name/{name} Retrieve a role by its name
- POST /roles Create a new role
- PUT /roles/{id} Update an existing role
- DELETE /roles/{id} Delete a role
- Since:
- 15.12.2024
- Version:
- 1.0.0
- Author:
- Needle & Stitch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity
<Role> createRole
(Role role) Creates a new role.org.springframework.http.ResponseEntity
<Void> deleteRole
(Long id) Deletes a role by its ID.Retrieves all roles.org.springframework.http.ResponseEntity
<Role> getRoleById
(Long id) Retrieves a role by its ID.org.springframework.http.ResponseEntity
<Role> getRoleByName
(String name) Retrieves a role by its name.org.springframework.http.ResponseEntity
<Role> updateRole
(Long id, Role role) Updates an existing role's name.
-
Constructor Details
-
RoleController
public RoleController()
-
-
Method Details
-
getAllRoles
-
getRoleById
-
getRoleByName
@GetMapping("/name/{name}") public org.springframework.http.ResponseEntity<Role> getRoleByName(@PathVariable String name) Retrieves a role by its name.- Parameters:
name
- The name of the role to retrieve- Returns:
- A ResponseEntity with a 200 OK status with a role if successful, or a 404 Not Found status if not.
-
createRole
-
updateRole
@PutMapping("/{id}") public org.springframework.http.ResponseEntity<Role> updateRole(@PathVariable Long id, @RequestBody Role role) Updates an existing role's name.- Parameters:
id
- The ID of the role to updaterole
- The updated role object- Returns:
- A ResponseEntity with a 200 OK status if successful, or a 404 Not Found status if not.
-
deleteRole
-