Search in sources :

Example 1 with Role

use of com.vip.saturn.job.console.mybatis.entity.Role in project Saturn by vipshop.

the class AuthorizationManageServiceImpl method addUserRole.

@Transactional(rollbackFor = Exception.class)
@Override
public void addUserRole(UserRole userRole) throws SaturnJobConsoleException {
    validateUser(userRole);
    // check role is existing
    String roleKey = userRole.getRoleKey();
    Role role = roleRepository.selectByKey(roleKey);
    if (role == null) {
        throw new SaturnJobConsoleException(String.format("角色key(%s)不存在", roleKey));
    }
    // insert or update userRole
    UserRole pre = userRoleRepository.selectWithNotFilterDeleted(userRole);
    if (pre == null) {
        userRoleRepository.insert(userRole);
    } else {
        userRoleRepository.update(pre, userRole);
    }
}
Also used : UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) Role(com.vip.saturn.job.console.mybatis.entity.Role) UserRole(com.vip.saturn.job.console.mybatis.entity.UserRole) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)1 Role (com.vip.saturn.job.console.mybatis.entity.Role)1 UserRole (com.vip.saturn.job.console.mybatis.entity.UserRole)1 Transactional (org.springframework.transaction.annotation.Transactional)1