Documentation
¶
Index ¶
- type CommentService
- func (s *CommentService) BatchVoteComments(ctx context.Context, votes []models.VoteRequest, userID string) error
- func (s *CommentService) CreateComment(ctx context.Context, req *models.CreateCommentRequest) (*models.Comment, error)
- func (s *CommentService) DeleteComment(ctx context.Context, id, userID string) error
- func (s *CommentService) GetComment(ctx context.Context, id string) (*models.Comment, error)
- func (s *CommentService) GetCommentChildren(ctx context.Context, parentID string, maxDepth int) ([]*models.Comment, error)
- func (s *CommentService) GetCommentPath(ctx context.Context, commentID string) ([]*models.Comment, error)
- func (s *CommentService) GetCommentStats(ctx context.Context, rootID string) (*models.CommentStats, error)
- func (s *CommentService) GetCommentTree(ctx context.Context, rootID string, maxDepth int, sortBy string) ([]*models.CommentTree, error)
- func (s *CommentService) GetCommentsByRoot(ctx context.Context, rootID string, filter *models.CommentFilter) ([]*models.Comment, error)
- func (s *CommentService) GetCommentsByUser(ctx context.Context, userID string, filter *models.CommentFilter) ([]*models.Comment, error)
- func (s *CommentService) GetCommentsWithUserVotes(ctx context.Context, rootID, userID string, filter *models.CommentFilter) ([]*models.Comment, map[string]*models.Vote, error)
- func (s *CommentService) GetTopComments(ctx context.Context, rootID string, limit int, timeRange string) ([]*models.Comment, error)
- func (s *CommentService) GetUserCommentCount(ctx context.Context, userID string) (int64, error)
- func (s *CommentService) PurgeOldDeletedComments(ctx context.Context, olderThanDays int) (int64, error)
- func (s *CommentService) RecalculateAllScores(ctx context.Context) error
- func (s *CommentService) RemoveVote(ctx context.Context, commentID, userID string) error
- func (s *CommentService) SearchComments(ctx context.Context, rootID, query string, filter *models.CommentFilter) ([]*models.Comment, error)
- func (s *CommentService) UpdateComment(ctx context.Context, id, userID string, req *models.UpdateCommentRequest) error
- func (s *CommentService) VoteComment(ctx context.Context, commentID, userID string, voteType models.VoteType) error
- type CommentServiceConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommentService ¶
type CommentService struct {
// contains filtered or unexported fields
}
CommentService handles business logic for comments
func NewCommentService ¶
func NewCommentService(repo repository.CommentRepository) *CommentService
NewCommentService creates a new comment service
func NewCommentServiceWithConfig ¶
func NewCommentServiceWithConfig(repo repository.CommentRepository, config *CommentServiceConfig) *CommentService
NewCommentServiceWithConfig creates a comment service with custom configuration
func (*CommentService) BatchVoteComments ¶
func (s *CommentService) BatchVoteComments(ctx context.Context, votes []models.VoteRequest, userID string) error
BatchVoteComments allows voting on multiple comments at once (useful for bulk operations)
func (*CommentService) CreateComment ¶
func (s *CommentService) CreateComment(ctx context.Context, req *models.CreateCommentRequest) (*models.Comment, error)
CreateComment creates a new comment with validation and business logic
func (*CommentService) DeleteComment ¶
func (s *CommentService) DeleteComment(ctx context.Context, id, userID string) error
DeleteComment soft deletes a comment
func (*CommentService) GetComment ¶
GetComment retrieves a comment by ID
func (*CommentService) GetCommentChildren ¶
func (s *CommentService) GetCommentChildren(ctx context.Context, parentID string, maxDepth int) ([]*models.Comment, error)
GetCommentChildren retrieves all child comments for a given comment
func (*CommentService) GetCommentPath ¶
func (s *CommentService) GetCommentPath(ctx context.Context, commentID string) ([]*models.Comment, error)
GetCommentPath retrieves the full path from root to a specific comment
func (*CommentService) GetCommentStats ¶
func (s *CommentService) GetCommentStats(ctx context.Context, rootID string) (*models.CommentStats, error)
GetCommentStats retrieves statistics for a comment thread
func (*CommentService) GetCommentTree ¶
func (s *CommentService) GetCommentTree(ctx context.Context, rootID string, maxDepth int, sortBy string) ([]*models.CommentTree, error)
GetCommentTree retrieves a hierarchical comment tree
func (*CommentService) GetCommentsByRoot ¶
func (s *CommentService) GetCommentsByRoot(ctx context.Context, rootID string, filter *models.CommentFilter) ([]*models.Comment, error)
GetCommentsByRoot retrieves comments for a specific root with enhanced filtering
func (*CommentService) GetCommentsByUser ¶
func (s *CommentService) GetCommentsByUser(ctx context.Context, userID string, filter *models.CommentFilter) ([]*models.Comment, error)
GetCommentsByUser retrieves comments by a specific user
func (*CommentService) GetCommentsWithUserVotes ¶
func (s *CommentService) GetCommentsWithUserVotes(ctx context.Context, rootID, userID string, filter *models.CommentFilter) ([]*models.Comment, map[string]*models.Vote, error)
GetCommentsWithUserVotes retrieves comments with user's voting status for efficient frontend rendering
func (*CommentService) GetTopComments ¶
func (s *CommentService) GetTopComments(ctx context.Context, rootID string, limit int, timeRange string) ([]*models.Comment, error)
GetTopComments retrieves the highest-scored comments within a time range
func (*CommentService) GetUserCommentCount ¶
GetUserCommentCount retrieves the total number of comments by a user
func (*CommentService) PurgeOldDeletedComments ¶
func (s *CommentService) PurgeOldDeletedComments(ctx context.Context, olderThanDays int) (int64, error)
PurgeOldDeletedComments removes soft-deleted comments older than specified days
func (*CommentService) RecalculateAllScores ¶
func (s *CommentService) RecalculateAllScores(ctx context.Context) error
RecalculateAllScores recalculates vote scores for all comments
func (*CommentService) RemoveVote ¶
func (s *CommentService) RemoveVote(ctx context.Context, commentID, userID string) error
RemoveVote removes a user's vote from a comment
func (*CommentService) SearchComments ¶
func (s *CommentService) SearchComments(ctx context.Context, rootID, query string, filter *models.CommentFilter) ([]*models.Comment, error)
SearchComments searches for comments containing specific text
func (*CommentService) UpdateComment ¶
func (s *CommentService) UpdateComment(ctx context.Context, id, userID string, req *models.UpdateCommentRequest) error
UpdateComment updates a comment's content
func (*CommentService) VoteComment ¶
func (s *CommentService) VoteComment(ctx context.Context, commentID, userID string, voteType models.VoteType) error
VoteComment handles voting on a comment