dao

package
v0.0.0-...-77539bd Latest Latest
Warning

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

Go to latest
Published: Apr 27, 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"`
	Status     CommentStatus `bson:"status"`
	CreateTime int64         `bson:"create_time"`
}

type Comment

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

	// 该评论下的所有回复的内容
	Replies []Reply       `bson:"replies"`
	Status  CommentStatus `bson:"status"`
	// 评论时间
	CreateTime int64 `bson:"create_time"`
	// 修改时间
	UpdateTime int64 `bson:"update_time"`
}

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, cmtId string, 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, id string) error

func (*CommentDao) DeleteReplyByCIdAndRId

func (d *CommentDao) DeleteReplyByCIdAndRId(ctx context.Context, commentId string, replyId string) error

func (*CommentDao) FindApprovedCommentById

func (d *CommentDao) FindApprovedCommentById(ctx context.Context, cmtId string) (*Comment, error)

func (*CommentDao) FindCommentById

func (d *CommentDao) FindCommentById(ctx context.Context, id string) (*Comment, error)

func (*CommentDao) FindCommentWithRepliesById

func (d *CommentDao) FindCommentWithRepliesById(ctx context.Context, id string) (*Comment, error)

func (*CommentDao) FindCommentsByPostIdAndCmtStatus

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

func (*CommentDao) FindReplyByCIdAndRId

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

func (*CommentDao) FineLatestCommentAndReply

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

func (*CommentDao) UpdateCommentReplyStatus

func (d *CommentDao) UpdateCommentReplyStatus(ctx context.Context, commentId string, replyId string, commentStatus CommentStatus) error

func (*CommentDao) UpdateCommentStatus

func (d *CommentDao) UpdateCommentStatus(ctx context.Context, id string, commentStatus CommentStatus) error

type CommentStatus

type CommentStatus uint
const (
	// CommentStatusPending 审核中
	CommentStatusPending CommentStatus = iota
	// CommentStatusApproved 审核通过
	CommentStatusApproved
	// CommentStatusHidden 隐藏
	CommentStatusHidden
	// CommentStatusRejected 审核不通过
	CommentStatusRejected
)

type ICommentDao

type ICommentDao interface {
	AddComment(ctx context.Context, comment *Comment) (string, error)
	FindApprovedCommentById(ctx context.Context, cmtId string) (*Comment, error)
	AddCommentReply(ctx context.Context, cmtId string, commentReply Reply) error
	FineLatestCommentAndReply(ctx context.Context, cnt int) ([]LatestComment, error)
	FindCommentsByPostIdAndCmtStatus(ctx context.Context, postId string, cmtStatus uint) ([]*Comment, error)
	AggregationQuerySkipAndSetLimit(ctx context.Context, cond bson.D, findOptions *options.FindOptions) ([]AdminComment, int64, error)
	FindCommentById(ctx context.Context, id string) (*Comment, error)
	UpdateCommentStatus(ctx context.Context, id string, commentStatus CommentStatus) error
	FindReplyByCIdAndRId(ctx context.Context, commentId string, replyId string) (*ReplyWithPostInfo, error)
	UpdateCommentReplyStatus(ctx context.Context, commentId string, replyId string, commentStatus CommentStatus) error
	FindCommentWithRepliesById(ctx context.Context, id string) (*Comment, error)
	DeleteById(ctx context.Context, id string) error
	DeleteReplyByCIdAndRId(ctx context.Context, commentId string, replyId string) error
	CountOfToday(ctx context.Context) (int64, error)
}

type LatestComment

type LatestComment struct {
	PostInfo   `bson:"post_info"`
	Name       string `bson:"name"`
	Email      string `bson:"email"`
	Content    string `bson:"content"`
	CreateTime int64  `bson:"create_time"`
}

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"`
	Status          CommentStatus  `bson:"status"`
	// 回复时间
	CreateTime int64 `bson:"create_time"`
	// 修改时间
	UpdateTime int64 `bson:"update_time"`
}

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