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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

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

	// 该评论下的所有回复的内容
	Replies []CommentReply `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 CommentReply) error

func (*CommentDao) FindCommentById

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

func (*CommentDao) FindCommentsByPostIdAndCmtStatus

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

func (*CommentDao) FineLatestCommentAndReply

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

type CommentReply

type CommentReply 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 CommentStatus

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

type ICommentDao

type ICommentDao interface {
	AddComment(ctx context.Context, comment Comment) (string, error)
	FindCommentById(ctx context.Context, cmtId string) (*Comment, error)
	AddCommentReply(ctx context.Context, cmtId string, commentReply CommentReply) error
	FineLatestCommentAndReply(ctx context.Context, cnt int) ([]LatestComment, error)
	FindCommentsByPostIdAndCmtStatus(ctx context.Context, postId string, cmtStatus uint) ([]*Comment, error)
}

type LatestComment

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

type PostInfo4Comment

type PostInfo4Comment struct {
	// 文章 ID
	PostId string `bson:"post_id"`
	// 文章标题字段
	PostTitle string `bson:"post_title"`
}

type UserInfo4Comment

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

type UserInfo4Reply

type UserInfo4Reply UserInfo4Comment

Jump to

Keyboard shortcuts

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