mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
Some checks failed
- Updated database models and repositories to replace uint IDs with UUIDs. - Modified test fixtures to generate and use UUIDs for authors, translations, users, and works. - Adjusted mock implementations to align with the new UUID structure. - Ensured all relevant functions and methods are updated to handle UUIDs correctly. - Added necessary imports for UUID handling in various files.
44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package collection
|
|
|
|
import (
|
|
"context"
|
|
"tercul/internal/domain"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// CollectionQueries contains the query handlers for the collection aggregate.
|
|
type CollectionQueries struct {
|
|
repo domain.CollectionRepository
|
|
}
|
|
|
|
// NewCollectionQueries creates a new CollectionQueries handler.
|
|
func NewCollectionQueries(repo domain.CollectionRepository) *CollectionQueries {
|
|
return &CollectionQueries{repo: repo}
|
|
}
|
|
|
|
// Collection returns a collection by ID.
|
|
func (q *CollectionQueries) Collection(ctx context.Context, id uuid.UUID) (*domain.Collection, error) {
|
|
return q.repo.GetByID(ctx, id)
|
|
}
|
|
|
|
// CollectionsByUserID returns all collections for a user.
|
|
func (q *CollectionQueries) CollectionsByUserID(ctx context.Context, userID uuid.UUID) ([]domain.Collection, error) {
|
|
return q.repo.ListByUserID(ctx, userID)
|
|
}
|
|
|
|
// PublicCollections returns all public collections.
|
|
func (q *CollectionQueries) PublicCollections(ctx context.Context) ([]domain.Collection, error) {
|
|
return q.repo.ListPublic(ctx)
|
|
}
|
|
|
|
// CollectionsByWorkID returns all collections for a work.
|
|
func (q *CollectionQueries) CollectionsByWorkID(ctx context.Context, workID uuid.UUID) ([]domain.Collection, error) {
|
|
return q.repo.ListByWorkID(ctx, workID)
|
|
}
|
|
|
|
// Collections returns all collections.
|
|
func (q *CollectionQueries) Collections(ctx context.Context) ([]domain.Collection, error) {
|
|
return q.repo.ListAll(ctx)
|
|
}
|