post

package
v0.0.0-...-dd01cb3 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommentService

type CommentService interface {
	Create(ctx context.Context, req *types.Comment, idPost string) (*types.Comment, error)
	GetCommentsPost(ctx context.Context, idPost string) ([]*types.Comment, error)
}

type Handler

type Handler struct {
	Svc service
}

func NewHandler

func NewHandler(svc service) *Handler

func (*Handler) ArchivePost

func (h *Handler) ArchivePost(w http.ResponseWriter, r *http.Request)

ArchivePost post can no longer be edited or commented

func (*Handler) CreateComment

func (h *Handler) CreateComment(w http.ResponseWriter, r *http.Request)

func (*Handler) DeletePost

func (h *Handler) DeletePost(w http.ResponseWriter, r *http.Request)

func (*Handler) GetCommentsPost

func (h *Handler) GetCommentsPost(w http.ResponseWriter, r *http.Request)

func (*Handler) GetEntireThing

func (h *Handler) GetEntireThing(w http.ResponseWriter, r *http.Request)

GetEntireThing get all post to display in homepage

func (*Handler) GetPost

func (h *Handler) GetPost(w http.ResponseWriter, r *http.Request)

func (*Handler) Routes

func (h *Handler) Routes() []router.Route

func (*Handler) UpdatePost

func (h *Handler) UpdatePost(w http.ResponseWriter, r *http.Request)

type MongoDBRepository

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

func NewMongoDBRepo

func NewMongoDBRepo(session *mgo.Session) *MongoDBRepository

func (*MongoDBRepository) ChangeStatus

func (r *MongoDBRepository) ChangeStatus(ctx context.Context, id string, status types.Status) error

func (*MongoDBRepository) CheckPostBelongTo

func (r *MongoDBRepository) CheckPostBelongTo(ctx context.Context, idCom string, idPost string) (*types.Post, error)

func (*MongoDBRepository) Create

func (r *MongoDBRepository) Create(ctx context.Context, req *types.Post) error

func (*MongoDBRepository) FindByID

func (r *MongoDBRepository) FindByID(ctx context.Context, idPost string) (*types.Post, error)

func (*MongoDBRepository) GetAllPost

func (r *MongoDBRepository) GetAllPost(ctx context.Context, idCom string) ([]*types.Post, error)

func (*MongoDBRepository) GetEntire

func (r *MongoDBRepository) GetEntire(ctx context.Context) ([]*types.Post, error)

func (*MongoDBRepository) UpdatePost

type PolicyService

type PolicyService interface {
	AddPolicy(ctx context.Context, req types.Policy) error
	Validate(ctx context.Context, obj string, act string) error
}

type RepoProvider

type RepoProvider interface {
	Create(ctx context.Context, req *types.Post) error
	GetAllPost(ctx context.Context, idCom string) ([]*types.Post, error)

	CheckPostBelongTo(ctx context.Context, idCom string, idPost string) (*types.Post, error)
	FindByID(ctx context.Context, idPost string) (*types.Post, error)
	UpdatePost(ctx context.Context, id string, p *types.PostUpdateRequest) error
	ChangeStatus(ctx context.Context, id string, status types.Status) error

	GetEntire(ctx context.Context) ([]*types.Post, error)
}

type Service

type Service struct {
	Repo RepoProvider
	// contains filtered or unexported fields
}

func NewService

func NewService(repo RepoProvider, policy PolicyService, cmtService CommentService) *Service

func (*Service) ChangeStatus

func (s *Service) ChangeStatus(ctx context.Context, idPost string, stat types.Status) error

func (*Service) CheckPostBelongTo

func (s *Service) CheckPostBelongTo(ctx context.Context, idCom string, idPost string) (*types.Post, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, req *types.Post, idCom string) (*types.Post, error)

func (*Service) CreateComment

func (s *Service) CreateComment(ctx context.Context, req *types.Comment, idPost string) (*types.Comment, error)

Comments

func (*Service) FindByID

func (s *Service) FindByID(ctx context.Context, idPost string) (*types.Post, error)

func (*Service) GetAll

func (s *Service) GetAll(ctx context.Context, idCom string) ([]*types.Post, error)

func (*Service) GetCommentsPost

func (s *Service) GetCommentsPost(ctx context.Context, idPost string) ([]*types.Comment, error)

func (*Service) GetEntire

func (s *Service) GetEntire(ctx context.Context) ([]*types.Post, error)

func (*Service) UpdatePost

func (s *Service) UpdatePost(ctx context.Context, idPost string, p *types.PostUpdateRequest) error

Jump to

Keyboard shortcuts

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