|
|
|
@ -61,6 +61,8 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
checkUserDetailModel(model, false);
|
|
|
|
|
personnelService.checkSysUserOnly(user);
|
|
|
|
|
|
|
|
|
|
initUserDetail(info,user);
|
|
|
|
|
|
|
|
|
|
SysDepartment infoDepartment = personnelService.getSysDepartmentById(Long.parseLong(model.getInfoDepartmentId()));
|
|
|
|
|
if(infoDepartment == null){
|
|
|
|
|
ValidatorBean.checkNotNull(infoDepartment,"用户主部门不存在");
|
|
|
|
@ -92,7 +94,7 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
user.setOrganizeNameRdd(userOrganize.getName());
|
|
|
|
|
user.setOrganizeCode(userOrganize.getOrganizeCode());
|
|
|
|
|
user.setUserInfoId(info.getId());
|
|
|
|
|
user.setUserLoginPassword(EncryptTool.hexMD5(user.getUserLoginPassword()));
|
|
|
|
|
refreshSysUserPassword(user);
|
|
|
|
|
personnelService.saveSysUser(user);
|
|
|
|
|
|
|
|
|
|
info.setUserId(user.getId());
|
|
|
|
@ -143,6 +145,9 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
info.setDepartmentNameRdd(infoDepartment.getName());
|
|
|
|
|
info.setOrganizeId(infoOrganize.getId());
|
|
|
|
|
info.setOrganizeNameRdd(infoOrganize.getName());
|
|
|
|
|
info.setOrganizeCode(infoOrganize.getOrganizeCode());
|
|
|
|
|
info.setPositionId(position.getId());
|
|
|
|
|
info.setPositionNameRdd(position.getName());
|
|
|
|
|
|
|
|
|
|
user.setDepartmentId(userDepartment.getId());
|
|
|
|
|
user.setDepartmentNameRdd(userDepartment.getName());
|
|
|
|
@ -151,6 +156,8 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
|
|
|
|
|
// 关系 刷新
|
|
|
|
|
refreshRef(user, info, model);
|
|
|
|
|
// 更新 密码
|
|
|
|
|
refreshSysUserPassword(user);
|
|
|
|
|
|
|
|
|
|
personnelService.saveSysUser(user);
|
|
|
|
|
personnelService.saveSysUserInfo(info);
|
|
|
|
@ -265,6 +272,71 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(value="/user/delete/{id}")
|
|
|
|
|
@ApiOperation(value="删除账号信息",notes="根据账号信息id删除信息")
|
|
|
|
|
public ResultBean deleteSysUser(@PathVariable("id") String id){
|
|
|
|
|
try {
|
|
|
|
|
//条件验证
|
|
|
|
|
ValidatorBean.checkNotNull(id,"id为空");
|
|
|
|
|
|
|
|
|
|
SysUser user = personnelService.getSysUserById(Long.parseLong(id));
|
|
|
|
|
if(user != null){
|
|
|
|
|
personnelService.deleteSysUserInfo(new Long[]{user.getUserInfoId()},getSessionUser().getUserName());
|
|
|
|
|
personnelService.deleteSysUser(new Long[]{user.getId()},getSessionUser().getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("删除成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}else{
|
|
|
|
|
return ResultBean.fail("数据不存在").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
|
|
|
|
|
}
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(value = "/user/batch-delete")
|
|
|
|
|
@ApiOperation(value = "根据id批量删除", notes = "根据id批量删除")
|
|
|
|
|
public ResultBean deleteSysUserByIds(String[] ids){
|
|
|
|
|
try{
|
|
|
|
|
ids = ConvertBean.modelSafeArrayNumber(ids,true);
|
|
|
|
|
if(ids.length == 0){
|
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
.setErrorDetail("请选择需要删除的用户信息。")
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<SysUser> list = personnelService.findSysUserByIds(StringTool.getArrayLong(ids));
|
|
|
|
|
|
|
|
|
|
if(list != null && list.size() > 0){
|
|
|
|
|
Long[] infoIds = new Long[list.size()];
|
|
|
|
|
Long[] userIds = new Long[list.size()];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
|
infoIds[i] = list.get(i).getUserInfoId();
|
|
|
|
|
userIds[i] = list.get(i).getId();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
personnelService.deleteSysUserInfo(infoIds,getSessionUser().getUserName());
|
|
|
|
|
personnelService.deleteSysUser(userIds,getSessionUser().getUserName());
|
|
|
|
|
|
|
|
|
|
return ResultBean.success("删除成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}else{
|
|
|
|
|
return ResultBean.fail("数据不存在").setCode(ResourceEnumUtil.MESSAGE.EMPTY.getCode());
|
|
|
|
|
}
|
|
|
|
|
}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 model
|
|
|
|
@ -303,6 +375,7 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
|
|
|
|
|
info.setUserInfoStatus(CommonEnumUtil.USER_INFO_STATUS.INCUMBENT.getValue());
|
|
|
|
|
info.setUserLoginNum(0);
|
|
|
|
|
info.setIsValid(CommonEnumUtil.IS_VAILD.VAILD.getValue());
|
|
|
|
|
ConvertBean.modelInitialize(info, AuthUtil.getSessionUser());
|
|
|
|
|
|
|
|
|
|
user.setUserType(CommonEnumUtil.USER_TYPE.USER.getValue());
|
|
|
|
@ -329,4 +402,23 @@ public class PersonnelController extends CoreBaseController {
|
|
|
|
|
// 刷新用户 岗位关系
|
|
|
|
|
personnelService.refreshRefSysUserInfoPosition(info.getId(),StringTool.getArrayLong(model.getInfoPositionIdList()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新用户密码
|
|
|
|
|
* @param user
|
|
|
|
|
*/
|
|
|
|
|
private void refreshSysUserPassword(SysUser user)throws Exception{
|
|
|
|
|
if(user != null){
|
|
|
|
|
if(user.getId() != null){ // 更新密码
|
|
|
|
|
if(!StringUtils.isAnyBlank(user.getUserLoginPassword())){ // 使用新密码
|
|
|
|
|
user.setUserLoginPassword(EncryptTool.hexMD5(user.getUserLoginPassword()));
|
|
|
|
|
}else{ //使用旧密码
|
|
|
|
|
SysUser sysUser = personnelService.getSysUserById(user.getId());
|
|
|
|
|
user.setUserLoginPassword(sysUser.getUserLoginPassword());
|
|
|
|
|
}
|
|
|
|
|
}else { // 创建密码
|
|
|
|
|
user.setUserLoginPassword(EncryptTool.hexMD5(user.getUserLoginPassword()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|