|
|
|
@ -6,6 +6,7 @@ import cn.estsh.i3plus.core.api.iservice.busi.ISysUserService;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.EncryptTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.tool.StringTool;
|
|
|
|
|
import cn.estsh.i3plus.platform.common.util.CommonConstWords;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.common.Pager;
|
|
|
|
|
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
|
|
|
@ -17,16 +18,19 @@ import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppBusiException;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
|
|
|
|
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ImppRedis;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ResultBean;
|
|
|
|
|
import cn.estsh.impp.framework.boot.util.ValidatorBean;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
|
|
import org.apache.commons.lang3.RandomStringUtils;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -43,6 +47,9 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
|
|
|
|
|
|
public static final Logger LOGGER = LoggerFactory.getLogger(SysUserController.class);
|
|
|
|
|
|
|
|
|
|
@Resource(name="redisCore")
|
|
|
|
|
private ImppRedis redisCore;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysUserService sysUserService;
|
|
|
|
|
|
|
|
|
@ -337,7 +344,7 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@DeleteMapping("/reset-pwd/{id}")
|
|
|
|
|
@PostMapping("/reset-pwd/{id}")
|
|
|
|
|
@ApiOperation(value = "密码重置",notes = "根据id重置用户密码")
|
|
|
|
|
public ResultBean updateResetPassword(@PathVariable String id){
|
|
|
|
|
try {
|
|
|
|
@ -380,4 +387,90 @@ public class SysUserController extends CoreBaseController{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/verification/get-email")
|
|
|
|
|
@ApiOperation(value = "发送验证码",notes = "发送邮件验证码")
|
|
|
|
|
public ResultBean getEmailVerification(String email){
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
SysUser user = sysUserService.getSysUserByEmail(email);
|
|
|
|
|
if(user != null){
|
|
|
|
|
String verification = RandomStringUtils.random(6, true, false);
|
|
|
|
|
|
|
|
|
|
String redisKey = CommonConstWords.SESSION_VERIFICATION_USER_EMAIL + "_" + getSessionUser().getUserId();
|
|
|
|
|
redisCore.putObject(redisKey, verification + "-" + email, 180);
|
|
|
|
|
|
|
|
|
|
String content = "系统提示:\n" +
|
|
|
|
|
"\t密码找回验证码:【"+verification+"】";
|
|
|
|
|
|
|
|
|
|
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("系统提示:\t 密码找回验证码【{}】",verification);
|
|
|
|
|
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) {
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/password/update-verification")
|
|
|
|
|
@ApiOperation(value = "修改密码",notes = "通过邮箱的验证码修改密码")
|
|
|
|
|
public ResultBean getEmailVerification(String password,String email,String verification){
|
|
|
|
|
try {
|
|
|
|
|
ValidatorBean.checkNotNull(verification,"验证码不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(password,"新密码不能为空");
|
|
|
|
|
ValidatorBean.checkNotNull(email,"邮件不能为空");
|
|
|
|
|
|
|
|
|
|
String redisKey = CommonConstWords.SESSION_VERIFICATION_USER_EMAIL + "_" + getSessionUser().getUserId();
|
|
|
|
|
Object redisValue = redisCore.getObject(redisKey);
|
|
|
|
|
if(redisValue != null){
|
|
|
|
|
if(redisValue.toString().indexOf(verification) >= 0 ){
|
|
|
|
|
if(redisValue.toString().indexOf(email) >= 0 ){
|
|
|
|
|
SysUser user = sysUserService.getSysUserByEmail(email);
|
|
|
|
|
user.setUserLoginPassword(EncryptTool.hexMD5(password));
|
|
|
|
|
sysUserService.updateSysUser(user);
|
|
|
|
|
return ResultBean.success("操作成功").setCode(ResourceEnumUtil.MESSAGE.SUCCESS.getCode());
|
|
|
|
|
}else {
|
|
|
|
|
return ResultBean.success("操作失败")
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode())
|
|
|
|
|
.setErrorMsg("请勿修改邮箱信息");
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
return ResultBean.success("操作失败")
|
|
|
|
|
.setCode(ResourceEnumUtil.MESSAGE.FAIL.getCode())
|
|
|
|
|
.setErrorMsg("验证码错误请重新输入");
|
|
|
|
|
}
|
|
|
|
|
}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) {
|
|
|
|
|
LOGGER.error(ImppExceptionEnum.SYSTEM_EXCEPTION.getDescription() + ":{}", e.getMessage(), e);
|
|
|
|
|
return ResultBean.fail().setCode(ImppExceptionEnum.SYSTEM_EXCEPTION.getCode());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|