忘记密码

hehai
mzh820631607 4 years ago
parent ab00ca858e
commit 02f4836109
  1. 2
      src/main/java/com/msdw/tms/api/UserInfoControllerApi.java
  2. 4
      src/main/java/com/msdw/tms/config/EmailUtils.java
  3. 17
      src/main/java/com/msdw/tms/service/impl/UserInfoServiceImpl.java

@ -30,7 +30,7 @@ public interface UserInfoControllerApi {
@ApiOperation(value = "发送验证码",notes = "发送验证码") @ApiOperation(value = "发送验证码",notes = "发送验证码")
R findPassword(@ApiParam(value = "账号",required = true) String account, R findPassword(@ApiParam(value = "账号",required = true) String account,
@ApiParam(value = "发送类型(1手机,2邮箱)",required = true) Integer type); @ApiParam(value = "发送类型(1邮箱,2手机)",required = true) Integer type);
@ApiOperation(value = "校验验证码",notes = "校验验证码") @ApiOperation(value = "校验验证码",notes = "校验验证码")
R checkCode(@ApiParam(value = "用户id和验证码") CheckVo checkVo); R checkCode(@ApiParam(value = "用户id和验证码") CheckVo checkVo);

@ -18,9 +18,9 @@ public class EmailUtils {
//授权码 //授权码
private static final String AUTHORIZATION_CODE = "ZPAASKPCYJDIFFDR"; private static final String AUTHORIZATION_CODE = "ZPAASKPCYJDIFFDR";
//邮件标题 //邮件标题
private static final String EMAILHEAD = "京喜"; private static final String EMAILHEAD = "职站";
//邮件信息(后接验证码)头部信息 //邮件信息(后接验证码)头部信息
private static final String EMAILMASSAGEHEAD = "尊敬的用户您好,您本次注册的验证码是: "; private static final String EMAILMASSAGEHEAD = "尊敬的用户您好,您本次的验证码是: ";
//邮件信息(后接验证码)尾部信息 //邮件信息(后接验证码)尾部信息
private static final String EMAILMASSAGETAIL = ",有效时间为5分钟"; private static final String EMAILMASSAGETAIL = ",有效时间为5分钟";

@ -161,18 +161,18 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity
String code = utils.sendCode(); String code = utils.sendCode();
CheckVo checkVo = new CheckVo(); CheckVo checkVo = new CheckVo();
if (type==1){//通过手机验证 if (type==1){//通过邮箱验证
EmailUtils.sendEmail(entity.getEmail(),code); EmailUtils.sendEmail(entity.getEmail(),code);
checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()); checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()).setTypes(1);
boolean result = userDao.saveCheckCode(checkVo); boolean result = userDao.saveCheckCode(checkVo);
if (result) { if (result) {
return R.ok().put("data",entity); return R.ok().put("data",entity);
}else { }else {
return R.error("保存验证码异常"); return R.error("保存验证码异常");
} }
}else if (type==2){//通过邮箱验证 }else if (type==2){//通过手机验证
SendSMS.sendCode(entity.getPhone(),code); SendSMS.sendCode(entity.getPhone(),code);
checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()); checkVo.setCheckCode(code).setSetTime(utils.letTimes(5)).setUserId(entity.getUserId()).setTypes(2);
boolean result = userDao.saveCheckPhoneCode(checkVo); boolean result = userDao.saveCheckPhoneCode(checkVo);
if (result) { if (result) {
return R.ok().put("data",entity); return R.ok().put("data",entity);
@ -191,11 +191,16 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoDao, UserInfoEntity
@Override @Override
public R checkCode(CheckVo checkVo) { public R checkCode(CheckVo checkVo) {
String checkCode = userInfoDao.checkCode(checkVo); String checkCode = userInfoDao.checkCode(checkVo);
if (checkCode.equals(checkVo.getCode())){ if (checkCode==null){
return R.error("验证码已过期或不存在");
}else if (checkCode.equals(checkVo.getCode())){
return R.ok(); return R.ok();
}else {
return R.error("failure");
} }
return R.error();
} }
@Override @Override

Loading…
Cancel
Save