|
|
|
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.constant.CacheConstants;
|
|
|
|
|
import com.ruoyi.common.redis.service.RedisService;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
@ -32,7 +35,7 @@ import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户 业务层处理
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
@ -61,9 +64,12 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
@Autowired
|
|
|
|
|
protected Validator validator;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private RedisService redisService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件分页查询用户列表
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 用户信息集合信息
|
|
|
|
|
*/
|
|
|
|
@ -76,7 +82,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件分页查询已分配用户角色列表
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 用户信息集合信息
|
|
|
|
|
*/
|
|
|
|
@ -89,7 +95,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件分页查询未分配用户角色列表
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 用户信息集合信息
|
|
|
|
|
*/
|
|
|
|
@ -102,7 +108,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过用户名查询用户
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名
|
|
|
|
|
* @return 用户对象信息
|
|
|
|
|
*/
|
|
|
|
@ -114,7 +120,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过用户ID查询用户
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userId 用户ID
|
|
|
|
|
* @return 用户对象信息
|
|
|
|
|
*/
|
|
|
|
@ -126,7 +132,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询用户所属角色组
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -143,7 +149,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询用户所属岗位组
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -160,7 +166,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验用户名称是否唯一
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名称
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -213,7 +219,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验用户是否允许操作
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
@ -227,7 +233,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验用户是否有数据权限
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userId 用户id
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
@ -247,7 +253,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增保存用户信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -266,7 +272,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 注册用户信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -278,7 +284,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改保存用户信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -300,7 +306,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户授权角色
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userId 用户ID
|
|
|
|
|
* @param roleIds 角色组
|
|
|
|
|
*/
|
|
|
|
@ -314,7 +320,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改用户状态
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -326,7 +332,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改用户基本信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -338,7 +344,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改用户头像
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名
|
|
|
|
|
* @param avatar 头像地址
|
|
|
|
|
* @return 结果
|
|
|
|
@ -351,19 +357,22 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重置用户密码
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int resetPwd(SysUser user)
|
|
|
|
|
{
|
|
|
|
|
// 重置密码的时候,同步删除 登录错误次数 缓存
|
|
|
|
|
redisService.deleteObject(CacheConstants.REDIS_KEY_ERROR_TIMES + user.getUserName());
|
|
|
|
|
|
|
|
|
|
return userMapper.updateUser(user);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重置用户密码
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userName 用户名
|
|
|
|
|
* @param password 密码
|
|
|
|
|
* @return 结果
|
|
|
|
@ -371,12 +380,15 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
@Override
|
|
|
|
|
public int resetUserPwd(String userName, String password)
|
|
|
|
|
{
|
|
|
|
|
// 重置密码的时候,同步删除 登录错误次数 缓存
|
|
|
|
|
redisService.deleteObject(CacheConstants.REDIS_KEY_ERROR_TIMES + userName);
|
|
|
|
|
|
|
|
|
|
return userMapper.resetUserPwd(userName, password);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户角色信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户对象
|
|
|
|
|
*/
|
|
|
|
|
public void insertUserRole(SysUser user)
|
|
|
|
@ -402,7 +414,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户岗位信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param user 用户对象
|
|
|
|
|
*/
|
|
|
|
|
public void insertUserPost(SysUser user)
|
|
|
|
@ -428,7 +440,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增用户角色信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userId 用户ID
|
|
|
|
|
* @param roleIds 角色组
|
|
|
|
|
*/
|
|
|
|
@ -454,7 +466,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过用户ID删除用户
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userId 用户ID
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -471,7 +483,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除用户信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userIds 需要删除的用户ID
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -493,7 +505,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入用户数据
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param userList 用户数据列表
|
|
|
|
|
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
|
|
|
|
* @param operName 操作用户
|
|
|
|
|