comment

package
v0.0.0-...-f176ba3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: AGPL-3.0 Imports: 29 Imported by: 3

Documentation

Index

Constants

View Source
const (
	BehaviorName = `comment`
)

Variables

View Source
var (
	//CommentAllowUsers all-所有人;buyer-当前商品买家;author-当前文章作者;admin-管理员;allAgent-所有代理;curAgent-当前产品代理;none-无人;designated-指定人员
	CommentAllowUsers = []echo.KV{
		{K: `all`, V: echo.T(`所有人`)},
		{K: `buyer`, V: echo.T(`当前商品买家`)},
		{K: `author`, V: echo.T(`当前文章作者`)},
		{K: `curAgent`, V: echo.T(`当前产品代理商`)},
		{K: `allAgent`, V: echo.T(`所有代理商`)},
		{K: `admin`, V: echo.T(`管理员`)},
		{K: `none`, V: echo.T(`无`)},
	}
	//CommentAllowTypes 允许的类型标识
	CommentAllowTypes = map[string]*CommentConfig{
		`article`: {
			GetTarget:   commentArticleGetTarget,
			CheckMaster: commentArticleCheck,
			AfterAdd:    commentArticleAfterAdd,
			AfterDelete: commentArticleAfterDelete,
			WithTarget:  commentArticleWithTarget,
			Ident:       `article`,
			Label:       echo.T(`文章`),
		},
		`other`: {
			Ident: `other`,
			Label: echo.T(`其它`),
		},
	}
)

Functions

func CommentOpen

func CommentOpen() bool

func CommentReview

func CommentReview() bool

func CommentSetting

func CommentSetting() string

func NeedWithQuoteComment

func NeedWithQuoteComment(c echo.Context) bool

func PureJSONCommentList

func PureJSONCommentList(c echo.Context) bool

Types

type Comment

type Comment struct {
	*dbschema.OfficialCommonComment
}

func NewComment

func NewComment(ctx echo.Context) *Comment

func (*Comment) Add

func (f *Comment) Add() (pk interface{}, err error)

func (*Comment) CustomerPendingCount

func (f *Comment) CustomerPendingCount(customerID interface{}) (int64, error)

func (*Comment) CustomerPendingTodayCount

func (f *Comment) CustomerPendingTodayCount(customerID interface{}) (int64, error)

func (*Comment) CustomerTodayCount

func (f *Comment) CustomerTodayCount(customerID interface{}) (int64, error)

func (*Comment) DecrRepliesBy

func (f *Comment) DecrRepliesBy(in *dbschema.OfficialCommonComment) error

func (*Comment) Delete

func (f *Comment) Delete(mw func(db.Result) db.Result, args ...interface{}) error

func (*Comment) Edit

func (f *Comment) Edit(mw func(db.Result) db.Result, args ...interface{}) error

func (*Comment) GetTargetIDs

func (f *Comment) GetTargetIDs(cond *db.Compounds, limit int, offset int) ([]uint64, error)

func (*Comment) IncrRepliesBy

func (f *Comment) IncrRepliesBy(in *dbschema.OfficialCommonComment) error

func (*Comment) ListCond

func (f *Comment) ListCond(typ, subType string, id uint64, flat bool, tableAlias ...string) *db.Compounds

func (*Comment) ListReplyCond

func (f *Comment) ListReplyCond(commentID uint64) *db.Compounds

func (*Comment) ListReplyCondMutiRoot

func (f *Comment) ListReplyCondMutiRoot(commentIDs []uint64) *db.Compounds

func (*Comment) RowNums

func (f *Comment) RowNums(targetType, subType string, targetID uint64, ids []uint64) (map[uint64]int, error)

func (*Comment) SetCustomerID

func (f *Comment) SetCustomerID(customerID uint64)

func (*Comment) SetUserID

func (f *Comment) SetUserID(userID uint)

func (*Comment) WithExtra

type CommentAndCustomer

type CommentAndCustomer struct {
	*dbschema.OfficialCommonComment
	Customer *dbschema.OfficialCustomer
}

type CommentAndExtra

type CommentAndExtra struct {
	*CommentAndReplyTarget
	FloorNumber      int
	ReplyFloorNumber int
	Extra            echo.H
}

func QueryCommentList

func QueryCommentList(c echo.Context, articleID uint64, articleSN string, targetType string, subType string, flat bool, urlLayout string, pagingVarSuffix ...string) ([]*CommentAndExtra, error)

QueryCommentList 查询评论列表 @param c echo.Context @param articleID uint64 文章ID @param articleSN string 文章SN @param targetType string 评论目标类型 @param subType string 评论子类型 @param flat bool 是否平铺评论 @param urlLayout string 分页的 URL 格式 @param pagingVarSuffix ...string 分页的参数后缀 @return []*CommentAndExtra 评论列表 @return error 错误

func QueryCommentReplyList

func QueryCommentReplyList(c echo.Context, commentID uint64, urlLayout string, pagingVarSuffix ...string) ([]*CommentAndExtra, error)

QueryCommentReplyList 根据评论ID查询评论下的回复列表

commentID: 评论ID
urlLayout:  URL前缀
pagingVarSuffix:  分页变量后缀

返回评论下的回复列表,如果评论不存在,则返回DataNotFound错误

type CommentAndExtraLite

type CommentAndExtraLite struct {
	*CommentLite
	User     *modelAuthor.User     `db:"-,relation=id:owner_id|gtZero|eq(owner_type:user),columns=id&username&avatar" json:",omitempty"`
	Customer *modelAuthor.Customer `db:"-,relation=id:owner_id|gtZero|eq(owner_type:customer),columns=id&name&avatar" json:",omitempty"`
}

func (*CommentAndExtraLite) Name_

func (c *CommentAndExtraLite) Name_() string

type CommentAndReplyTarget

type CommentAndReplyTarget struct {
	*dbschema.OfficialCommonComment
	ReplyTarget *CommentAndExtraLite `` /* 145-byte string literal not displayed */
}

type CommentConfig

type CommentConfig struct {
	SN2ID       func(ctx echo.Context, sn string) (uint64, error) // 序列号转ID
	GetTarget   func(ctx echo.Context, targetID uint64) (res echo.H, breadcrumb []echo.KV, detailURL string, err error)
	CheckMaster func(echo.Context, *dbschema.OfficialCommonComment) error
	AfterAdd    func(echo.Context, *dbschema.OfficialCommonComment) error
	AfterEdit   func(echo.Context, *dbschema.OfficialCommonComment) error
	AfterDelete func(echo.Context, *dbschema.OfficialCommonComment) error
	WithTarget  func(
		ctx echo.Context,
		listx []*CommentAndExtra,
		productIdOwnerIds map[string]map[string]map[string][]uint64,
		targets map[string][]uint64,
		targetObject map[uint64][]int,
	) ([]*CommentAndExtra, error)
	Ident string
	Label string
}

type CommentLite

type CommentLite struct {
	Id        uint64 `db:"id" bson:"id" json:"id" xml:"id"` // 关联值字段不能缺少
	OwnerId   uint64 `db:"owner_id" bson:"owner_id" comment:"评论者ID" json:"owner_id" xml:"owner_id"`
	OwnerType string `` /* 135-byte string literal not displayed */
	Content   string `db:"content" bson:"content" comment:"评论内容" json:"content" xml:"content"`
	Contype   string `db:"contype" bson:"contype" comment:"内容类型" json:"contype" xml:"contype"`
	Created   uint   `db:"created" bson:"created" comment:"创建时间" json:"created" xml:"created"`
	Updated   uint   `db:"updated" bson:"updated" comment:"编辑时间" json:"updated" xml:"updated"`
	Display   string `db:"display" bson:"display" comment:"显示" json:"display" xml:"display"`
}

func (*CommentLite) Name_

func (c *CommentLite) Name_() string

Jump to

Keyboard shortcuts

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