use of org.codenergic.theskeleton.role.RoleNotFoundException in project theskeleton by codenergic.
the class PrivilegeServiceImpl method addPrivilegeToRole.
@Override
@Transactional
public RoleEntity addPrivilegeToRole(String code, String privilegeName) {
RoleEntity role = roleRepository.findByCode(code).orElseThrow(() -> new RoleNotFoundException(code));
PrivilegeEntity privilege = privilegeRepository.findByName(privilegeName).orElseThrow(() -> new PrivilegeNotFoundException(privilegeName));
return rolePrivilegeRepository.save(new RolePrivilegeEntity(role, privilege)).getRole();
}
Aggregations