| | |
| | | package com.ruoyi.project.system.service.impl;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Collections;
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | | import javax.validation.Validator;
|
| | |
|
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
| | | import com.ruoyi.project.system.domain.*;
|
| | | import com.ruoyi.project.system.mapper.*;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.CollectionUtils;
|
| | | import com.ruoyi.common.constant.UserConstants;
|
| | | import com.ruoyi.common.exception.ServiceException;
|
| | | import com.ruoyi.common.utils.SecurityUtils;
|
| | |
| | | import com.ruoyi.common.utils.bean.BeanValidators;
|
| | | import com.ruoyi.common.utils.spring.SpringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
|
| | | import com.ruoyi.project.system.domain.*;
|
| | | import com.ruoyi.project.system.mapper.*;
|
| | | import com.ruoyi.project.system.service.ISysConfigService;
|
| | | import com.ruoyi.project.system.service.ISysDeptService;
|
| | | import com.ruoyi.project.system.service.ISysUserService;
|
| | | import jakarta.validation.Validator;
|
| | | import lombok.RequiredArgsConstructor;
|
| | | import org.slf4j.Logger;
|
| | | import org.slf4j.LoggerFactory;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.springframework.util.CollectionUtils;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | | import java.util.stream.Collectors;
|
| | |
|
| | | /**
|
| | | * 用户 业务层处理
|
| | | * |
| | | *
|
| | | * @author ruoyi
|
| | | */
|
| | | @Service
|
| | | @RequiredArgsConstructor
|
| | | public class SysUserServiceImpl implements ISysUserService
|
| | | {
|
| | | @Autowired
|
| | | private SysUserDeptMapper sysUserDeptMapper;
|
| | |
|
| | | private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
| | |
|
| | | @Autowired
|
| | | private SysUserMapper userMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysRoleMapper roleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysPostMapper postMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysUserRoleMapper userRoleMapper;
|
| | |
|
| | | @Autowired
|
| | | private SysUserPostMapper userPostMapper;
|
| | |
|
| | | @Autowired
|
| | | private ISysConfigService configService;
|
| | |
|
| | | @Autowired
|
| | | private ISysDeptService deptService;
|
| | |
|
| | | @Autowired
|
| | | protected Validator validator;
|
| | | private final SysUserDeptMapper sysUserDeptMapper;
|
| | | private final SysUserMapper userMapper;
|
| | | private final SysRoleMapper roleMapper;
|
| | | private final SysPostMapper postMapper;
|
| | | private final SysUserRoleMapper userRoleMapper;
|
| | | private final SysUserPostMapper userPostMapper;
|
| | | private final ISysConfigService configService;
|
| | | protected final Validator validator;
|
| | |
|
| | | /**
|
| | | * 根据条件分页查询用户列表
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 用户信息集合信息
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 根据条件分页查询已分配用户角色列表
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 用户信息集合信息
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 根据条件分页查询未分配用户角色列表
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 用户信息集合信息
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 通过用户名查询用户
|
| | | * |
| | | *
|
| | | * @param userName 用户名
|
| | | * @return 用户对象信息
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 通过用户ID查询用户
|
| | | * |
| | | *
|
| | | * @param userId 用户ID
|
| | | * @return 用户对象信息
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 查询用户所属角色组
|
| | | * |
| | | *
|
| | | * @param userName 用户名
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 查询用户所属岗位组
|
| | | * |
| | | *
|
| | | * @param userName 用户名
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 校验用户名称是否唯一
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 校验用户是否允许操作
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | */
|
| | | @Override
|
| | |
| | |
|
| | | /**
|
| | | * 校验用户是否有数据权限
|
| | | * |
| | | *
|
| | | * @param userId 用户id
|
| | | */
|
| | | @Override
|
| | |
| | |
|
| | | /**
|
| | | * 新增保存用户信息
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 注册用户信息
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 修改保存用户信息
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 用户授权角色
|
| | | * |
| | | *
|
| | | * @param userId 用户ID
|
| | | * @param roleIds 角色组
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 修改用户状态
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 修改用户基本信息
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 修改用户头像
|
| | | * |
| | | *
|
| | | * @param userName 用户名
|
| | | * @param avatar 头像地址
|
| | | * @return 结果
|
| | |
| | |
|
| | | /**
|
| | | * 重置用户密码
|
| | | * |
| | | *
|
| | | * @param user 用户信息
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 重置用户密码
|
| | | * |
| | | *
|
| | | * @param userName 用户名
|
| | | * @param password 密码
|
| | | * @return 结果
|
| | |
| | |
|
| | | /**
|
| | | * 新增用户角色信息
|
| | | * |
| | | *
|
| | | * @param user 用户对象
|
| | | */
|
| | | public void insertUserRole(SysUser user)
|
| | |
| | |
|
| | | /**
|
| | | * 新增用户岗位信息
|
| | | * |
| | | *
|
| | | * @param user 用户对象
|
| | | */
|
| | | public void insertUserPost(SysUser user)
|
| | |
| | |
|
| | | /**
|
| | | * 新增用户角色信息
|
| | | * |
| | | *
|
| | | * @param userId 用户ID
|
| | | * @param roleIds 角色组
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 通过用户ID删除用户
|
| | | * |
| | | *
|
| | | * @param userId 用户ID
|
| | | * @return 结果
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 批量删除用户信息
|
| | | * |
| | | *
|
| | | * @param userIds 需要删除的用户ID
|
| | | * @return 结果
|
| | | */
|
| | |
| | | userRoleMapper.deleteUserRole(userIds);
|
| | | // 删除用户与岗位关联
|
| | | userPostMapper.deleteUserPost(userIds);
|
| | | // 删除用户与部门数据
|
| | | sysUserDeptMapper.delete(new LambdaQueryWrapper<SysUserDept>()
|
| | | .in(SysUserDept::getUserId, userIds));
|
| | | return userMapper.deleteUserByIds(userIds);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 导入用户数据
|
| | | * |
| | | *
|
| | | * @param userList 用户数据列表
|
| | | * @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
|
| | | * @param operName 操作用户
|
| | |
| | | }
|
| | |
|
| | | /**
|
| | | * 查询角色为teamLeader的用户列表(不分页)
|
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<SysUser> selectTeamLeaderUserList() {
|
| | | return userMapper.selectTeamLeaderUserList();
|
| | | }
|
| | |
|
| | | /**
|
| | | * 绑定用户部门
|
| | | * @param user
|
| | | * @return
|