手机登录修改

This commit is contained in:
hupeng
2023-10-18 11:46:02 +08:00
parent d0c7d3e527
commit 2bc4abbc3d
3 changed files with 20 additions and 11 deletions

View File

@ -17,7 +17,7 @@ public class RegParam {
@ApiModelProperty(value = "手机号码")
private String account;
@NotBlank(message = "验证码必填")
//@NotBlank(message = "验证码必填")
@ApiModelProperty(value = "验证码")
private String captcha;

View File

@ -195,8 +195,13 @@ public class AuthController {
YxUser yxUser = userService.getOne(Wrappers.<YxUser>lambdaQuery()
.eq(YxUser::getUsername,loginVerifyParam.getAccount()));
//用户不存在自动创建
if(yxUser == null) {
throw new YshopException("账号不存在");
RegParam param = new RegParam();
param.setAccount(loginVerifyParam.getAccount());
param.setPassword("yshop123456");
param.setSpread(loginVerifyParam.getSpread());
yxUser = authService.register(param);
}
String token = JwtToken.makeToken(yxUser.getUid(),yxUser.getUsername());
@ -277,14 +282,14 @@ public class AuthController {
@PostMapping("/register/verify")
@ApiOperation(value = "短信验证码发送", notes = "短信验证码发送")
public ApiResult<String> verify(@Validated @RequestBody VerityParam param) {
YxUser yxUser = userService.getOne(Wrappers.<YxUser>lambdaQuery()
.eq(YxUser::getPhone,param.getPhone()),false);
if (SmsTypeEnum.REGISTER.getValue().equals(param.getType()) && ObjectUtil.isNotNull(yxUser)) {
return ApiResult.fail("手机号已注册");
}
if (SmsTypeEnum.LOGIN.getValue().equals(param.getType()) && ObjectUtil.isNull(yxUser)) {
return ApiResult.fail("账号不存在");
}
// YxUser yxUser = userService.getOne(Wrappers.<YxUser>lambdaQuery()
// .eq(YxUser::getPhone,param.getPhone()),false);
// if (SmsTypeEnum.REGISTER.getValue().equals(param.getType()) && ObjectUtil.isNotNull(yxUser)) {
// return ApiResult.fail("手机号已注册");
// }
// if (SmsTypeEnum.LOGIN.getValue().equals(param.getType()) && ObjectUtil.isNull(yxUser)) {
// return ApiResult.fail("账号不存在");
// }
String codeKey = "code_" + param.getPhone();
if (ObjectUtil.isNotNull(redisUtil.get(codeKey))) {
return ApiResult.fail("10分钟内有效:" + redisUtil.get(codeKey).toString());

View File

@ -165,6 +165,8 @@ public class AuthService {
.phone(phoneNoInfo.getPhoneNumber())
.addIp(ip)
.lastIp(ip)
.nickname(phoneNoInfo.getPhoneNumber())
.avatar(ShopConstants.YSHOP_DEFAULT_AVATAR)
.userType(AppFromEnum.ROUNTINE.getValue())
.build();
@ -293,7 +295,7 @@ public class AuthService {
* @param param RegDTO
*/
@Transactional(rollbackFor = Exception.class)
public void register(RegParam param) {
public YxUser register(RegParam param) {
String account = param.getAccount();
String ip = IpUtil.getRequestIp();
@ -319,6 +321,8 @@ public class AuthService {
}
}
return user;
}