|
|
|
@ -4,46 +4,41 @@ import apelet.common.core.annotation.MyRequestBody; |
|
|
|
import apelet.common.core.constant.ErrorCodeEnum; |
|
|
|
import apelet.common.core.constant.ErrorCodeEnum; |
|
|
|
import apelet.common.core.exception.MyRuntimeException; |
|
|
|
import apelet.common.core.exception.MyRuntimeException; |
|
|
|
import apelet.common.core.object.*; |
|
|
|
import apelet.common.core.object.*; |
|
|
|
import apelet.common.core.upload.*; |
|
|
|
import apelet.common.core.upload.BaseUpDownloader; |
|
|
|
|
|
|
|
import apelet.common.core.upload.UpDownloaderFactory; |
|
|
|
|
|
|
|
import apelet.common.core.upload.UploadResponseInfo; |
|
|
|
|
|
|
|
import apelet.common.core.upload.UploadStoreInfo; |
|
|
|
import apelet.common.core.util.MyCommonUtil; |
|
|
|
import apelet.common.core.util.MyCommonUtil; |
|
|
|
import apelet.common.core.util.MyModelUtil; |
|
|
|
import apelet.common.core.util.MyModelUtil; |
|
|
|
import apelet.common.core.util.MyPageUtil; |
|
|
|
import apelet.common.core.util.MyPageUtil; |
|
|
|
import apelet.common.eas.service.impl.EASSyncService; |
|
|
|
|
|
|
|
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
|
|
|
import apelet.common.generator.utils.OrmGenDataSourceUtil; |
|
|
|
import apelet.common.log.annotation.OperationLog; |
|
|
|
import apelet.common.log.annotation.OperationLog; |
|
|
|
import apelet.common.log.model.constant.SysOperationLogType; |
|
|
|
import apelet.common.log.model.constant.SysOperationLogType; |
|
|
|
import apelet.common.redis.cache.SessionCacheHelper; |
|
|
|
import apelet.common.redis.cache.SessionCacheHelper; |
|
|
|
import apelet.common.sequence.wrapper.IdGeneratorWrapper; |
|
|
|
|
|
|
|
import apelet.tenantadmin.config.ApplicationConfig; |
|
|
|
import apelet.tenantadmin.config.ApplicationConfig; |
|
|
|
|
|
|
|
import apelet.tenantadmin.upms.dto.RoleDeptItemDto; |
|
|
|
import apelet.tenantadmin.upms.dto.SysUserDto; |
|
|
|
import apelet.tenantadmin.upms.dto.SysUserDto; |
|
|
|
import apelet.tenantadmin.upms.model.SysUser; |
|
|
|
import apelet.tenantadmin.upms.model.SysUser; |
|
|
|
import apelet.tenantadmin.upms.service.SysUserService; |
|
|
|
import apelet.tenantadmin.upms.service.SysUserService; |
|
|
|
import apelet.tenantadmin.upms.vo.SysDeptVo; |
|
|
|
|
|
|
|
import apelet.tenantadmin.upms.vo.SysUserVo; |
|
|
|
import apelet.tenantadmin.upms.vo.SysUserVo; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
import cn.hutool.core.util.ReflectUtil; |
|
|
|
import cn.hutool.core.util.ReflectUtil; |
|
|
|
import com.alibaba.fastjson.*; |
|
|
|
import com.alibaba.fastjson.TypeReference; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
import com.github.pagehelper.page.PageMethod; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob; |
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag; |
|
|
|
import javafx.concurrent.Task; |
|
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.redisson.api.RLock; |
|
|
|
|
|
|
|
import org.redisson.api.RedissonClient; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.security.crypto.password.PasswordEncoder; |
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.LinkedList; |
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
|
import java.util.List; |
|
|
|
import java.util.concurrent.Executors; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 用户管理操作控制器类。 |
|
|
|
* 用户管理操作控制器类。 |
|
|
|
@ -75,7 +70,7 @@ public class SysUserController { |
|
|
|
* @param deptPostIdListString 逗号分隔的部门岗位Id列表。 |
|
|
|
* @param deptPostIdListString 逗号分隔的部门岗位Id列表。 |
|
|
|
* @param dataPermIdListString 逗号分隔的数据权限Id列表。 |
|
|
|
* @param dataPermIdListString 逗号分隔的数据权限Id列表。 |
|
|
|
* @param roleIdListString 逗号分隔的角色Id列表。 |
|
|
|
* @param roleIdListString 逗号分隔的角色Id列表。 |
|
|
|
* @param deptIdListString 逗号分隔的组织Id列表。 |
|
|
|
* @param deptIdListString 逗号分隔的组织Id列表(可选,写入SysUserRole.deptId)。 |
|
|
|
* @return 应答结果对象,包含新增用户的主键Id。 |
|
|
|
* @return 应答结果对象,包含新增用户的主键Id。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ApiOperationSupport(ignoreParameters = { |
|
|
|
@ApiOperationSupport(ignoreParameters = { |
|
|
|
@ -100,16 +95,12 @@ public class SysUserController { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
|
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
if (result.getData().containsKey("deptIdSet")) { |
|
|
|
if (result.getData().containsKey("deptIdSet")) { |
|
|
|
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>() { |
|
|
|
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
sysUserService.saveNew(sysUser, roleIdSet, deptPostIdSet, dataPermIdSet, deptIdSet); |
|
|
|
sysUserService.saveNew(sysUser, roleIdSet, deptPostIdSet, dataPermIdSet, deptIdSet); |
|
|
|
return ResponseResult.success(sysUser.getUserId()); |
|
|
|
return ResponseResult.success(sysUser.getUserId()); |
|
|
|
@ -139,12 +130,9 @@ public class SysUserController { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
|
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
SysUser sysUserO = sysUserService.saveNew(sysUser, roleIdSet, deptPostIdSet, dataPermIdSet, null); |
|
|
|
SysUser sysUserO = sysUserService.saveNew(sysUser, roleIdSet, deptPostIdSet, dataPermIdSet, null); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
@ -172,7 +160,7 @@ public class SysUserController { |
|
|
|
* @param deptPostIdListString 逗号分隔的部门岗位Id列表。 |
|
|
|
* @param deptPostIdListString 逗号分隔的部门岗位Id列表。 |
|
|
|
* @param dataPermIdListString 逗号分隔的数据权限Id列表。 |
|
|
|
* @param dataPermIdListString 逗号分隔的数据权限Id列表。 |
|
|
|
* @param roleIdListString 逗号分隔的角色Id列表。 |
|
|
|
* @param roleIdListString 逗号分隔的角色Id列表。 |
|
|
|
* @param deptIdListString 逗号分隔的组织Id列表。 |
|
|
|
* @param deptIdListString 逗号分隔的组织Id列表(可选,写入SysUserRole.deptId)。 |
|
|
|
* @return 应答结果对象。 |
|
|
|
* @return 应答结果对象。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ApiOperationSupport(ignoreParameters = { |
|
|
|
@ApiOperationSupport(ignoreParameters = { |
|
|
|
@ -200,16 +188,12 @@ public class SysUserController { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
if (!result.isSuccess()) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> roleIdSet = result.getData().getObject("roleIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
Set<Long> deptPostIdSet = result.getData().getObject("deptPostIdSet", new TypeReference<Set<Long>>() { |
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
|
|
|
|
Set<Long> dataPermIdSet = result.getData().getObject("dataPermIdSet", new TypeReference<Set<Long>>() { |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
Set<Long> deptIdSet = null; |
|
|
|
if (result.getData().containsKey("deptIdSet")) { |
|
|
|
if (result.getData().containsKey("deptIdSet")) { |
|
|
|
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>() { |
|
|
|
deptIdSet = result.getData().getObject("deptIdSet", new TypeReference<Set<Long>>(){}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (!sysUserService.update(sysUser, originalUser, roleIdSet, deptPostIdSet, dataPermIdSet, deptIdSet)) { |
|
|
|
if (!sysUserService.update(sysUser, originalUser, roleIdSet, deptPostIdSet, dataPermIdSet, deptIdSet)) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST); |
|
|
|
@ -218,6 +202,31 @@ public class SysUserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 分配用户组织角色。 |
|
|
|
|
|
|
|
* 先删除用户原有的角色关联(xy_sys_user_role),再按 roleDeptList 逐条写入。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userId 用户Id。 |
|
|
|
|
|
|
|
* @param roleDeptList 角色-组织关联列表,每项含 roleId/deptId(均可为空,roleId 为空则跳过)。 |
|
|
|
|
|
|
|
* @return 应答结果对象。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@OperationLog(type = SysOperationLogType.UPDATE) |
|
|
|
|
|
|
|
@PostMapping("/assignRoleDept") |
|
|
|
|
|
|
|
public ResponseResult<Void> assignRoleDept(@MyRequestBody Long userId, @MyRequestBody List<RoleDeptItemDto> roleDeptList) { |
|
|
|
|
|
|
|
if (MyCommonUtil.existBlankArgument(userId)) { |
|
|
|
|
|
|
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!sysUserService.existId(userId)) { |
|
|
|
|
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_NOT_EXIST, "用户不存在,请刷新后重试!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
CallResult result = sysUserService.verifyRoleDeptMap(roleDeptList); |
|
|
|
|
|
|
|
if (!result.isSuccess()) { |
|
|
|
|
|
|
|
return ResponseResult.error(ErrorCodeEnum.DATA_VALIDATED_FAILED, result.getErrorMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
sysUserService.assignRoleDept(userId, roleDeptList); |
|
|
|
|
|
|
|
return ResponseResult.success(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 删除用户管理数据。 |
|
|
|
* 删除用户管理数据。 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param userId 删除对象主键Id。 |
|
|
|
* @param userId 删除对象主键Id。 |
|
|
|
@ -498,18 +507,18 @@ public class SysUserController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询用户关联的组织列表(用于编辑页回显)。 |
|
|
|
* 查询所有组织及其下角色列表,并标记用户是否拥有该角色。 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param userId 用户Id。 |
|
|
|
* @param userId 用户Id。 |
|
|
|
* @return 应答结果对象,包含用户关联的组织列表。 |
|
|
|
* @return 应答结果对象,包含组织-角色树及用户勾选状态。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@GetMapping("/listUserDept") |
|
|
|
@GetMapping("/listUserDept") |
|
|
|
public ResponseResult<List<SysDeptVo>> listUserDept(@RequestParam Long userId) { |
|
|
|
public ResponseResult<List<Map<String, Object>>> listUserDept(@RequestParam Long userId) { |
|
|
|
if (MyCommonUtil.existBlankArgument(userId)) { |
|
|
|
if (MyCommonUtil.existBlankArgument(userId)) { |
|
|
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
|
|
|
return ResponseResult.error(ErrorCodeEnum.ARGUMENT_NULL_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
List<SysDeptVo> deptVoList = sysUserService.listUserDept(userId); |
|
|
|
List<Map<String, Object>> result = sysUserService.listUserDept(userId); |
|
|
|
return ResponseResult.success(deptVoList); |
|
|
|
return ResponseResult.success(result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ResponseResult<Void> doDelete(Long userId) { |
|
|
|
private ResponseResult<Void> doDelete(Long userId) { |
|
|
|
|