news

package
v0.0.0-...-c74069a Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewsNotFound error = errors.New("News not found.")
View Source
var NewsTitleAlreadyExist error = errors.New("News already exist with same title new.")

Functions

This section is empty.

Types

type GetNewsQuery

type GetNewsQuery struct {
	Hashtags []string `query:"hashtags"`
}

type Handler

type Handler struct {
	Service Service
}

func NewHandler

func NewHandler(service Service) Handler

func (*Handler) AddNewsHandler

func (h *Handler) AddNewsHandler(c *fiber.Ctx) error

func (*Handler) DeleteNewsHandler

func (h *Handler) DeleteNewsHandler(c *fiber.Ctx) error

func (*Handler) GetNewHandler

func (h *Handler) GetNewHandler(c *fiber.Ctx) error

func (*Handler) GetNewsHandler

func (h *Handler) GetNewsHandler(c *fiber.Ctx) error

func (*Handler) SetupApp

func (h *Handler) SetupApp(app *fiber.App)

type NewSearchCredentialsDTO

type NewSearchCredentialsDTO struct {
	ID string `json:"id"`
}

type News

type News struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	Image     string    `json:"image"`
	Hashtags  []string  `json:"hashtags"`
	Content   string    `json:"content"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type NewsDTO

type NewsDTO struct {
	Title    string   `json:"title"`
	Image    string   `json:"image"`
	Content  string   `json:"content"`
	Hashtags []string `json:"hashtags"`
}

type NewsPageableResponse

type NewsPageableResponse struct {
	News []News `json:"news"`
	Page Page   `json:"page"`
}

type Page

type Page struct {
	Number        int `json:"number"`
	Size          int `json:"size",omitempty`
	TotalElements int `json:"totalElements",omitempty"`
	TotalPages    int `json:"totalPages",omitempty"`
}

type Repository

type Repository struct {
	MongoClient *mongo.Client
}

func NewRepository

func NewRepository(uri string) Repository

func (*Repository) AddNews

func (r *Repository) AddNews(news News) (*News, error)

func (*Repository) DeleteNews

func (r *Repository) DeleteNews(id string) error

func (*Repository) GetNews

func (r *Repository) GetNews() ([]News, error)

func (*Repository) GetNewsByID

func (r *Repository) GetNewsByID(id string) (*News, error)

type Service

type Service struct {
	Repository Repository
}

func NewService

func NewService(repository Repository) Service

func (*Service) AddNews

func (s *Service) AddNews(newsDTO NewsDTO) (*News, error)

func (*Service) DeleteNews

func (s *Service) DeleteNews(dto string) error

func (*Service) GetNew

func (s *Service) GetNew(newID string) (*News, error)

Jump to

Keyboard shortcuts

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