comment

package
v0.0.0-...-72fb90f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPermissionDenied = errors.New("permission denied")

Functions

This section is empty.

Types

type CommentHandler

type CommentHandler interface {
	GetMyComment(c *fiber.Ctx) error
	GetUserComments(c *fiber.Ctx) error
	GetAllCommentsPost(c *fiber.Ctx) error
	CreateComments(c *fiber.Ctx) error
	UpdateComment(c *fiber.Ctx) error
	DeleteComment(c *fiber.Ctx) error
}

type CommentHandlerImpl

type CommentHandlerImpl struct {
	CommentService CommentService
	// contains filtered or unexported fields
}

func NewCommentHandler

func NewCommentHandler(commentService CommentService, validator *validate.XValidator) *CommentHandlerImpl

func (*CommentHandlerImpl) CreateComments

func (h *CommentHandlerImpl) CreateComments(c *fiber.Ctx) error

func (*CommentHandlerImpl) DeleteComment

func (h *CommentHandlerImpl) DeleteComment(c *fiber.Ctx) error

func (*CommentHandlerImpl) GetAllCommentsPost

func (h *CommentHandlerImpl) GetAllCommentsPost(c *fiber.Ctx) error

func (*CommentHandlerImpl) GetMyComment

func (h *CommentHandlerImpl) GetMyComment(c *fiber.Ctx) error

func (*CommentHandlerImpl) GetUserComments

func (h *CommentHandlerImpl) GetUserComments(c *fiber.Ctx) error

func (*CommentHandlerImpl) UpdateComment

func (h *CommentHandlerImpl) UpdateComment(c *fiber.Ctx) error

type CommentRepository

type CommentRepository interface {
	FindCommentsByPostID(comment *models.Comment) ([]models.Comment, error)
	CreateCommentByPostID(comment *models.Comment) error
	UpdateCommentByCommentAndPostID(comment *models.Comment) error
	DeleteCommentByCommentAndPostID(comment *models.Comment) error
}

type CommentRepositoryImpl

type CommentRepositoryImpl struct {
	// contains filtered or unexported fields
}

func NewCommentRepository

func NewCommentRepository(db *gorm.DB) *CommentRepositoryImpl

func (*CommentRepositoryImpl) CreateCommentByPostID

func (r *CommentRepositoryImpl) CreateCommentByPostID(comment *models.Comment) error

func (*CommentRepositoryImpl) DeleteCommentByCommentAndPostID

func (r *CommentRepositoryImpl) DeleteCommentByCommentAndPostID(comment *models.Comment) error

func (*CommentRepositoryImpl) FindCommentsByPostID

func (r *CommentRepositoryImpl) FindCommentsByPostID(comment *models.Comment) ([]models.Comment, error)

func (*CommentRepositoryImpl) UpdateCommentByCommentAndPostID

func (r *CommentRepositoryImpl) UpdateCommentByCommentAndPostID(comment *models.Comment) error

type CommentService

type CommentService interface {
	GetCommentsByPostID(postID, userID uint) (*GetCommentsResponse, error)
	CreateCommentByPostID(postID, authorID uint, comment *CreateCommentRequest) error
	UpdateComment(commentID, PostID, userID uint, updatedFields *UpdateCommentRequest) error
	DeleteComment(commentID, PostID, userID uint) error
}

type CommentServiceImpl

type CommentServiceImpl struct {
	CommentRepo CommentRepository
	PostRepo    post.PostRepository
}

func NewCommentService

func NewCommentService(commentRepo CommentRepository, postRepo post.PostRepository) *CommentServiceImpl

func (*CommentServiceImpl) CreateCommentByPostID

func (s *CommentServiceImpl) CreateCommentByPostID(postID, authorID uint, comment *CreateCommentRequest) error

func (*CommentServiceImpl) DeleteComment

func (s *CommentServiceImpl) DeleteComment(commentID, PostID, userID uint) error

func (*CommentServiceImpl) GetCommentsByPostID

func (s *CommentServiceImpl) GetCommentsByPostID(postID, userID uint) (*GetCommentsResponse, error)

func (*CommentServiceImpl) UpdateComment

func (s *CommentServiceImpl) UpdateComment(commentID, postID, userID uint, fields *UpdateCommentRequest) error

type CreateCommentRequest

type CreateCommentRequest struct {
	Title   string `json:"title" validate:"required,max=255"`
	Content string `json:"content" validate:"required,max=255"`
}

type GetCommentResponseBody

type GetCommentResponseBody struct {
	ID         uint      `json:"id"`
	Title      string    `json:"title"`
	Content    string    `json:"content"`
	AuthorName string    `json:"author_name"`
	PostTitle  string    `json:"post_title"`
	CreatedAt  time.Time `json:"created_at"`
}

type GetCommentsResponse

type GetCommentsResponse struct {
	Comments []GetCommentResponseBody `json:"comments"`
}

type UpdateCommentRequest

type UpdateCommentRequest struct {
	Content string `json:"content" validate:"required,max=255"`
}

Jump to

Keyboard shortcuts

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