|
|
|
@ -2,6 +2,7 @@ package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysDepartmentService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysFileService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysPositionService;
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserInfoService;
|
|
|
|
|
import cn.estsh.i3plus.core.apiservice.serviceimpl.busi.SysOrganizeService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
@ -10,9 +11,7 @@ import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysDepartment;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysUserInfo;
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
@ -56,6 +55,9 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysFileService sysFileService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysPositionService sysPositionService;
|
|
|
|
|
|
|
|
|
|
@PostMapping(value="/insert")
|
|
|
|
|
@ApiOperation(value="添加用户信息",notes="返回内容添加用户信息")
|
|
|
|
|
public ResultBean insertSysUserInfo(SysUserInfo userInfo){
|
|
|
|
@ -63,33 +65,24 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
//登陆用户
|
|
|
|
|
SessionUser user = AuthUtil.getSessionUser();
|
|
|
|
|
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.beginValid(userInfo)
|
|
|
|
|
.notNull("name",userInfo.getName())
|
|
|
|
|
.notNull("userEmpNo",userInfo.getUserEmpNo())
|
|
|
|
|
.checkNotZero("departmentId",userInfo.getDepartmentId())
|
|
|
|
|
.checkNotZero("departmentIdList",userInfo.getDepartmentIdList())
|
|
|
|
|
.checkNotZero("positionId",userInfo.getPositionId());
|
|
|
|
|
checkSysUserInfo(userInfo,false);
|
|
|
|
|
|
|
|
|
|
ConvertBean.modelInitialize(userInfo,user);
|
|
|
|
|
userInfo.setUserInfoStatus(CommonEnumUtil.USER_STATUS.ENABLE.getValue());
|
|
|
|
|
SysUserInfo pos = sysUserInfoService.insertSysUserInfo(userInfo);
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.refreshRefUserDepartment(pos.getId(),
|
|
|
|
|
SysUserInfo info = sysUserInfoService.insertSysUserInfo(userInfo);
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.refreshRefUserDepartment(info.getId(),
|
|
|
|
|
StringTool.getArrayLong(userInfo.getDepartmentIdList()),
|
|
|
|
|
user.getUserName());
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.refreshRefUserPosition(pos.getId(),
|
|
|
|
|
new Long[]{userInfo.getPositionId()},
|
|
|
|
|
sysUserInfoService.refreshRefUserPosition(info.getId(),
|
|
|
|
|
StringTool.getArrayLong(userInfo.getPositionIdList()),
|
|
|
|
|
user.getUserName());
|
|
|
|
|
|
|
|
|
|
SysDepartment department = departmentService.getSysDepartmentById(userInfo.getDepartmentId());
|
|
|
|
|
if(department != null){
|
|
|
|
|
sysUserInfoService.refreshRefUserOrganize(pos.getId(),
|
|
|
|
|
department.getOrganizeId(),user.getUserName());
|
|
|
|
|
}
|
|
|
|
|
sysUserInfoService.refreshRefUserOrganize(info.getId(), userInfo.getDepartment().getOrganizeId(),user.getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(pos);
|
|
|
|
|
return ResultBean.success("添加成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode()).setResultObject(info);
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
@ -106,13 +99,7 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
//登陆用户
|
|
|
|
|
SessionUser user = AuthUtil.getSessionUser();
|
|
|
|
|
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.beginValid(userInfo)
|
|
|
|
|
.notNull("id",userInfo.getId())
|
|
|
|
|
.notNull("name",userInfo.getName())
|
|
|
|
|
.notNull("userEmpNo",userInfo.getUserEmpNo())
|
|
|
|
|
.checkNotZero("departmentId",userInfo.getDepartmentId())
|
|
|
|
|
.checkNotZero("positionId",userInfo.getPositionId());
|
|
|
|
|
checkSysUserInfo(userInfo,true);
|
|
|
|
|
|
|
|
|
|
//修改初始化
|
|
|
|
|
ConvertBean.modelUpdate(userInfo,user);
|
|
|
|
@ -120,16 +107,14 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
sysUserInfoService.updateSysUserInfo(userInfo);
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.refreshRefUserDepartment(userInfo.getId(),
|
|
|
|
|
StringTool.getArrayLong(userInfo.getDepartmentIdList()), user.getUserName());
|
|
|
|
|
StringTool.getArrayLong(userInfo.getDepartmentIdList()),
|
|
|
|
|
user.getUserName());
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.refreshRefUserPosition(userInfo.getId(),
|
|
|
|
|
new Long[]{userInfo.getPositionId()}, user.getUserName());
|
|
|
|
|
StringTool.getArrayLong(userInfo.getPositionIdList()),
|
|
|
|
|
user.getUserName());
|
|
|
|
|
|
|
|
|
|
SysDepartment department = departmentService.getSysDepartmentById(userInfo.getDepartmentId());
|
|
|
|
|
if(department != null){
|
|
|
|
|
sysUserInfoService.refreshRefUserOrganize(userInfo.getId(),
|
|
|
|
|
department.getOrganizeId(),user.getUserName());
|
|
|
|
|
}
|
|
|
|
|
sysUserInfoService.refreshRefUserOrganize(userInfo.getId(), userInfo.getDepartment().getOrganizeId(),user.getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("修改成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
@ -237,4 +222,90 @@ public class SysUserInfoController extends CoreBaseController{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/find-ref-department/{userId}")
|
|
|
|
|
@ApiOperation(value = "查询角色的所有角色权限关系", notes = "查询角色的所有角色权限关系")
|
|
|
|
|
public ResultBean findRefDepartment(@PathVariable("userId") String userId) {
|
|
|
|
|
try {
|
|
|
|
|
ValidatorBean.checkNotNull(userId, "用户 id 不能为空");
|
|
|
|
|
List<SysRefUserDepartment> list = sysUserInfoService.findRefUserDepartmentByUserId(Long.parseLong(userId));
|
|
|
|
|
return ResultBean.success("操作成功")
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
|
.setResultList(list);
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping(value = "/find-ref-position/{userId}")
|
|
|
|
|
@ApiOperation(value = "查询角色的所有角色权限关系", notes = "查询角色的所有角色权限关系")
|
|
|
|
|
public ResultBean findRefPosition(@PathVariable("userId") String userId) {
|
|
|
|
|
try {
|
|
|
|
|
ValidatorBean.checkNotNull(userId, "用户 id 不能为空");
|
|
|
|
|
List<SysRefUserPosition> list = sysUserInfoService.findSysRefUserPositionByUserId(Long.parseLong(userId));
|
|
|
|
|
return ResultBean.success("操作成功")
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode())
|
|
|
|
|
.setResultList(list);
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 用户唯一信息校验
|
|
|
|
|
* @param userInfo
|
|
|
|
|
* @param isId 是否检查ID 存在
|
|
|
|
|
*/
|
|
|
|
|
private void checkSysUserInfo(SysUserInfo userInfo,boolean isId){
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.beginValid(userInfo)
|
|
|
|
|
.notNull("name",userInfo.getName())
|
|
|
|
|
.notNull("userEmpNo",userInfo.getUserEmpNo())
|
|
|
|
|
.checkNotZero("departmentId",userInfo.getDepartmentId())
|
|
|
|
|
.checkNotZero("departmentIdList",userInfo.getDepartmentIdList())
|
|
|
|
|
.checkNotZero("positionId",userInfo.getPositionId());
|
|
|
|
|
if(isId){
|
|
|
|
|
ValidatorBean.beginValid(userInfo)
|
|
|
|
|
.notNull("id",userInfo.getId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysDepartment department = departmentService.getSysDepartmentById(userInfo.getDepartmentId());
|
|
|
|
|
if(department == null){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("主部门信息不存在。")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysPosition position = sysPositionService.getSysPositionById(userInfo.getPositionId());
|
|
|
|
|
if(position == null){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("主岗位信息不存在。")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sysUserInfoService.checkSysUserInfoOnly(userInfo);
|
|
|
|
|
|
|
|
|
|
userInfo.setDepartmentNameRdd(department.getName());
|
|
|
|
|
userInfo.setPositionNameRdd(position.getName());
|
|
|
|
|
userInfo.setDepartment(department);
|
|
|
|
|
userInfo.setPosition(position);
|
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
|
}catch(Exception e){
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|