Search in sources :

Example 1 with UserRole

use of com.dimple.project.system.domain.UserRole in project DimpleBlog by martin-chips.

the class UserServiceImpl method insertUserRole.

public void insertUserRole(SysUser user) {
    Long[] roles = user.getRoleIds();
    if (StringUtils.isNotNull(roles)) {
        // 新增用户与角色管理
        List<UserRole> list = new ArrayList<>();
        for (Long roleId : roles) {
            UserRole ur = new UserRole();
            ur.setUserId(user.getId());
            ur.setRoleId(roleId);
            list.add(ur);
        }
        if (!list.isEmpty()) {
            userRoleMapper.batchUserRole(list);
        }
    }
}
Also used : UserRole(com.dimple.project.system.domain.UserRole) ArrayList(java.util.ArrayList)

Aggregations

UserRole (com.dimple.project.system.domain.UserRole)1 ArrayList (java.util.ArrayList)1