service

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

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

func (s *CommentService) GetComment(ctx context.Context, id string) (*models.Comment, error)

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

func (s *CommentService) GetUserCommentCount(ctx context.Context, userID string) (int64, error)

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

type CommentServiceConfig

type CommentServiceConfig struct {
	MaxCommentLength int
	MaxTreeDepth     int
	MaxBatchSize     int
	DefaultPageSize  int
	MaxPageSize      int
}

CommentServiceConfig holds configuration for the comment service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL