|
@@ -10,6 +10,7 @@ import com.care.common.util.Result;
|
|
|
import com.google.common.cache.Cache;
|
|
|
import com.google.common.cache.CacheBuilder;
|
|
|
import io.swagger.annotations.*;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -73,16 +74,16 @@ public class PassportController {
|
|
|
if (StringUtils.isNotBlank(phone) && StringUtils.isNotBlank(password)) {
|
|
|
CareMemberInfo careMemberInfo = new CareMemberInfo();
|
|
|
careMemberInfo.setPhone(phone);
|
|
|
- careMemberInfo.setPassword(password);
|
|
|
+ careMemberInfo.setPassword(DigestUtils.md5Hex(password));
|
|
|
boolean flag = careMemberInfoService.save(careMemberInfo);
|
|
|
if (flag) {
|
|
|
return Result.success();
|
|
|
}
|
|
|
}
|
|
|
- return Result.error("绑定手机号码失败");
|
|
|
+ return Result.error("注册失败");
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "新用户注册-获取验证码", notes = "新用户注册-获取验证码")
|
|
|
+ @ApiOperation(value = " 获取验证码", notes = "获取验证码")
|
|
|
@GetMapping("getVCode")
|
|
|
@ApiImplicitParams(value = {
|
|
|
@ApiImplicitParam(paramType = "query", name = "phone", value = "电话号码"),
|
|
@@ -97,38 +98,58 @@ public class PassportController {
|
|
|
} else {
|
|
|
return Result.error("获取验证码失败");
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "校验验证码", notes = "校验验证码")
|
|
|
+ @GetMapping("checkVCode")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "phone", value = "电话号码"),
|
|
|
+ })
|
|
|
+ public Result<String> checkVCode(@RequestParam(value = "phone", required = true) String phone,
|
|
|
+ @RequestParam(value = "vcode", required = true) String vcode) {
|
|
|
+ if(StringUtils.equalsIgnoreCase(vcode, smsTimeoutCache.getIfPresent(phone))){
|
|
|
+ return Result.success();
|
|
|
+ } else {
|
|
|
+ return Result.error("请输入正确的验证码");
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
-// @ApiOperation(value = "修改密码", notes = "修改密码")
|
|
|
-// @ApiParam(name = "params", value = "登录参数")
|
|
|
-// @PostMapping("changePwd")
|
|
|
-// public Result<Object> changePwd(@RequestBody MemberInitParams params) {
|
|
|
-//
|
|
|
-// if (StringUtils.isBlank(params.getPhone())) {
|
|
|
-// return Result.error("请输入手机号码");
|
|
|
-// }
|
|
|
-// if (StringUtils.isBlank(params.getPassword())) {
|
|
|
-// return Result.error("请输入密码");
|
|
|
-// }
|
|
|
-// if (StringUtils.isBlank(params.getVcode())) {
|
|
|
-// return Result.error("请输入验证码");
|
|
|
-// }
|
|
|
-// if (!StringUtils.equalsIgnoreCase(params.getVcode(), smsTimeoutCache.getIfPresent(params.getPhone()))) {
|
|
|
-// return Result.error("请输入正确的验证码");
|
|
|
-// }
|
|
|
-// MemberOpenDO memberOpenDO = memberOpenService.detailByPhone(params.getPhone());
|
|
|
-// if (memberOpenDO == null) {
|
|
|
-// return Result.error("该手机号未注册");
|
|
|
-// }
|
|
|
-//
|
|
|
-// boolean flag = memberInfoService.changePwd(params.getPassword(), memberOpenDO.getMember().getId());
|
|
|
-// if (flag) {
|
|
|
-// return Result.success();
|
|
|
-// }
|
|
|
-//
|
|
|
-// return Result.error("绑定手机号码失败");
|
|
|
-// }
|
|
|
+ @ApiOperation(value = "设置新密码", notes = "设置新密码, 传值:手机号,密码,确认密码,验证码")
|
|
|
+ @ApiParam(name = "params", value = "登录参数")
|
|
|
+ @PostMapping("changePwd")
|
|
|
+ public Result<Object> changePwd(@RequestBody MemberInitParams params) {
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(params.getPhone())) {
|
|
|
+ return Result.error("手机号码不能为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(params.getPassword())) {
|
|
|
+ return Result.error("请输入密码");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(params.getPasswordAgain())) {
|
|
|
+ return Result.error("请再次输入密码");
|
|
|
+ }
|
|
|
+ if (!params.getPassword().equals(StringUtils.isBlank(params.getPasswordAgain()))) {
|
|
|
+ return Result.error("两次输入密码不一致");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(params.getVcode())) {
|
|
|
+ return Result.error("验证码不能为空");
|
|
|
+ }
|
|
|
+ if (!StringUtils.equalsIgnoreCase(params.getVcode(), smsTimeoutCache.getIfPresent(params.getPhone()))) {
|
|
|
+ return Result.error("验证码无效");
|
|
|
+ }
|
|
|
+ CareMemberInfo careMemberInfo = careMemberInfoService.detailByPhone(params.getPhone());
|
|
|
+ if (careMemberInfo == null) {
|
|
|
+ return Result.error("该手机号未注册");
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean flag = passportService.changePwd(params.getPassword(), careMemberInfo.getId());
|
|
|
+ if (flag) {
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ return Result.error("设置新密码失败");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "小程序登出", notes = "小程序登出")
|