comment

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// filtersKey identifies the current filters during the request life.
	FiltersKey contextKey = iota
)

Variables

This section is empty.

Functions

func NewMiddleware added in v0.4.0

func NewMiddleware(service Service, logger log.Logger) middleware

NewMiddleware creates a new user Middleware.

func RegisterHandlers

func RegisterHandlers(g *echo.Group, service Service,
	logger log.Logger, requireLogin echo.MiddlewareFunc,
	verifyID echo.MiddlewareFunc)

func WithFilters added in v0.8.0

func WithFilters(ctx context.Context, value map[string][]string) context.Context

WithFilters returns a context that contains the API filters.

Types

type Comment

type Comment struct {
	entity.Comment
}

Comment represents a comment made by a user for a file.

type CreateCommentRequest

type CreateCommentRequest struct {
	Body     string `json:"body" validate:"required"`
	SHA256   string `json:"sha256" validate:"required,alphanum,len=64"`
	Username string
}

CreateCommentRequest represents a comment creation request.

type Repository

type Repository interface {
	// Get returns the comment with the specified comment ID.
	Get(ctx context.Context, id string, fields []string) (entity.Comment, error)
	// Create saves a new comment in the storage.
	Create(ctx context.Context, Comment entity.Comment) error
	// Update updates the comment with given ID in the storage.
	Update(ctx context.Context, User entity.Comment) error
	// Delete removes the comment with given ID from the storage.
	Delete(ctx context.Context, id string) error
	// Exists checks if a comment exists with a given ID.
	Exists(ctx context.Context, id string) (bool, error)
	// Count returns the number of comments.
	Count(ctx context.Context) (int, error)
	// Query returns the list of comments with the given offset and limit.
	Query(ctx context.Context, offset, limit int, fields []string) ([]entity.Comment, error)
}

Repository encapsulates the logic to access comments from the data source.

func NewRepository

func NewRepository(db *dbcontext.DB, logger log.Logger) Repository

NewRepository creates a new comment repository.

type Service

type Service interface {
	Exists(ctx context.Context, id string) (bool, error)
	Get(ctx context.Context, id string, fields []string) (Comment, error)
	Create(ctx context.Context, input CreateCommentRequest) (Comment, error)
	Update(ctx context.Context, id string, input UpdateCommentRequest) (Comment, error)
	Delete(ctx context.Context, id string) (Comment, error)
	Count(ctx context.Context) (int, error)
	Query(ctx context.Context, offset, limit int, fields []string) ([]Comment, error)
}

Service encapsulates usecase logic for files.

func NewService

func NewService(repo Repository, logger log.Logger, actSvc activity.Service,
	userSvc user.Service) Service

NewService creates a new user service.

type UpdateCommentRequest added in v0.4.0

type UpdateCommentRequest struct {
	Body string `json:"body" validate:"required"`
}

UpdateCommentRequest represents a comment update request.

Jump to

Keyboard shortcuts

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