|
|
@@ -1,5 +1,6 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
@@ -12,6 +13,10 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.dromara.backstage.api.RemotePtParameterService;
|
|
|
+import org.dromara.backstage.api.RemoteUserAccountService;
|
|
|
+import org.dromara.backstage.api.domain.bo.RemoteUserAccountBo;
|
|
|
import org.dromara.common.core.constant.CacheNames;
|
|
|
import org.dromara.common.core.constant.UserConstants;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
@@ -25,15 +30,16 @@ import org.dromara.common.mybatis.helper.DataBaseHelper;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.system.domain.SysDept;
|
|
|
import org.dromara.system.domain.SysUser;
|
|
|
-import org.dromara.system.domain.SysUserPost;
|
|
|
import org.dromara.system.domain.SysUserRole;
|
|
|
import org.dromara.system.domain.bo.SysUserBo;
|
|
|
+import org.dromara.system.domain.bo.UserDeptBo;
|
|
|
import org.dromara.system.domain.vo.SysPostVo;
|
|
|
import org.dromara.system.domain.vo.SysRoleVo;
|
|
|
import org.dromara.system.domain.vo.SysUserExportVo;
|
|
|
import org.dromara.system.domain.vo.SysUserVo;
|
|
|
import org.dromara.system.mapper.*;
|
|
|
import org.dromara.system.service.ISysUserService;
|
|
|
+import org.dromara.system.service.IUserDeptService;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -58,7 +64,12 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
private final SysRoleMapper roleMapper;
|
|
|
private final SysPostMapper postMapper;
|
|
|
private final SysUserRoleMapper userRoleMapper;
|
|
|
- private final SysUserPostMapper userPostMapper;
|
|
|
+ private final IUserDeptService userDeptService;
|
|
|
+
|
|
|
+ @DubboReference
|
|
|
+ private final RemotePtParameterService remotePtParameterService;
|
|
|
+ private final RemoteUserAccountService remoteUserAccountService;
|
|
|
+ //private final RemoteUserAccountService remoteUserAccountService;
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<SysUserVo> selectPageUserList(SysUserBo user, PageQuery pageQuery) {
|
|
|
@@ -83,6 +94,7 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
|
|
.eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId())
|
|
|
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
|
|
+ .like(StringUtils.isNotBlank(user.getRealName()), "u.real_name", user.getRealName())
|
|
|
.eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus())
|
|
|
.like(StringUtils.isNotBlank(user.getPhone()), "u.phone", user.getPhone())
|
|
|
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
|
|
@@ -310,10 +322,17 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
user.setUserId(sysUser.getUserId());
|
|
|
}
|
|
|
// 新增用户岗位关联
|
|
|
- //insertUserPost(user, false);
|
|
|
- insertUserDept(user,false);
|
|
|
+ insertUserDept(user);
|
|
|
// 新增用户与角色管理
|
|
|
insertUserRole(user, false);
|
|
|
+ String autoUserAccount = remotePtParameterService.getPtParameterByKey("AUTO_CREATE_BAG");
|
|
|
+ RemoteUserAccountBo remoteUserAccountBo = BeanUtil.copyProperties(user, RemoteUserAccountBo.class);
|
|
|
+ //if("1".equals(autoUserAccount)){
|
|
|
+ //
|
|
|
+ //} else {
|
|
|
+ remoteUserAccountBo.setAccountStatus("0");
|
|
|
+ //remoteUserAccountService.insertByBo(remoteUserAccountBo);
|
|
|
+ //}
|
|
|
return rows;
|
|
|
}
|
|
|
|
|
|
@@ -344,8 +363,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
public int updateUser(SysUserBo user) {
|
|
|
// 新增用户与角色管理
|
|
|
insertUserRole(user, true);
|
|
|
- // 新增用户与岗位管理
|
|
|
- insertUserPost(user, true);
|
|
|
+ // 新增用户部门岗位管理
|
|
|
+ insertUserDept(user);
|
|
|
SysUser sysUser = MapstructUtils.convert(user, SysUser.class);
|
|
|
// 防止错误更新后导致的数据误删除
|
|
|
int flag = baseMapper.updateById(sysUser);
|
|
|
@@ -440,30 +459,6 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
this.insertUserRole(user.getUserId(), user.getRoleIds(), clear);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 新增用户岗位信息
|
|
|
- *
|
|
|
- * @param user 用户对象
|
|
|
- * @param clear 清除已存在的关联数据
|
|
|
- */
|
|
|
- private void insertUserPost(SysUserBo user, boolean clear) {
|
|
|
- Long[] posts = user.getPostIds();
|
|
|
- if (ArrayUtil.isNotEmpty(posts)) {
|
|
|
- if (clear) {
|
|
|
- // 删除用户与岗位关联
|
|
|
- userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, user.getUserId()));
|
|
|
- }
|
|
|
- // 新增用户与岗位管理
|
|
|
- List<SysUserPost> list = StreamUtils.toList(List.of(posts), postId -> {
|
|
|
- SysUserPost up = new SysUserPost();
|
|
|
- up.setUserId(user.getUserId());
|
|
|
- up.setPostId(postId);
|
|
|
- return up;
|
|
|
- });
|
|
|
- userPostMapper.insertBatch(list);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 新增用户角色信息
|
|
|
*
|
|
|
@@ -513,7 +508,11 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
// 删除用户与角色关联
|
|
|
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
|
|
// 删除用户与岗位表
|
|
|
- userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, userId));
|
|
|
+ UserDeptBo userDeptBo = new UserDeptBo();
|
|
|
+ userDeptBo.setUserId(userId);
|
|
|
+ userDeptBo.setMainDept("N");
|
|
|
+ userDeptService.deleteByBo(userDeptBo);
|
|
|
+
|
|
|
// 防止更新失败导致的数据删除
|
|
|
int flag = baseMapper.deleteById(userId);
|
|
|
if (flag < 1) {
|
|
|
@@ -538,8 +537,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
List<Long> ids = List.of(userIds);
|
|
|
// 删除用户与角色关联
|
|
|
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
|
|
|
- // 删除用户与岗位表
|
|
|
- userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
|
|
|
+ // 删除用户部门表
|
|
|
+ userDeptService.deleteByUserIds(List.of(userIds));
|
|
|
// 防止更新失败导致的数据删除
|
|
|
int flag = baseMapper.deleteByIds(ids);
|
|
|
if (flag < 1) {
|
|
|
@@ -635,8 +634,12 @@ public class SysUserServiceImpl implements ISysUserService {
|
|
|
return ObjectUtil.isNull(sysUser) ? null : sysUser.getEmail();
|
|
|
}
|
|
|
|
|
|
- private void insertUserDept(SysUserBo bo,Boolean clear){
|
|
|
- Long deptId = bo.getDeptId();
|
|
|
+ private void insertUserDept(SysUserBo bo){
|
|
|
+ UserDeptBo userDeptBo = new UserDeptBo();
|
|
|
+ userDeptBo.setDeptId(bo.getDeptId());
|
|
|
+ userDeptBo.setPostId(bo.getPostId());
|
|
|
+ userDeptBo.setUserId(bo.getUserId());
|
|
|
|
|
|
+ userDeptService.setUserDeptPost(userDeptBo);
|
|
|
}
|
|
|
}
|