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:
@@ -21,14 +21,14 @@ type CertificateService interface {
|
||||
// yggdrasilCertificateService 证书服务实现
|
||||
type yggdrasilCertificateService struct {
|
||||
profileRepo repository.ProfileRepository
|
||||
signatureService *signatureService
|
||||
signatureService *SignatureService
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
// NewCertificateService 创建证书服务实例
|
||||
func NewCertificateService(
|
||||
profileRepo repository.ProfileRepository,
|
||||
signatureService *signatureService,
|
||||
signatureService *SignatureService,
|
||||
logger *zap.Logger,
|
||||
) CertificateService {
|
||||
return &yggdrasilCertificateService{
|
||||
@@ -49,7 +49,7 @@ func (s *yggdrasilCertificateService) GeneratePlayerCertificate(ctx context.Cont
|
||||
)
|
||||
|
||||
// 获取密钥对
|
||||
keyPair, err := s.profileRepo.GetKeyPair(uuid)
|
||||
keyPair, err := s.profileRepo.GetKeyPair(ctx, uuid)
|
||||
if err != nil {
|
||||
s.logger.Info("获取用户密钥对失败,将创建新密钥对",
|
||||
zap.Error(err),
|
||||
@@ -74,7 +74,7 @@ func (s *yggdrasilCertificateService) GeneratePlayerCertificate(ctx context.Cont
|
||||
}
|
||||
|
||||
// 保存密钥对到数据库
|
||||
err = s.profileRepo.UpdateKeyPair(uuid, keyPair)
|
||||
err = s.profileRepo.UpdateKeyPair(ctx, uuid, keyPair)
|
||||
if err != nil {
|
||||
s.logger.Warn("更新用户密钥对失败",
|
||||
zap.Error(err),
|
||||
|
||||
Reference in New Issue
Block a user