优化登录接口
This commit is contained in:
parent
b7a36ed148
commit
54fee71f1d
@ -143,11 +143,20 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册/登录
|
||||
* @param form 手机验证码登录dto
|
||||
* @param request
|
||||
* @return 用户ID
|
||||
*/
|
||||
@Override
|
||||
public Integer smsLogin(SmsLoginForm form, HttpServletRequest request) {
|
||||
AppUserEntity appUserEntity = this.lambdaQuery().eq(AppUserEntity::getMobile, form.getMobile()).one();
|
||||
String codeKey = "code_" + form.getMobile();
|
||||
String s = redisUtils.get(codeKey);
|
||||
if (io.linfeng.common.utils.ObjectUtil.isEmpty(s)) {
|
||||
throw new LinfengException("请先发送验证码");
|
||||
}
|
||||
if (!s.equals(form.getCode())) {
|
||||
throw new LinfengException("验证码错误");
|
||||
}
|
||||
@ -170,7 +179,13 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
list.add("新人");
|
||||
appUser.setTagStr(JSON.toJSONString(list));
|
||||
baseMapper.insert(appUser);
|
||||
AppUserEntity user = this.lambdaQuery().eq(AppUserEntity::getMobile, form.getMobile()).one();
|
||||
AppUserEntity user = this.lambdaQuery()
|
||||
.eq(AppUserEntity::getMobile, form.getMobile())
|
||||
.one();
|
||||
if(ObjectUtil.isNull(user)){
|
||||
throw new LinfengException("注册失败");
|
||||
}
|
||||
//其他业务处理
|
||||
return user.getUid();
|
||||
}
|
||||
|
||||
@ -329,6 +344,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
|
||||
appUser.setTagStr(JSON.toJSONString(list));
|
||||
baseMapper.insert(appUser);
|
||||
AppUserEntity users = this.lambdaQuery().eq(AppUserEntity::getOpenid, openId).one();
|
||||
if(ObjectUtil.isNull(users)){
|
||||
throw new LinfengException("注册失败");
|
||||
}
|
||||
//其他业务todo
|
||||
return users.getUid();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user