dao

package
v0.0.0-...-594631a Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminComment

type AdminComment struct {
	Id string `bson:"_id"`
	// 评论的内容
	PostInfo       PostInfo `bson:"post_info"`
	Content        string   `bson:"content"`
	UserInfo       UserInfo `bson:"user_info"`
	Fid            string   `bson:"fid"`
	Type           int      `bson:"type"`
	ApprovalStatus bool     `bson:"approval_status"`
	CreateTime     int64    `bson:"created_at"`
}

type Comment

type Comment struct {
	mongox.Model `bson:",inline"`
	// 文章信息
	PostInfo PostInfo `bson:"post_info"`
	// 评论的内容
	Content string `bson:"content"`
	// 用户信息
	UserInfo UserInfo4Comment `bson:"user_info"`

	// 该评论下的所有回复的内容
	Replies        []Reply `bson:"replies"`
	ApprovalStatus bool    `bson:"approval_status"`
}

type CommentDao

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

func NewCommentDao

func NewCommentDao(db *mongo.Database) *CommentDao

func (*CommentDao) AddComment

func (d *CommentDao) AddComment(ctx context.Context, comment *Comment) (string, error)

func (*CommentDao) AddCommentReply

func (d *CommentDao) AddCommentReply(ctx context.Context, objectID primitive.ObjectID, commentReply Reply) error

func (*CommentDao) AggregationQuerySkipAndSetLimit

func (d *CommentDao) AggregationQuerySkipAndSetLimit(ctx context.Context, cond bson.D, findOptions *options.FindOptions) ([]AdminComment, int64, error)

func (*CommentDao) CountOfToday

func (d *CommentDao) CountOfToday(ctx context.Context) (int64, error)

func (*CommentDao) DeleteById

func (d *CommentDao) DeleteById(ctx context.Context, objectID primitive.ObjectID) error

func (*CommentDao) DeleteByIds

func (d *CommentDao) DeleteByIds(ctx context.Context, ids []primitive.ObjectID) error

func (*CommentDao) DeleteManyByPostId

func (d *CommentDao) DeleteManyByPostId(ctx context.Context, postId string) error

func (*CommentDao) DeleteReplyByCIdAndRId

func (d *CommentDao) DeleteReplyByCIdAndRId(ctx context.Context, objectID primitive.ObjectID, replyId string) error

func (*CommentDao) Find

func (d *CommentDao) Find(ctx context.Context, findOptions *options.FindOptions) ([]*Comment, int64, error)

func (*CommentDao) FindApprovedCommentById

func (d *CommentDao) FindApprovedCommentById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)

func (*CommentDao) FindApprovedCommentsByPostId

func (d *CommentDao) FindApprovedCommentsByPostId(ctx context.Context, postId string) ([]*Comment, error)

func (*CommentDao) FindByAggregation

func (d *CommentDao) FindByAggregation(ctx context.Context, pipeline mongo.Pipeline) ([]*Comment, error)

func (*CommentDao) FindByObjectIDs

func (d *CommentDao) FindByObjectIDs(ctx context.Context, ids []primitive.ObjectID) ([]*Comment, error)

func (*CommentDao) FindCommentById

func (d *CommentDao) FindCommentById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)

func (*CommentDao) FindCommentWithRepliesById

func (d *CommentDao) FindCommentWithRepliesById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)

func (*CommentDao) FindCommentsByPostId

func (d *CommentDao) FindCommentsByPostId(ctx context.Context, postId string) ([]*Comment, error)

func (*CommentDao) FindDisapprovedCommentByObjectIDs

func (d *CommentDao) FindDisapprovedCommentByObjectIDs(ctx context.Context, commentObjectIDs []primitive.ObjectID) ([]*Comment, error)

func (*CommentDao) FindReplyByCIdAndRId

func (d *CommentDao) FindReplyByCIdAndRId(ctx context.Context, objectCommentID primitive.ObjectID, replyId string) (*ReplyWithPostInfo, error)

func (*CommentDao) FindWithDisapprovedReplyByCidAndRIds

func (d *CommentDao) FindWithDisapprovedReplyByCidAndRIds(ctx context.Context, commentObjID primitive.ObjectID, replyIds []string) (*Comment, error)

func (*CommentDao) FineLatestCommentAndReply

func (d *CommentDao) FineLatestCommentAndReply(ctx context.Context, cnt int) ([]LatestComment, error)

func (*CommentDao) PullReplyByCIdAndRIds

func (d *CommentDao) PullReplyByCIdAndRIds(ctx context.Context, commentObjID primitive.ObjectID, replyIds []string) error

func (*CommentDao) UpdateCReplyStatus2TrueByCidAndRIds

func (d *CommentDao) UpdateCReplyStatus2TrueByCidAndRIds(ctx context.Context, commentObjectID primitive.ObjectID, replyIds []string) error

func (*CommentDao) UpdateCommentReplyStatus

func (d *CommentDao) UpdateCommentReplyStatus(ctx context.Context, objectID primitive.ObjectID, replyId string, commentStatus bool) error

func (*CommentDao) UpdateCommentStatus2True

func (d *CommentDao) UpdateCommentStatus2True(ctx context.Context, objectID primitive.ObjectID) error

func (*CommentDao) UpdateCommentStatus2TrueByIds

func (d *CommentDao) UpdateCommentStatus2TrueByIds(ctx context.Context, ids []primitive.ObjectID) error

type ICommentDao

type ICommentDao interface {
	AddComment(ctx context.Context, comment *Comment) (string, error)
	FindApprovedCommentById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)
	AddCommentReply(ctx context.Context, objectID primitive.ObjectID, commentReply Reply) error
	FineLatestCommentAndReply(ctx context.Context, cnt int) ([]LatestComment, error)
	FindApprovedCommentsByPostId(ctx context.Context, postId string) ([]*Comment, error)
	AggregationQuerySkipAndSetLimit(ctx context.Context, cond bson.D, findOptions *options.FindOptions) ([]AdminComment, int64, error)
	FindCommentById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)
	UpdateCommentStatus2True(ctx context.Context, objectID primitive.ObjectID) error
	FindReplyByCIdAndRId(ctx context.Context, objectCommentID primitive.ObjectID, replyId string) (*ReplyWithPostInfo, error)
	UpdateCommentReplyStatus(ctx context.Context, objectID primitive.ObjectID, replyId string, commentStatus bool) error
	FindCommentWithRepliesById(ctx context.Context, objectID primitive.ObjectID) (*Comment, error)
	DeleteById(ctx context.Context, objectID primitive.ObjectID) error
	DeleteReplyByCIdAndRId(ctx context.Context, objectID primitive.ObjectID, replyId string) error
	CountOfToday(ctx context.Context) (int64, error)
	Find(ctx context.Context, findOptions *options.FindOptions) ([]*Comment, int64, error)
	UpdateCommentStatus2TrueByIds(ctx context.Context, ids []primitive.ObjectID) error
	FindByObjectIDs(ctx context.Context, ids []primitive.ObjectID) ([]*Comment, error)
	UpdateCReplyStatus2TrueByCidAndRIds(ctx context.Context, commentObjectID primitive.ObjectID, replyIds []string) error
	FindWithDisapprovedReplyByCidAndRIds(ctx context.Context, commentObjID primitive.ObjectID, replyIds []string) (*Comment, error)
	FindDisapprovedCommentByObjectIDs(ctx context.Context, commentObjectIDs []primitive.ObjectID) ([]*Comment, error)
	FindByAggregation(ctx context.Context, pipeline mongo.Pipeline) ([]*Comment, error)
	DeleteByIds(ctx context.Context, ids []primitive.ObjectID) error
	PullReplyByCIdAndRIds(ctx context.Context, commentId primitive.ObjectID, replyIds []string) error
	DeleteManyByPostId(ctx context.Context, postId string) error
	FindCommentsByPostId(ctx context.Context, postId string) ([]*Comment, error)
}

type LatestComment

type LatestComment struct {
	PostInfo  `bson:"post_info"`
	Name      string    `bson:"name"`
	Email     string    `bson:"email"`
	Content   string    `bson:"content"`
	CreatedAt time.Time `bson:"created_at"`
}

type PostInfo

type PostInfo struct {
	// 文章 ID
	PostId string `bson:"post_id"`
	// 文章标题字段
	PostTitle string `bson:"post_title"`
	// 文章链接
	PostUrl string `bson:"post_url"`
}

type Reply

type Reply struct {
	ReplyId string `bson:"reply_id"`
	// 回复内容
	Content string `bson:"content"`
	// 被回复的回复 Id
	ReplyToId string `bson:"reply_to_id"`
	// 用户信息
	UserInfo UserInfo4Reply `bson:"user_info"`
	// 被回复用户的信息
	RepliedUserInfo UserInfo4Reply `bson:"replied_user_info"`
	ApprovalStatus  bool           `bson:"approval_status"`
	// 回复时间
	CreatedAt time.Time `bson:"created_at"`
	// 修改时间
	UpdatedAt time.Time `bson:"updated_at"`
}

type ReplyWithPostInfo

type ReplyWithPostInfo struct {
	Reply    `bson:"inline"`
	PostInfo `bson:"post_info"`
}

type UserInfo

type UserInfo struct {
	Name    string `bson:"name"`
	Email   string `bson:"email"`
	Ip      string `bson:"ip"`
	Website string `bson:"website"`
}

type UserInfo4Comment

type UserInfo4Comment UserInfo

type UserInfo4Reply

type UserInfo4Reply UserInfo

Jump to

Keyboard shortcuts

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