dao

package
v0.0.0-...-8ac8648 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category4Post

type Category4Post struct {
	Id   string `bson:"id"`
	Name string `bson:"name"`
}

type IPostDao

type IPostDao interface {
	GetFrontPosts(ctx context.Context, count int64) ([]*Post, error)
	QueryPostsPage(ctx context.Context, con bson.D, findOptions *options.FindOptions) ([]*Post, int64, error)
	GetPunishedPostById(ctx context.Context, sug string) (*Post, error)
	FindByIdAndIp(ctx context.Context, sug string, ip string) (*Post, error)
	AddLike(ctx context.Context, sug string, ip string) error
	DeleteLike(ctx context.Context, sug string, ip string) error
	IncreaseFieldById(ctx context.Context, id string, field string) error
	AddPost(ctx context.Context, post *Post) error
	DeleteById(ctx context.Context, id string) error
	FindById(ctx context.Context, id string) (*Post, error)
	DecreaseByField(ctx context.Context, id string, filedName string, cnt int) error
	SavePost(ctx context.Context, post *Post) error
	UpdateIsDisplayedById(ctx context.Context, id string, isDisplayed bool) error
	UpdateIsCommentAllowedById(ctx context.Context, id string, isCommentAllowed bool) error
	IncreasePostLikeCount(ctx context.Context, postId string) error
}

type Post

type Post struct {
	Id               string          `bson:"_id"`
	Author           string          `bson:"author"`
	Title            string          `bson:"title"`
	Summary          string          `bson:"summary"`
	Content          string          `bson:"content"`
	CoverImg         string          `bson:"cover_img"`
	Categories       []Category4Post `bson:"categories"`
	Tags             []Tag4Post      `bson:"tags"`
	IsDisplayed      bool            `bson:"is_displayed"`
	LikeCount        int             `bson:"like_count,omitempty"`
	CommentCount     int             `bson:"comment_count,omitempty"`
	VisitCount       int             `bson:"visit_count,omitempty"`
	StickyWeight     int             `bson:"sticky_weight"`
	MetaDescription  string          `bson:"meta_description"`
	MetaKeywords     string          `bson:"meta_keywords"`
	WordCount        int             `bson:"word_count"`
	IsCommentAllowed bool            `bson:"is_comment_allowed"`
	CreateTime       int64           `bson:"create_time"`
	UpdateTime       int64           `bson:"update_time"`
}

type PostDao

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

func NewPostDao

func NewPostDao(db *mongo.Database) *PostDao

func (*PostDao) AddLike

func (d *PostDao) AddLike(ctx context.Context, id string, ip string) error

func (*PostDao) AddPost

func (d *PostDao) AddPost(ctx context.Context, post *Post) error

func (*PostDao) DecreaseByField

func (d *PostDao) DecreaseByField(ctx context.Context, id string, filedName string, cnt int) error

func (*PostDao) DeleteById

func (d *PostDao) DeleteById(ctx context.Context, id string) error

func (*PostDao) DeleteLike

func (d *PostDao) DeleteLike(ctx context.Context, id string, ip string) error

func (*PostDao) FindById

func (d *PostDao) FindById(ctx context.Context, id string) (*Post, error)

func (*PostDao) FindByIdAndIp

func (d *PostDao) FindByIdAndIp(ctx context.Context, id string, ip string) (*Post, error)

func (*PostDao) GetFrontPosts

func (d *PostDao) GetFrontPosts(ctx context.Context, count int64) ([]*Post, error)

func (*PostDao) GetPunishedPostById

func (d *PostDao) GetPunishedPostById(ctx context.Context, id string) (*Post, error)

func (*PostDao) IncreaseFieldById

func (d *PostDao) IncreaseFieldById(ctx context.Context, id string, field string) error

func (*PostDao) IncreasePostLikeCount

func (d *PostDao) IncreasePostLikeCount(ctx context.Context, postId string) error

func (*PostDao) QueryPostsPage

func (d *PostDao) QueryPostsPage(ctx context.Context, con bson.D, findOptions *options.FindOptions) ([]*Post, int64, error)

func (*PostDao) SavePost

func (d *PostDao) SavePost(ctx context.Context, post *Post) error

func (*PostDao) UpdateIsCommentAllowedById

func (d *PostDao) UpdateIsCommentAllowedById(ctx context.Context, id string, isCommentAllowed bool) error

func (*PostDao) UpdateIsDisplayedById

func (d *PostDao) UpdateIsDisplayedById(ctx context.Context, id string, isDisplayed bool) error

type Tag4Post

type Tag4Post struct {
	Id   string `bson:"id"`
	Name string `bson:"name"`
}

Jump to

Keyboard shortcuts

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