package service import ( "context" "opencatd-open/internal/dao" "opencatd-open/internal/store" "gorm.io/gorm" ) type ApiKeyServiceImpl struct { db *gorm.DB apiKeyRepo *dao.ApiKeyDAO } func NewApiKeyService(db *gorm.DB, apiKeyDao *dao.ApiKeyDAO) *ApiKeyServiceImpl { return &ApiKeyServiceImpl{db: db, apiKeyRepo: apiKeyDao} } func (s *ApiKeyServiceImpl) CreateApiKey(ctx context.Context, apikey *store.APIKey) error { return s.apiKeyRepo.Create(apikey) } func (s *ApiKeyServiceImpl) GetApiKey(ctx context.Context, id uint64) (*store.APIKey, error) { return s.apiKeyRepo.GetByID(id) } func (s *ApiKeyServiceImpl) ListApiKey(ctx context.Context, userID uint64, limit, offset int) ([]*store.APIKey, int64, error) { return s.apiKeyRepo.ListByUserID(userID, limit, offset) } func (s *ApiKeyServiceImpl) UpdateApiKey(ctx context.Context, apikey *store.APIKey) error { return s.apiKeyRepo.Update(apikey) } func (s *ApiKeyServiceImpl) DeleteApiKey(ctx context.Context, id uint64) error { return s.apiKeyRepo.Delete(id) }