处理微信登录问题

This commit is contained in:
TinyAnts 2022-09-08 09:56:10 +08:00
parent 67ccf1b607
commit 4529f969ea
3 changed files with 17 additions and 15 deletions

View File

@ -35,7 +35,7 @@ public class GlobalException {
System.out.println(e.getMessage()); System.out.println(e.getMessage());
} }
log.error("系统异常 {}", e.getMessage()); log.error("系统异常 {}", e.getMessage());
return AjaxResult.failed(HttpEnum.SYSTEM_ERROR.getCode(), HttpEnum.SYSTEM_ERROR.getMsg()); return AjaxResult.failed(HttpEnum.SYSTEM_ERROR.getCode(), e.getMessage());
} }
/** /**

View File

@ -131,14 +131,16 @@ public class LoginServiceImpl implements ILoginService {
userMapper.insert(model); userMapper.insert(model);
userId = model.getId(); userId = model.getId();
UserAuth auth = new UserAuth(); if (StringUtil.isNull(userAuth)) {
auth.setUserId(model.getId()); UserAuth auth = new UserAuth();
auth.setOpenid(openId); auth.setUserId(model.getId());
auth.setUnionid(unionId); auth.setOpenid(openId);
auth.setClient(client); auth.setUnionid(unionId);
auth.setCreateTime(System.currentTimeMillis() / 1000); auth.setClient(client);
auth.setUpdateTime(System.currentTimeMillis() / 1000); auth.setCreateTime(System.currentTimeMillis() / 1000);
userAuthMapper.insert(auth); auth.setUpdateTime(System.currentTimeMillis() / 1000);
userAuthMapper.insert(auth);
}
} else { } else {
// 更新微信标识 // 更新微信标识
userId = user.getId(); userId = user.getId();
@ -161,7 +163,7 @@ public class LoginServiceImpl implements ILoginService {
} }
String token = ToolsUtil.makeToken(); String token = ToolsUtil.makeToken();
RedisUtil.set(FrontConfig.frontendTokenKey+token, user.getId(), 7200); RedisUtil.set(FrontConfig.frontendTokenKey+token, userId, 7200);
Map<String, Object> response = new LinkedHashMap<>(); Map<String, Object> response = new LinkedHashMap<>();
response.put("id", userId); response.put("id", userId);

View File

@ -115,12 +115,12 @@ public class UserServiceImpl implements IUserService {
wxMaService.setWxMaConfig(wxConfig); wxMaService.setWxMaConfig(wxConfig);
try { try {
String sessionKey = ""; // String sessionKey = "";
String encryptedData = params.get("encryptedData"); // String encryptedData = params.get("encryptedData");
String ivStr = params.get("iv"); // String ivStr = params.get("iv");
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService() WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService()
.getNewPhoneNoInfo("093bd81w3n9ocZ2KZu2w3XBZ034bd81S"); .getNewPhoneNoInfo("0330FG000I3kwO1Ui81000ZRkr00FG0Y");
System.out.println(wxMaPhoneNumberInfo);
} catch (WxErrorException e) { } catch (WxErrorException e) {
System.out.println(e.getError()); System.out.println(e.getError());