comment

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: AGPL-3.0 Imports: 28 Imported by: 0

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: `所有人`},
		{K: `buyer`, V: `当前商品买家`},
		{K: `author`, V: `当前文章作者`},
		{K: `curAgent`, V: `当前产品代理商`},
		{K: `allAgent`, V: `所有代理商`},
		{K: `admin`, V: `管理员`},
		{K: `none`, V: `无`},
	}
	//CommentAllowTypes 允许的类型标识
	CommentAllowTypes = map[string]*CommentConfig{
		`article`: {
			GetTarget:   commentArticleGetTarget,
			CheckMaster: commentArticleCheck,
			AfterAdd:    commentArticleAfterAdd,
			AfterDelete: commentArticleAfterDelete,
			WithTarget:  commentArticleWithTarget,
			Ident:       `article`,
			Label:       `文章`,
		},
		`other`: {
			Ident: `other`,
			Label: `其它`,
		},
	}
)

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) Delete

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

func (*Comment) DeleteBy

func (f *Comment) DeleteBy(row *dbschema.OfficialCommonComment, top bool) error

DeleteBy 删除评论,并遍历删除所有对该评论的回复

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) 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
}

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