处理微信登录问题

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());
}
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);
userId = model.getId();
UserAuth auth = new UserAuth();
auth.setUserId(model.getId());
auth.setOpenid(openId);
auth.setUnionid(unionId);
auth.setClient(client);
auth.setCreateTime(System.currentTimeMillis() / 1000);
auth.setUpdateTime(System.currentTimeMillis() / 1000);
userAuthMapper.insert(auth);
if (StringUtil.isNull(userAuth)) {
UserAuth auth = new UserAuth();
auth.setUserId(model.getId());
auth.setOpenid(openId);
auth.setUnionid(unionId);
auth.setClient(client);
auth.setCreateTime(System.currentTimeMillis() / 1000);
auth.setUpdateTime(System.currentTimeMillis() / 1000);
userAuthMapper.insert(auth);
}
} else {
// 更新微信标识
userId = user.getId();
@ -161,7 +163,7 @@ public class LoginServiceImpl implements ILoginService {
}
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<>();
response.put("id", userId);

View File

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