feat: 解耦认证逻辑

This commit is contained in:
2026-06-24 12:17:09 +08:00
parent 5d9f5b8ab7
commit ab2a2dbf7f
14 changed files with 332 additions and 94 deletions

View File

@@ -1,6 +1,6 @@
package com.webgame.webgamebackend.service.impl;
import cn.dev33.satoken.stp.StpUtil;
import com.webgame.webgamebackend.common.auth.AuthenticationProvider;
import com.webgame.webgamebackend.common.dto.user.UpdateStatusRequest;
import com.webgame.webgamebackend.common.dto.user.UpdateUserInfoRequest;
import com.webgame.webgamebackend.common.dto.user.UserInfoResponse;
@@ -48,10 +48,11 @@ public class UserServiceImpl implements UserService {
private static final long MAX_AVATAR_SIZE = 2 * 1024 * 1024;
private final UserRepository userRepository;
private final AuthenticationProvider authProvider;
@Override
public UserInfoResponse getCurrentUserInfo() {
String accountId = StpUtil.getLoginIdAsString();
String accountId = authProvider.getCurrentUserId();
log.info("[用户服务] 获取当前登录用户信息, accountId: {}", accountId);
UserEntity user = userRepository.findByAccountId(accountId)
.orElseThrow(() -> new BusinessException(ErrorCode.USER_NOT_FOUND));