|
|
@@ -58,8 +58,13 @@ private OnboardingService onboardingService;
|
|
|
private FamilyInvitationService familyInvitationService;
|
|
|
|
|
|
public LoginResultDTO wechatLogin(WechatLoginDTO dto) {
|
|
|
- // 模拟微信登录,实际需要调用微信API获取openid
|
|
|
- String openid = "mock_openid_" + dto.getCode();
|
|
|
+ // 通过code获取真实openid(调微信code2session接口)
|
|
|
+ Map<String, String> sessionData = wechatService.code2Session(dto.getCode());
|
|
|
+ String openid = sessionData.get("openid");
|
|
|
+ String unionid = sessionData.get("unionid");
|
|
|
+ if (openid == null || openid.isEmpty()) {
|
|
|
+ throw new RuntimeException("获取openid失败,请重试");
|
|
|
+ }
|
|
|
|
|
|
// 查询用户是否存在
|
|
|
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
|