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