post

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	Title string `json:"title" validate:"required,max=255"`
	Text  string `json:"text" validate:"required"`
}

type PostHandler

type PostHandler interface {
	GetAllPosts(c *fiber.Ctx) error
	GetPostById(c *fiber.Ctx) error
	CreatePost(c *fiber.Ctx) error
	UpdatePost(c *fiber.Ctx) error
	DeletePost(c *fiber.Ctx) error
}

type PostHandlerImpl

type PostHandlerImpl struct {
	PostService PostService
	// contains filtered or unexported fields
}

func NewPostHandler

func NewPostHandler(postService PostService, validator *validate.XValidator) *PostHandlerImpl

func (*PostHandlerImpl) CreatePost

func (h *PostHandlerImpl) CreatePost(c *fiber.Ctx) error

func (*PostHandlerImpl) DeletePost

func (h *PostHandlerImpl) DeletePost(c *fiber.Ctx) error

func (*PostHandlerImpl) GetAllPosts

func (h *PostHandlerImpl) GetAllPosts(c *fiber.Ctx) error

func (*PostHandlerImpl) GetPostById

func (h *PostHandlerImpl) GetPostById(c *fiber.Ctx) error

func (*PostHandlerImpl) UpdatePost

func (h *PostHandlerImpl) UpdatePost(c *fiber.Ctx) error

type PostRepository

type PostRepository interface {
	FindALL() ([]models.Post, error)
	FindByID(postID uint) (*models.Post, error)
	FindByUserID(authorID uint) ([]models.Post, error)
	Create(post *models.Post) error
	Update(postID uint, updatedFields *models.Post) error
	Delete(postID uint) error
}

type PostRepositoryImpl

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

func NewPostRepository

func NewPostRepository(db *gorm.DB) *PostRepositoryImpl

func (*PostRepositoryImpl) Create

func (repo *PostRepositoryImpl) Create(post *models.Post) error

func (*PostRepositoryImpl) Delete

func (repo *PostRepositoryImpl) Delete(postID uint) error

func (*PostRepositoryImpl) FindALL

func (repo *PostRepositoryImpl) FindALL() ([]models.Post, error)

func (*PostRepositoryImpl) FindByID

func (repo *PostRepositoryImpl) FindByID(postID uint) (*models.Post, error)

func (*PostRepositoryImpl) FindByUserID

func (repo *PostRepositoryImpl) FindByUserID(authorID uint) ([]models.Post, error)

func (*PostRepositoryImpl) Update

func (repo *PostRepositoryImpl) Update(postID uint, updatedFields *models.Post) error

type PostService

type PostService interface {
	GetAllPosts() ([]models.Post, error)
	GetPostById(postID uint) (*models.Post, error)
	GetPostsByAuthorID(authorID uint) ([]models.Post, error)
	CreatePost(post *models.Post) error
	UpdatePost(postID uint, updatedFields *models.Post) error
	DeletePost(postID uint) error
}

type PostServiceImpl

type PostServiceImpl struct {
	PostRepo PostRepository
}

func NewPostService

func NewPostService(postRepo PostRepository) *PostServiceImpl

func (*PostServiceImpl) CreatePost

func (s *PostServiceImpl) CreatePost(post *models.Post) error

func (*PostServiceImpl) DeletePost

func (s *PostServiceImpl) DeletePost(postID uint) error

func (*PostServiceImpl) GetAllPosts

func (s *PostServiceImpl) GetAllPosts() ([]models.Post, error)

func (*PostServiceImpl) GetPostById

func (s *PostServiceImpl) GetPostById(postID uint) (*models.Post, error)

func (*PostServiceImpl) GetPostsByAuthorID

func (s *PostServiceImpl) GetPostsByAuthorID(authorID uint) ([]models.Post, error)

func (*PostServiceImpl) UpdatePost

func (s *PostServiceImpl) UpdatePost(postID uint, updatedFields *models.Post) error

type UpdateRequest

type UpdateRequest struct {
	Title string `json:"title" validate:"required,max=255"`
	Text  string `json:"text" validate:"required"`
}

Jump to

Keyboard shortcuts

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