|
@@ -40,9 +40,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
//权限字符
|
|
//权限字符
|
|
@Autowired
|
|
@Autowired
|
|
private ReRoleMenuMapper reRoleMenuMapper;
|
|
private ReRoleMenuMapper reRoleMenuMapper;
|
|
- /** 方法抽取 */
|
|
|
|
- @Autowired
|
|
|
|
- private MethodAppUserService methodAppUserService;
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -58,6 +56,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
|
|
|
|
/** 改 */
|
|
/** 改 */
|
|
void update(AppUser a){
|
|
void update(AppUser a){
|
|
|
|
+ a.setUpdateTime(new Date());
|
|
updateById(a);
|
|
updateById(a);
|
|
|
|
|
|
}
|
|
}
|
|
@@ -154,6 +153,8 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
if(appUser.getStatus().equals("0"))return AjaxJson.getError("该账户 " + appUser.getPhone() + " 已停用!");
|
|
if(appUser.getStatus().equals("0"))return AjaxJson.getError("该账户 " + appUser.getPhone() + " 已停用!");
|
|
//设置登录次数
|
|
//设置登录次数
|
|
appUser.setLoginCount(appUser.getLoginCount() + 1);
|
|
appUser.setLoginCount(appUser.getLoginCount() + 1);
|
|
|
|
+ //保存
|
|
|
|
+ appUserMapper.updateById(appUser);
|
|
//开始执行登录
|
|
//开始执行登录
|
|
StpUtil.login(appUser.getId());
|
|
StpUtil.login(appUser.getId());
|
|
// 组织返回参数,直接拿过来用的,然后自己改吧改吧
|
|
// 组织返回参数,直接拿过来用的,然后自己改吧改吧
|
|
@@ -183,15 +184,18 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, forgetPasswordDto.getPhone())
|
|
(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, forgetPasswordDto.getPhone())
|
|
.eq(AppUser::getDeleteStatus, 1)
|
|
.eq(AppUser::getDeleteStatus, 1)
|
|
.eq(AppUser::getStatus, 1));
|
|
.eq(AppUser::getStatus, 1));
|
|
- if(appUserList.size() != 1)return AjaxJson.getError("当前账户存在异常,请联系客服进行处理!");
|
|
|
|
|
|
+ //判断其手机号码可能存在的异常情况
|
|
|
|
+ if(appUserList.size() > 1)
|
|
|
|
+ return AjaxJson.getError("当前账户存在异常,请联系客服进行处理!");
|
|
|
|
+ if(appUserList.size() == 0)throw new RuntimeException("您当前手机号尚未进行注册!");
|
|
//获取当前手机号对象
|
|
//获取当前手机号对象
|
|
AppUser appUser = appUserList.get(0);
|
|
AppUser appUser = appUserList.get(0);
|
|
//获取短信验证码发送结果
|
|
//获取短信验证码发送结果
|
|
- boolean sendResult = methodAppUserService.getSmsCode(forgetPasswordDto.getPhone());
|
|
|
|
- if(!sendResult)return AjaxJson.getError("验证码发送失败!");
|
|
|
|
|
|
+ boolean phoneSmsCode = getPhoneSmsCode(forgetPasswordDto.getPhone());
|
|
|
|
+ if(!phoneSmsCode)return AjaxJson.getError("验证码发送失败!");
|
|
//从缓存中获取验证码
|
|
//从缓存中获取验证码
|
|
String smsCode = RedisUtil.get(forgetPasswordDto.getPhone());
|
|
String smsCode = RedisUtil.get(forgetPasswordDto.getPhone());
|
|
- if(smsCode == null)return AjaxJson.getError("验证码发送失败!");
|
|
|
|
|
|
+ if(smsCode == null)return AjaxJson.getError("验证码已过期!");
|
|
//比对用户输入的验证码
|
|
//比对用户输入的验证码
|
|
boolean result = smsCode.equals(forgetPasswordDto.getSmsCode());
|
|
boolean result = smsCode.equals(forgetPasswordDto.getSmsCode());
|
|
//进行验证码校验完成后的流程
|
|
//进行验证码校验完成后的流程
|
|
@@ -209,7 +213,9 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
if(i != 1)return AjaxJson.getError("密码重置失败!");
|
|
if(i != 1)return AjaxJson.getError("密码重置失败!");
|
|
return AjaxJson.getSuccess("密码找回成功!");
|
|
return AjaxJson.getSuccess("密码找回成功!");
|
|
}else {
|
|
}else {
|
|
|
|
+
|
|
return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
|
|
return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -218,4 +224,17 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
return AjaxJson.getError("验证码输入错误,请检查!");
|
|
return AjaxJson.getError("验证码输入错误,请检查!");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /** 获取验证码 */
|
|
|
|
+ boolean getPhoneSmsCode(String phone){
|
|
|
|
+ //todo: 发送短信,其短信商回调验证码
|
|
|
|
+ String smsCode = "123";
|
|
|
|
+ //todo: 根据其短信发送情况返回不同的结果
|
|
|
|
+
|
|
|
|
+ // return false;
|
|
|
|
+
|
|
|
|
+ //todo: 保存到缓存,默认1分钟
|
|
|
|
+ RedisUtil.setByMINUTES(phone,smsCode, 1);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
}
|
|
}
|