Reorganize project structure: - backend/cmd/openteam/ — entry point - backend/internal/ — core packages - backend/middleware/ — HTTP middleware - backend/router/ — route setup - backend/wire/ — dependency injection - backend/pkg/ — shared utilities - backend/go.mod, go.sum — Go module files Updated Makefile to work from backend/ directory. Removed old lowercase makefile.
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
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)
|
|
}
|