免登录功能

This commit is contained in:
khy 2025-06-09 13:08:59 +08:00
parent 59e6c4871f
commit 1b4196ceef
3 changed files with 27 additions and 0 deletions

View File

@ -123,4 +123,10 @@ public class AppAuthController {
return success(AuthConvert.INSTANCE.convert(signature));
}
@PostMapping("/checkLogin")
@PermitAll
public CommonResult<Integer> checkLogin(@RequestBody @Valid AppAuthSocialLoginReqVO reqVO) {
return success(authService.checkLogin(reqVO));
}
}

View File

@ -85,4 +85,6 @@ public interface MemberAuthService {
*/
AppAuthLoginRespVO refreshToken(String refreshToken);
Integer checkLogin(AppAuthSocialLoginReqVO reqVO);
}

View File

@ -258,6 +258,25 @@ public class MemberAuthServiceImpl implements MemberAuthService {
return AuthConvert.INSTANCE.convert(accessTokenDO, null);
}
@Override
public Integer checkLogin(AppAuthSocialLoginReqVO reqVO) {
// 使用 code 授权码进行登录然后获得到绑定的用户编号
SocialUserRespDTO socialUser = socialUserApi.getSocialUserByCode(UserTypeEnum.MEMBER.getValue(), reqVO.getType(),
reqVO.getCode(), reqVO.getState());
System.out.println(socialUser);
if (socialUser == null) {
System.out.println("111");
throw exception(AUTH_SOCIAL_USER_NOT_FOUND);
}
//判断openid是否存在
// SocialUserRespDTO respDTO = socialUserApi.getSocialUserByOpenId(socialUser.getOpenid());
if (socialUser.getUserId() == null) {
return -1;
}
return 1;
}
private void createLogoutLog(Long userId) {
LoginLogCreateReqDTO reqDTO = new LoginLogCreateReqDTO();
reqDTO.setLogType(LoginLogTypeEnum.LOGOUT_SELF.getType());