| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 用户授权角色
|
| | | * |
| | | * @param userId 用户ID
|
| | | * @param roleIds 角色组
|
| | | */
|
| | | public void insertUserAuth(Long userId, Long[] roleIds)
|
| | | {
|
| | | userRoleMapper.deleteUserRoleByUserId(userId);
|
| | | insertUserRole(userId, roleIds);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 修改用户状态
|
| | | *
|
| | | * @param user 用户信息
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 新增用户角色信息
|
| | | * |
| | | * @param userId 用户ID
|
| | | * @param roleIds 角色组
|
| | | */
|
| | | public void insertUserRole(Long userId, Long[] roleIds)
|
| | | {
|
| | | if (StringUtils.isNotNull(roleIds))
|
| | | {
|
| | | // 新增用户与角色管理
|
| | | List<SysUserRole> list = new ArrayList<SysUserRole>();
|
| | | for (Long roleId : roleIds)
|
| | | {
|
| | | SysUserRole ur = new SysUserRole();
|
| | | ur.setUserId(userId);
|
| | | ur.setRoleId(roleId);
|
| | | list.add(ur);
|
| | | }
|
| | | if (list.size() > 0)
|
| | | {
|
| | | userRoleMapper.batchUserRole(list);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 通过用户ID删除用户
|
| | | *
|
| | | * @param userId 用户ID
|
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int deleteUserById(Long userId)
|
| | | {
|
| | | // 删除用户与角色关联
|
| | |
| | | * @return 结果
|
| | | */
|
| | | @Override
|
| | | @Transactional
|
| | | public int deleteUserByIds(Long[] userIds)
|
| | | {
|
| | | for (Long userId : userIds)
|
| | | {
|
| | | checkUserAllowed(new SysUser(userId));
|
| | | }
|
| | | // 删除用户与角色关联
|
| | | userRoleMapper.deleteUserRole(userIds);
|
| | | // 删除用户与岗位关联
|
| | | userPostMapper.deleteUserPost(userIds);
|
| | | return userMapper.deleteUserByIds(userIds);
|
| | | }
|
| | |
|