|
|
@ -1,5 +1,6 @@
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
package cn.estsh.i3plus.core.apiservice.controller.busi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysMessageService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserInfoService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserInfoService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
|
|
|
|
import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
@ -8,11 +9,9 @@ import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.ResourceEnumUtil;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.*;
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysRefUserRole;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysUser;
|
|
|
|
|
|
|
|
import cn.estsh.i3plus.pojo.platform.bean.SysUserInfo;
|
|
|
|
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
import cn.estsh.impp.framework.base.controller.CoreBaseController;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
@ -22,6 +21,7 @@ import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -49,6 +49,9 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ISysUserInfoService sysUserInfoService;
|
|
|
|
private ISysUserInfoService sysUserInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private ISysMessageService sysMessageService;
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/insert")
|
|
|
|
@PostMapping(value = "/insert")
|
|
|
|
@ApiOperation(value = "新增用户", notes = "新增系统用户")
|
|
|
|
@ApiOperation(value = "新增用户", notes = "新增系统用户")
|
|
|
|
public ResultBean insertSysUser(SysUser sysUser,String[] roleIds) {
|
|
|
|
public ResultBean insertSysUser(SysUser sysUser,String[] roleIds) {
|
|
|
@ -69,6 +72,9 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用户唯一校验
|
|
|
|
|
|
|
|
sysUserService.checkSysUserOnly(sysUser);
|
|
|
|
|
|
|
|
|
|
|
|
SysUserInfo userInfo = sysUserInfoService.getSysUserInfoById(sysUser.getUserInfoId());
|
|
|
|
SysUserInfo userInfo = sysUserInfoService.getSysUserInfoById(sysUser.getUserInfoId());
|
|
|
|
if(userInfo == null){
|
|
|
|
if(userInfo == null){
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
@ -83,6 +89,8 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
sysUser.setUserStatus(CommonEnumUtil.USER_STATUS.NORMAL.getValue());
|
|
|
|
sysUser.setUserStatus(CommonEnumUtil.USER_STATUS.NORMAL.getValue());
|
|
|
|
sysUser.setDepartmentId(userInfo.getDepartmentId());
|
|
|
|
sysUser.setDepartmentId(userInfo.getDepartmentId());
|
|
|
|
sysUser.setDepartmentNameRdd(userInfo.getDepartmentNameRdd());
|
|
|
|
sysUser.setDepartmentNameRdd(userInfo.getDepartmentNameRdd());
|
|
|
|
|
|
|
|
sysUser.setIsValid(CommonEnumUtil.TRUE_OR_FALSE.TRUE.getValue());
|
|
|
|
|
|
|
|
sysUser.setUserLoginNum(0);
|
|
|
|
ConvertBean.modelInitialize(sysUser,AuthUtil.getSessionUser());
|
|
|
|
ConvertBean.modelInitialize(sysUser,AuthUtil.getSessionUser());
|
|
|
|
|
|
|
|
|
|
|
|
SysUser user = sysUserService.insertSysUser(sysUser);
|
|
|
|
SysUser user = sysUserService.insertSysUser(sysUser);
|
|
|
@ -95,7 +103,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setResultObject(user);
|
|
|
|
.setResultObject(user);
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
@ -121,13 +129,8 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (sysUserService.checkLoginName(sysUser.getUserLoginName(), sysUser.getId())) {
|
|
|
|
// 用户唯一校验
|
|
|
|
throw ImppExceptionBuilder.newInstance()
|
|
|
|
sysUserService.checkSysUserOnly(sysUser);
|
|
|
|
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
|
|
|
|
|
|
|
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION.getCode())
|
|
|
|
|
|
|
|
.setErrorDetail("用户名已存在")
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用户信息封装
|
|
|
|
// 用户信息封装
|
|
|
|
SysUserInfo userInfo = sysUserService.getSysUserInfoById(sysUser.getUserInfoId());
|
|
|
|
SysUserInfo userInfo = sysUserService.getSysUserInfoById(sysUser.getUserInfoId());
|
|
|
@ -146,6 +149,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
user.setUserLoginPassword(md5);
|
|
|
|
user.setUserLoginPassword(md5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.setUserInfoId(userInfo.getId());
|
|
|
|
user.setUserName(userInfo.getName());
|
|
|
|
user.setUserName(userInfo.getName());
|
|
|
|
user.setDepartmentId(userInfo.getDepartmentId());
|
|
|
|
user.setDepartmentId(userInfo.getDepartmentId());
|
|
|
|
user.setDepartmentNameRdd(userInfo.getDepartmentNameRdd());
|
|
|
|
user.setDepartmentNameRdd(userInfo.getDepartmentNameRdd());
|
|
|
@ -163,7 +167,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setResultObject(user);
|
|
|
|
.setResultObject(user);
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
@ -182,7 +186,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
return new ResultBean(true);
|
|
|
|
return new ResultBean(true);
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
@ -204,7 +208,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
}catch(Exception e){
|
|
|
|
}catch(Exception e){
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
@ -225,7 +229,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
} catch(ImppBusiException busExcep){
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
}catch(Exception e){
|
|
|
|
}catch(Exception e){
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.BUSINESS_EXCEPTION_DATA_ERROR.getCode());
|
|
|
@ -242,7 +246,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setResultList(list);
|
|
|
|
.setResultList(list);
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
@ -265,16 +269,16 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
}catch(Exception e){
|
|
|
|
}catch(Exception e){
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
|
@DeleteMapping(value = "/delete/{id}")
|
|
|
|
@ApiOperation(value = "删除定时任务", notes = "删除定时任务")
|
|
|
|
@ApiOperation(value = "删除账号", notes = "删除制定账号信息")
|
|
|
|
public ResultBean delete(String id) {
|
|
|
|
public ResultBean delete(@PathVariable("id") String id) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 数据校验
|
|
|
|
// 数据校验
|
|
|
|
ValidatorBean.checkNotNull(id, "用户id 不能为空");
|
|
|
|
ValidatorBean.checkNotNull(id, "用户id 不能为空");
|
|
|
@ -283,7 +287,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
return ResultBean.success().setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
return ResultBean.success().setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
@ -308,7 +312,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
}catch(ImppBusiException busExcep){
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}",busExcep.getErrorDetail(),busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
}catch(Exception e){
|
|
|
|
}catch(Exception e){
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}",e.getMessage(),e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
@ -326,7 +330,50 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
.setResultList(list);
|
|
|
|
.setResultList(list);
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
return ResultBean.fail(busExcep.getErrorShow());
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("/reset-pwd/{id}")
|
|
|
|
|
|
|
|
@ApiOperation(value = "密码重置",notes = "根据id重置用户密码")
|
|
|
|
|
|
|
|
public ResultBean updateResetPassword(@PathVariable String id){
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
SysUser user = sysUserService.getSysUserById(Long.parseLong(id));
|
|
|
|
|
|
|
|
if(user != null){
|
|
|
|
|
|
|
|
String password = RandomStringUtils.random(6, true, false);
|
|
|
|
|
|
|
|
user.setUserLoginPassword(EncryptTool.hexMD5(password));
|
|
|
|
|
|
|
|
sysUserService.updateSysUser(user);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String content = "系统提示:\n" +
|
|
|
|
|
|
|
|
"\t"+getSessionUser().getUserName()+"使用密码重置功能帮您重置了【"+user.getUserLoginName()+"】账号的密码," +
|
|
|
|
|
|
|
|
"新密码是:"+password+"";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SysMessage message = new SysMessage();
|
|
|
|
|
|
|
|
message.setMessageTitle("重置密码");
|
|
|
|
|
|
|
|
message.setMessageContent(content);
|
|
|
|
|
|
|
|
message.setMessageType(ImppEnumUtil.MESSAGE_TYPE.MAIL.getValue());
|
|
|
|
|
|
|
|
message.setMessageContentType(ImppEnumUtil.MESSAGE_TYPE_CONTENT.TEXT.getValue());
|
|
|
|
|
|
|
|
message.setMessageSenderId(getSessionUser().getUser().getId());
|
|
|
|
|
|
|
|
message.setMessageSenderNameRdd(getSessionUser().getUserName());
|
|
|
|
|
|
|
|
message.setMessageReceiversId(user.getId().toString());
|
|
|
|
|
|
|
|
message.setMessageReceiversNameRdd(user.getUserName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sysMessageService.doSendSysMessage(message);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LOGGER.info("系统提示:{} 使用密码重置功能帮{}重置了{}账号的密码,新密码是:{}",
|
|
|
|
|
|
|
|
getSessionUser().getUserName(),user.getUserName(),user.getUserLoginName(),password);
|
|
|
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
return ResultBean.success("操作失败")
|
|
|
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode())
|
|
|
|
|
|
|
|
.setErrorMsg("用户不存在");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (ImppBusiException busExcep) {
|
|
|
|
|
|
|
|
LOGGER.error(busExcep.getErrorMsg() + ":{}", busExcep.getErrorDetail(), busExcep);
|
|
|
|
|
|
|
|
return ResultBean.fail(busExcep);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|