|
@@ -59,33 +59,31 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- private String getMailKey(String email) {
|
|
|
- return String.format(RedisConstants.USER_EMAIL_CODE, email);
|
|
|
+ private String getKey(String email) {
|
|
|
+ return String.format(RedisConstants.USER_SMS_CODE, email);
|
|
|
}
|
|
|
|
|
|
-// @Override public Result<Object> sendMail(String email) {
|
|
|
-// boolean isEmail = Validator.isEmail(email);
|
|
|
-// if (!isEmail) {
|
|
|
-// log.warn("WalletCenterService#sendMail warn. email address error. email:`{}`.", email);
|
|
|
-// return Result.error("1002", "E-mail address error.");
|
|
|
-// }
|
|
|
-// String key = getMailKey(email);
|
|
|
-// String code = RandomUtil.randomNumbers(6);
|
|
|
-// String subject = "来自Free City的CODE码";
|
|
|
-// String content = "您的CODE为: " + code;
|
|
|
+ @Override
|
|
|
+ public Result<Object> sendCode(String phoneNo) {
|
|
|
+ String key = getKey(phoneNo);
|
|
|
+ String code = RandomUtil.randomNumbers(6);
|
|
|
+ String subject = "来自Free City的CODE码";
|
|
|
+ String content = "您的CODE为: " + code;
|
|
|
+ //TODO 发短信
|
|
|
// Result<Object> result = MailClient.send(email, subject, content, null);
|
|
|
// if (result.isSuccess()) {
|
|
|
// redisClient.set(key, code, 60);
|
|
|
// }
|
|
|
-// return result;
|
|
|
-// }
|
|
|
+ redisClient.set(key, code, 60);
|
|
|
+ return Result.success(code);
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
- public Boolean checkCode(String email, String code) {
|
|
|
+ public Boolean checkCode(String phoneNo, String code) {
|
|
|
if (StrUtil.equals("888888",code)){
|
|
|
return true;
|
|
|
}
|
|
|
- String key = getMailKey(email);
|
|
|
+ String key = getKey(phoneNo);
|
|
|
Object o = redisClient.get(key);
|
|
|
if (StrUtil.equals(o.toString(),code)){
|
|
|
return true;
|
|
@@ -194,6 +192,22 @@ public class UserServiceImpl extends AbstractService<User> implements UserServic
|
|
|
accountService.saveUseGeneratedKeys(account);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result<Object> resetPwdByCode(Long userId, String verifyCode, String newPwd) {
|
|
|
+ User user = findById(userId);
|
|
|
+ if (user == null){
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.USER_IS_NULL);
|
|
|
+ }
|
|
|
+ String key = getKey(user.getPhoneNo());
|
|
|
+ Object o = redisClient.get(key);
|
|
|
+ if (!StrUtil.equals(o.toString(),verifyCode)){
|
|
|
+ return ResultGenerator.genFailResult(ResultCode.CODE_CHECK_FAIL);
|
|
|
+ }
|
|
|
+ update(User.builder().id(user.getId()).pwd(SecureUtil.md5(newPwd + user.getSalt())).build());
|
|
|
+
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
// @Override
|
|
|
// public boolean sendMsg(MessageParam param) {
|
|
|
// if (param == null){
|