|
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.user;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.io.IoUtil;
|
|
import cn.hutool.core.io.IoUtil;
|
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
import cn.iocoder.yudao.framework.common.exception.ServiceException;
|
|
@@ -36,7 +37,6 @@ import cn.iocoder.yudao.module.system.service.permission.PermissionService;
|
|
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
|
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.collect.ImmutableMap;
|
|
import com.google.common.collect.ImmutableMap;
|
|
-import com.google.common.collect.Lists;
|
|
|
|
import com.mzt.logapi.context.LogRecordContext;
|
|
import com.mzt.logapi.context.LogRecordContext;
|
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
|
import com.mzt.logapi.service.impl.DiffParseFunction;
|
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
|
import com.mzt.logapi.starter.annotation.LogRecord;
|
|
@@ -185,6 +185,8 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
return user.getId();
|
|
return user.getId();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Long registerUser(AuthRegisterReqVO registerReqVO) {
|
|
public Long registerUser(AuthRegisterReqVO registerReqVO) {
|
|
// 1.1 校验账户配合
|
|
// 1.1 校验账户配合
|
|
@@ -346,7 +348,7 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
|
|
permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null;
|
|
|
|
|
|
// 分页查询
|
|
// 分页查询
|
|
- return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds);
|
|
|
|
|
|
+ return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId(), null), userIds);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -413,13 +415,24 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
* @param deptId 部门编号
|
|
* @param deptId 部门编号
|
|
* @return 部门编号集合
|
|
* @return 部门编号集合
|
|
*/
|
|
*/
|
|
- private Set<Long> getDeptCondition(Long deptId) {
|
|
|
|
- if (deptId == null) {
|
|
|
|
|
|
+ private Set<Long> getDeptCondition(Long deptId, List<Long> deptIdList) {
|
|
|
|
+ if (deptId == null && CollUtil.isEmpty(deptIdList)) {
|
|
return Collections.emptySet();
|
|
return Collections.emptySet();
|
|
}
|
|
}
|
|
- Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
|
|
|
|
- deptIds.add(deptId); // 包括自身
|
|
|
|
- return deptIds;
|
|
|
|
|
|
+ Set<Long> resultDeptIds = new HashSet<>();
|
|
|
|
+ if (ObjUtil.isNotEmpty(deptId)) {
|
|
|
|
+ Set<Long> deptIds = convertSet(deptService.getChildDeptList(deptId), DeptDO::getId);
|
|
|
|
+ deptIds.add(deptId); // 包括自身
|
|
|
|
+ resultDeptIds.addAll(deptIds);
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(deptIdList)) {
|
|
|
|
+ deptIdList.forEach(departmentId -> {
|
|
|
|
+ Set<Long> deptIds = convertSet(deptService.getChildDeptList(departmentId), DeptDO::getId);
|
|
|
|
+ deptIds.add(departmentId);
|
|
|
|
+ resultDeptIds.addAll(deptIds);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ return resultDeptIds;
|
|
}
|
|
}
|
|
|
|
|
|
private AdminUserDO validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
|
|
private AdminUserDO validateUserForCreateOrUpdate(Long id, String username, String mobile, String email,
|
|
@@ -595,7 +608,26 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public List<AdminUserDO> getSimpleUserList(UserPageReqVO reqVO) {
|
|
public List<AdminUserDO> getSimpleUserList(UserPageReqVO reqVO) {
|
|
- return userMapper.selectSimpleList(getDeptCondition(reqVO.getDeptId()));
|
|
|
|
|
|
+ return userMapper.selectSimpleList(getDeptCondition(reqVO.getDeptId(), reqVO.getDeptIds()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Long batchSetUserPwd() {
|
|
|
|
+ // 查询出用户密码为空 的所有 用户 设置加密密码后 更新
|
|
|
|
+ List<AdminUserDO> emptyPwdUsers = userMapper.selectEmptyPwd();
|
|
|
|
+ AdminUserDO tobeUpdatedUser = new AdminUserDO();
|
|
|
|
+ if (CollUtil.isNotEmpty(emptyPwdUsers)) {
|
|
|
|
+ emptyPwdUsers.forEach(user -> {
|
|
|
|
+ // if ("0031890".equals(user.getUsername())) {
|
|
|
|
+ user.setPassword(encodePassword("yf654321"));
|
|
|
|
+ // System.out.println("当前用户是" + user.getUsername());
|
|
|
|
+ // BeanUtils.copyProperties(user, tobeUpdatedUser);
|
|
|
|
+ // }
|
|
|
|
+ });
|
|
|
|
+ // userMapper.updateById(tobeUpdatedUser);
|
|
|
|
+ userMapper.updateBatch(emptyPwdUsers);
|
|
|
|
+ }
|
|
|
|
+ return 0l;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|