refactor: Update service and repository methods to use context

- Refactored multiple service and repository methods to accept context as a parameter, enhancing consistency and enabling better control over request lifecycles.
- Updated handlers to utilize context in method calls, improving error handling and performance.
- Cleaned up Dockerfile by removing unnecessary whitespace.
This commit is contained in:
lan
2025-12-03 15:27:12 +08:00
parent 4824a997dd
commit 0bcd9336c4
32 changed files with 833 additions and 497 deletions

View File

@@ -33,7 +33,7 @@ func NewYggdrasilServiceComposite(
profileRepo repository.ProfileRepository,
tokenRepo repository.TokenRepository,
yggdrasilRepo repository.YggdrasilRepository,
signatureService *signatureService,
signatureService *SignatureService,
redisClient *redis.Client,
logger *zap.Logger,
) YggdrasilService {
@@ -76,7 +76,7 @@ func (s *yggdrasilServiceComposite) ResetYggdrasilPassword(ctx context.Context,
// JoinServer 加入服务器
func (s *yggdrasilServiceComposite) JoinServer(ctx context.Context, serverID, accessToken, selectedProfile, ip string) error {
// 验证Token
token, err := s.tokenRepo.FindByAccessToken(accessToken)
token, err := s.tokenRepo.FindByAccessToken(ctx, accessToken)
if err != nil {
s.logger.Error("验证Token失败",
zap.Error(err),
@@ -92,7 +92,7 @@ func (s *yggdrasilServiceComposite) JoinServer(ctx context.Context, serverID, ac
}
// 获取Profile以获取用户名
profile, err := s.profileRepo.FindByUUID(formattedProfile)
profile, err := s.profileRepo.FindByUUID(ctx, formattedProfile)
if err != nil {
s.logger.Error("获取Profile失败",
zap.Error(err),