|
|
@ -195,36 +195,7 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
@ApiOperation(value="查询用户信息",notes="复杂查询用户信息带分页")
|
|
|
|
@ApiOperation(value="查询用户信息",notes="复杂查询用户信息带分页")
|
|
|
|
public ResultBean querySysUserInfo(SysUserInfo userInfo, Pager pager){
|
|
|
|
public ResultBean querySysUserInfo(SysUserInfo userInfo, Pager pager){
|
|
|
|
try{
|
|
|
|
try{
|
|
|
|
List<Long> idList = new ArrayList<>();
|
|
|
|
ListPager<SysUserInfo> result = sysUserInfoService.querySysUserInfo(userInfo, packUserInfo(userInfo), pager);
|
|
|
|
if(userInfo.getOrganizeId() == null || userInfo.getOrganizeId() <= 0) {
|
|
|
|
|
|
|
|
if (AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
|
|
|
|
|
|
|
|
userInfo.setOrganizeCode(null);
|
|
|
|
|
|
|
|
userInfo.setOrganizeId(null);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
userInfo.setOrganizeId(AuthUtil.getOrganize().getId());
|
|
|
|
|
|
|
|
userInfo.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> departmentIdList = memTreeService.findDepartmentIdListByOrganizeIdAndDepartmentId(userInfo.getOrganizeId(), userInfo.getDepartmentId());
|
|
|
|
|
|
|
|
if(departmentIdList != null && departmentIdList.size() > 0){
|
|
|
|
|
|
|
|
List<SysRefUserInfoDepartment> refList = personnelService.findSysRefUserInfoDepartmentByDepartmentIdList(departmentIdList);
|
|
|
|
|
|
|
|
if(refList != null && refList.size() > 0){
|
|
|
|
|
|
|
|
refList.forEach(ref -> idList.add(ref.getUserId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(userInfo.getPositionId() != null && userInfo.getPositionId() > 0){
|
|
|
|
|
|
|
|
List<Long> refList = memTreeService.findSysPositionChildIdList(userInfo.getPositionId());
|
|
|
|
|
|
|
|
if(refList != null && refList.size() > 0){
|
|
|
|
|
|
|
|
List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionByIdList(refList);
|
|
|
|
|
|
|
|
if(refUserPositionList != null && refUserPositionList.size() > 0){
|
|
|
|
|
|
|
|
refUserPositionList.forEach(ref -> idList.add(ref.getUserId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ListPager<SysUserInfo> result = sysUserInfoService.querySysUserInfo(userInfo,idList, pager);
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setListPager(result).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
return ResultBean.success("操作成功").setListPager(result).setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
@ -406,10 +377,10 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/export")
|
|
|
|
@GetMapping("/export")
|
|
|
|
@ApiOperation(value = "导出用户信息",notes = "导出用户信息")
|
|
|
|
@ApiOperation(value = "导出用户信息",notes = "导出用户信息")
|
|
|
|
public void exportSysUserInfo(SysUserInfo sysUserInfo, HttpServletResponse response) throws Exception {
|
|
|
|
public void exportSysUserInfo(SysUserInfo userInfo, HttpServletResponse response) throws Exception {
|
|
|
|
File file = null;
|
|
|
|
File file = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
List<SysUserInfo> list = sysUserInfoService.findSysUserInfoList(sysUserInfo);
|
|
|
|
List<SysUserInfo> list = sysUserInfoService.querySysUserInfoList(userInfo, packUserInfo(userInfo));
|
|
|
|
Map<Long, SysUser> sysUserMap = sysUserService.list().stream()
|
|
|
|
Map<Long, SysUser> sysUserMap = sysUserService.list().stream()
|
|
|
|
.collect(Collectors.toMap(SysUser::getId, Function.identity()));
|
|
|
|
.collect(Collectors.toMap(SysUser::getId, Function.identity()));
|
|
|
|
List<UserExportModel> exportModelList = new ArrayList<>();
|
|
|
|
List<UserExportModel> exportModelList = new ArrayList<>();
|
|
|
@ -418,16 +389,16 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
UserExportModel userExportModel;
|
|
|
|
UserExportModel userExportModel;
|
|
|
|
List<SysRefUserRole> sysRefUserRoleList;
|
|
|
|
List<SysRefUserRole> sysRefUserRoleList;
|
|
|
|
StringBuilder roleName = new StringBuilder();
|
|
|
|
StringBuilder roleName = new StringBuilder();
|
|
|
|
for (SysUserInfo userInfo : list) {
|
|
|
|
for (SysUserInfo userInfoItem : list) {
|
|
|
|
// 关联角色信息
|
|
|
|
// 关联角色信息
|
|
|
|
sysRefUserRoleList = sysUserService.findSysRefUserRoleByUserId(userInfo.getUserId());
|
|
|
|
sysRefUserRoleList = sysUserService.findSysRefUserRoleByUserId(userInfoItem.getUserId());
|
|
|
|
for (SysRefUserRole sysRefUserRole : sysRefUserRoleList) {
|
|
|
|
for (SysRefUserRole sysRefUserRole : sysRefUserRoleList) {
|
|
|
|
roleName.append(sysRefUserRole.getRoleNameRdd()).append(",");
|
|
|
|
roleName.append(sysRefUserRole.getRoleNameRdd()).append(",");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
roleName.setLength(roleName.length() - 1);
|
|
|
|
roleName.setLength(roleName.length() - 1);
|
|
|
|
|
|
|
|
|
|
|
|
// 封装model
|
|
|
|
// 封装model
|
|
|
|
userExportModel = new UserExportModel(sysUserMap.get(userInfo.getUserId()), userInfo);
|
|
|
|
userExportModel = new UserExportModel(sysUserMap.get(userInfoItem.getUserId()), userInfoItem);
|
|
|
|
userExportModel.setRoleNameRdd(roleName.toString());
|
|
|
|
userExportModel.setRoleNameRdd(roleName.toString());
|
|
|
|
|
|
|
|
|
|
|
|
exportModelList.add(userExportModel);
|
|
|
|
exportModelList.add(userExportModel);
|
|
|
@ -461,4 +432,38 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<Long> packUserInfo(SysUserInfo userInfo){
|
|
|
|
|
|
|
|
ArrayList<Long> idList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (userInfo.getOrganizeId() == null || userInfo.getOrganizeId() <= 0) {
|
|
|
|
|
|
|
|
if (AuthUtil.getUserType().equals(CommonEnumUtil.USER_TYPE.ADMIN)) {
|
|
|
|
|
|
|
|
userInfo.setOrganizeCode(null);
|
|
|
|
|
|
|
|
userInfo.setOrganizeId(null);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
userInfo.setOrganizeId(AuthUtil.getOrganize().getId());
|
|
|
|
|
|
|
|
userInfo.setOrganizeCode(AuthUtil.getOrganize().getOrganizeCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<Long> departmentIdList = memTreeService.findDepartmentIdListByOrganizeIdAndDepartmentId(
|
|
|
|
|
|
|
|
userInfo.getOrganizeId(), userInfo.getDepartmentId()
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
if (departmentIdList != null && departmentIdList.size() > 0) {
|
|
|
|
|
|
|
|
List<SysRefUserInfoDepartment> refList = personnelService.findSysRefUserInfoDepartmentByDepartmentIdList(departmentIdList);
|
|
|
|
|
|
|
|
if (refList != null && refList.size() > 0) {
|
|
|
|
|
|
|
|
refList.forEach(ref -> idList.add(ref.getUserId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (userInfo.getPositionId() != null && userInfo.getPositionId() > 0) {
|
|
|
|
|
|
|
|
List<Long> refList = memTreeService.findSysPositionChildIdList(userInfo.getPositionId());
|
|
|
|
|
|
|
|
if (refList != null && refList.size() > 0) {
|
|
|
|
|
|
|
|
List<SysRefUserPosition> refUserPositionList = personnelService.findSysRefUserPositionByIdList(refList);
|
|
|
|
|
|
|
|
if (refUserPositionList != null && refUserPositionList.size() > 0) {
|
|
|
|
|
|
|
|
refUserPositionList.forEach(ref -> idList.add(ref.getUserId()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return idList;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|