mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 04:01: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.
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package comment
|
|
|
|
import (
|
|
"context"
|
|
"tercul/internal/domain"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// CommentQueries contains the query handlers for the comment aggregate.
|
|
type CommentQueries struct {
|
|
repo domain.CommentRepository
|
|
}
|
|
|
|
// NewCommentQueries creates a new CommentQueries handler.
|
|
func NewCommentQueries(repo domain.CommentRepository) *CommentQueries {
|
|
return &CommentQueries{repo: repo}
|
|
}
|
|
|
|
// Comment returns a comment by ID.
|
|
func (q *CommentQueries) Comment(ctx context.Context, id uuid.UUID) (*domain.Comment, error) {
|
|
return q.repo.GetByID(ctx, id)
|
|
}
|
|
|
|
// CommentsByUserID returns all comments for a user.
|
|
func (q *CommentQueries) CommentsByUserID(ctx context.Context, userID uuid.UUID) ([]domain.Comment, error) {
|
|
return q.repo.ListByUserID(ctx, userID)
|
|
}
|
|
|
|
// CommentsByWorkID returns all comments for a work.
|
|
func (q *CommentQueries) CommentsByWorkID(ctx context.Context, workID uuid.UUID) ([]domain.Comment, error) {
|
|
return q.repo.ListByWorkID(ctx, workID)
|
|
}
|
|
|
|
// CommentsByTranslationID returns all comments for a translation.
|
|
func (q *CommentQueries) CommentsByTranslationID(ctx context.Context, translationID uuid.UUID) ([]domain.Comment, error) {
|
|
return q.repo.ListByTranslationID(ctx, translationID)
|
|
}
|
|
|
|
// CommentsByParentID returns all comments for a parent.
|
|
func (q *CommentQueries) CommentsByParentID(ctx context.Context, parentID uuid.UUID) ([]domain.Comment, error) {
|
|
return q.repo.ListByParentID(ctx, parentID)
|
|
}
|
|
|
|
// Comments returns all comments.
|
|
func (q *CommentQueries) Comments(ctx context.Context) ([]domain.Comment, error) {
|
|
return q.repo.ListAll(ctx)
|
|
}
|