Class RoleService

java.lang.Object
com.needleandstitch.pavuk.service.RoleService

@Service public class RoleService extends Object
Service layer for managing roles.

This class provides business logic for operations related to roles, such as retrieving, creating, updating, and deleting roles.

Usage:

  • Retrieve roles by ID or name
  • Create new roles
  • Update existing roles
  • Delete roles
Since:
15.12.2024
Version:
1.0.0
Author:
Needle & Stitch
  • Constructor Details

    • RoleService

      public RoleService()
  • Method Details

    • findByName

      @Transactional(readOnly=true) public Role findByName(String name)
      Finds a role by its name.
      Parameters:
      name - The name of the role to find
      Returns:
      The role with the specified name
      Throws:
      jakarta.persistence.EntityNotFoundException - if the role with the specified name is not found
    • findById

      @Transactional(readOnly=true) public Role findById(Long id)
      Finds a role by its ID.
      Parameters:
      id - The ID of the role to find
      Returns:
      The role with the specified ID
      Throws:
      jakarta.persistence.EntityNotFoundException - if the role is not found
    • findAll

      @Transactional(readOnly=true) public List<Role> findAll()
      Retrieves all roles.
      Returns:
      A list of all roles
    • createRole

      @Transactional public Role createRole(String name)
      Creates a new role.
      Parameters:
      name - The name of the role
      Returns:
      The newly created role
    • updateRole

      @Transactional public Role updateRole(Long id, String name)
      Updates an existing role.
      Parameters:
      id - The ID of the role to update
      name - The new name of the role
      Returns:
      The updated role
    • deleteRole

      @Transactional public void deleteRole(Long id)
      Deletes a role by its ID.
      Parameters:
      id - The ID of the role to delete
      Throws:
      jakarta.persistence.EntityNotFoundException - if the role is not found