登录部分

This commit is contained in:
2024-06-22 11:26:07 +08:00
parent 941c33ea7a
commit d86463155d
3 changed files with 29 additions and 9 deletions

View File

@@ -178,7 +178,7 @@ public class LoginService {
* @param nickName
* @return
*/
public TbUserInfo register(String phone, String password, String nickName) {
public TbUserInfo register(String phone, String openId,String password, String nickName) {
TbUserInfo userInfo = new TbUserInfo();
userInfo.setAmount(BigDecimal.ZERO);
@@ -202,6 +202,9 @@ public class LoginService {
userInfo.setLastLogInAt(System.currentTimeMillis());
userInfo.setCreatedAt(System.currentTimeMillis());
userInfo.setUpdatedAt(System.currentTimeMillis());
userInfo.setMiniAppOpenId(openId);
userInfo.setIsPwd("0");
userInfo.setPwd(MD5Utils.md5("123456"));
if (StringUtils.isNotBlank(password)) {
userInfo.setPassword(MD5Utils.MD5Encode(password, "UTF-8"));
}
@@ -234,14 +237,19 @@ public class LoginService {
}
@Transactional(rollbackFor = Exception.class)
public Result appLogin(String username, String password) {
public Result appLogin(String username,String openId, String password) {
TbUserInfo userInfo = tbUserInfoMapper.selectByPhone(username);
if (ObjectUtil.isNull(userInfo)) {
if (StringUtils.isNotBlank(password)) {
return Result.fail("暂未设置密码,请使用验证码登录");
}
userInfo = register(username, password, username);
userInfo = register(username,openId, password, username);
} else {
if (StringUtils.isNotBlank(userInfo.getMiniAppOpenId())) {
if (!userInfo.getMiniAppOpenId().equals(openId)) {
userInfo.setMiniAppOpenId(openId);
}
}
String searchWord = userInfo.getSearchWord();
if (!searchWord.contains("移动端用户")) {
userInfo.setSearchWord(userInfo.getSearchWord() + "||移动端用户");
@@ -268,10 +276,10 @@ public class LoginService {
try {
map.put("token", token);
map.put("userInfo", userInfo);
if(StringUtils.isNotBlank(userInfo.getMiniAppOpenId())){
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(userInfo.getMiniAppOpenId()), JSON.toJSONString(map),60*60*24*30L);
}else {
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(userInfo.getId() + ""), JSON.toJSONString(map),60*60*24*30L);
if (StringUtils.isNotBlank(userInfo.getMiniAppOpenId())) {
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(userInfo.getMiniAppOpenId()), JSON.toJSONString(map), 60 * 60 * 24 * 30L);
} else {
redisUtil.saveMessage(RedisCst.ONLINE_USER.concat(userInfo.getId() + ""), JSON.toJSONString(map), 60 * 60 * 24 * 30L);
}
// redisUtil.saveMessage(RedisCst.ONLINE_APP_USER.concat(userInfo.getId() + ""), JSON.toJSONString(map),60*60*24*30L);
return Result.success(CodeEnum.SUCCESS, map);