dao

package
v0.0.0-...-a783adc Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 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 IPostDao

type IPostDao interface {
	GetLatest5Posts(ctx context.Context) ([]*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
}

type Post

type Post struct {
	Sug              string            `bson:"_id"`
	Author           string            `bson:"author"`
	Title            string            `bson:"title"`
	Summary          string            `bson:"summary"`
	Content          string            `bson:"content"`
	CoverImg         string            `bson:"cover_img"`
	Category         string            `bson:"category"`
	Tags             []string          `bson:"tags"`
	Status           domain.PostStatus `bson:"status"`
	Likes            []string          `bson:"likes"`
	LikeCount        int               `bson:"like_count"`
	CommentCount     int               `bson:"comment_count"`
	VisitCount       int               `bson:"visit_count"`
	Priority         int               `bson:"priority"`
	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) DeleteLike

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

func (*PostDao) FindByIdAndIp

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

func (*PostDao) GetLatest5Posts

func (d *PostDao) GetLatest5Posts(ctx context.Context) ([]*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) QueryPostsPage

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

Jump to

Keyboard shortcuts

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