47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
|
|
"backend/pkg/post/domain/entity"
|
|
"backend/pkg/post/domain/post"
|
|
|
|
"github.com/gocql/gocql"
|
|
)
|
|
|
|
// CommentRepository defines the interface for comment data access operations
|
|
type CommentRepository interface {
|
|
BaseCommentRepository
|
|
FindByPostID(ctx context.Context, postID gocql.UUID, params *CommentQueryParams) ([]*entity.Comment, int64, error)
|
|
FindByParentID(ctx context.Context, parentID gocql.UUID, params *CommentQueryParams) ([]*entity.Comment, int64, error)
|
|
FindByAuthorUID(ctx context.Context, authorUID string, params *CommentQueryParams) ([]*entity.Comment, int64, error)
|
|
FindReplies(ctx context.Context, commentID gocql.UUID, params *CommentQueryParams) ([]*entity.Comment, int64, error)
|
|
IncrementLikeCount(ctx context.Context, commentID gocql.UUID) error
|
|
DecrementLikeCount(ctx context.Context, commentID gocql.UUID) error
|
|
IncrementReplyCount(ctx context.Context, commentID gocql.UUID) error
|
|
DecrementReplyCount(ctx context.Context, commentID gocql.UUID) error
|
|
UpdateStatus(ctx context.Context, commentID gocql.UUID, status post.CommentStatus) error
|
|
}
|
|
|
|
// BaseCommentRepository defines basic CRUD operations for comments
|
|
type BaseCommentRepository interface {
|
|
Insert(ctx context.Context, data *entity.Comment) error
|
|
FindOne(ctx context.Context, id gocql.UUID) (*entity.Comment, error)
|
|
Update(ctx context.Context, data *entity.Comment) error
|
|
Delete(ctx context.Context, id gocql.UUID) error
|
|
}
|
|
|
|
// CommentQueryParams defines query parameters for comment listing
|
|
type CommentQueryParams struct {
|
|
PostID *gocql.UUID
|
|
ParentID *gocql.UUID
|
|
AuthorUID *string
|
|
Status *post.CommentStatus
|
|
CreateStartTime *int64
|
|
CreateEndTime *int64
|
|
PageSize int64
|
|
PageIndex int64
|
|
OrderBy string // "created_at", "like_count"
|
|
OrderDirection string // "ASC", "DESC"
|
|
}
|