comment

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

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)

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) (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)
}

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) (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)
}

Service encapsulates usecase logic for files.

func NewService

func NewService(repo Repository, logger log.Logger, actSvc activity.Service,
	userSvc user.Service, fileSvc file.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