comment

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func StateValidator

func StateValidator(v State) bool

Types

type CommentQuery

type CommentQuery struct {
	query.Text
	Created time.Time `query:"created"`
	State   []State   `query:"state,visible,top"`
	// contains filtered or unexported fields
}

func (*CommentQuery) Filter

func (q *CommentQuery) Filter(ctx *web.FilterContext)

type CommentTO

type CommentTO struct {
	Content string `json:"content" yaml:"content" cbor:"content"`
	Rate    int    `json:"rate" yaml:"rate" cbor:"rate"`
	Author  string `json:"author" yaml:"author" cbor:"author"` // 显示的作者信息
	Parent  int64  `json:"parent" yaml:"parent" cbor:"parent"` // 父评论
	// contains filtered or unexported fields
}

func (*CommentTO) Filter

func (to *CommentTO) Filter(ctx *web.FilterContext)

type CommentVO

type CommentVO struct {
	ID       int64     `json:"id" yaml:"id" cbor:"id" orm:"name(id)"`
	Author   string    `json:"author" yaml:"author" cbor:"author" orm:"name(author)"`
	Created  time.Time `json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
	Modified time.Time `json:"modified" yaml:"modified" cbor:"modified" orm:"name(modified)"`
	Content  string    `json:"content" yaml:"content" cbor:"content" orm:"name(content)"`

	Rate  int          `json:"rate,omitempty" yaml:"rate,omitempty" cbor:"rate,omitempty" orm:"name(rate)"`
	State State        `json:"state,omitempty" yaml:"state,omitempty" cbor:"state,omitempty" orm:"name(state)"`
	Items []*CommentVO `json:"items,omitempty" yaml:"items,omitempty" cbor:"items,omitempty" orm:"-"`
}

type Comments added in v0.13.0

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

Comments 评论管理

func Install

func Install(mod *cmfx.Module, tablePrefix string) *Comments

Install 安装数据

mod 所属模块;tablePrefix 表名前缀;

func NewComments added in v0.13.0

func NewComments(mod *cmfx.Module, tablePrefix string) *Comments

func (*Comments) HandleDeleteComment added in v0.13.0

func (m *Comments) HandleDeleteComment(ctx *web.Context, creator, comment int64) web.Responser

HandleDeleteComment 删除指定的评论

comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;

func (*Comments) HandleGetComment added in v0.13.0

func (m *Comments) HandleGetComment(ctx *web.Context, comment int64) web.Responser

HandleGetComment 获取评论信息

返回参数的实际类型为 CommentVO; comment 为评论的 ID,使用都需要确保值的正确性;

func (*Comments) HandleGetComments added in v0.13.0

func (m *Comments) HandleGetComments(ctx *web.Context) web.Responser

HandleGetComments 获取评论列表

查询参数为 CommentQuery,返回对象为 [query.Page[CommentVO]]

func (*Comments) HandleGetCommentsByTarget added in v0.13.0

func (m *Comments) HandleGetCommentsByTarget(ctx *web.Context, target int64) web.Responser

HandleGetCommentsByTarget 获取指定对象的评论列表

查询参数为 query.Limit,返回对象为 [query.Page[CommentVO]],只返回不 hidden 的条目。

func (*Comments) HandleGetSnapshot added in v0.13.0

func (m *Comments) HandleGetSnapshot(ctx *web.Context, snapshot int64) web.Responser

HandleGetSnapshot 获取快照的详细信息

NOTE: 关联的评论一旦删除,快照也将不可获取。

snapshot 为快照的 ID;

func (*Comments) HandleGetSnapshots added in v0.13.0

func (m *Comments) HandleGetSnapshots(ctx *web.Context, comment int64) web.Responser

HandleGetSnapshots 获取评论的快照列表

comment 评论的 ID; 返回 []SnapshotVO;

func (*Comments) HandlePatchComment added in v0.13.0

func (m *Comments) HandlePatchComment(ctx *web.Context, creator, comment int64) web.Responser

HandlePatchComment 修改评论的内容

comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;

func (*Comments) HandlePostComment added in v0.13.0

func (m *Comments) HandlePostComment(ctx *web.Context, creator, target int64) web.Responser

HandlePostComment 添加新的评论

creator 为创建者的 ID,调用者需要确保值的正确性;target 为评论对象的 ID; 提交类型为 CommentTO

func (*Comments) HandleSetState added in v0.13.0

func (m *Comments) HandleSetState(ctx *web.Context, comment int64, s State, status int) web.Responser

HandleSetState 设置状态

type SnapshotVO

type SnapshotVO struct {
	Comment int64     `json:"comment" yaml:"comment" cbor:"comment" orm:"name(comment)"` // 关联的评论
	ID      int64     `json:"id" yaml:"id" cbor:"id" orm:"name(id)"`
	Created time.Time `json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
	Content string    `json:"content" yaml:"content" cbor:"content" orm:"name(content)"`
	Rate    int64     `json:"rate" yaml:"rate" cbor:"rate" orm:"name(rate)"`
}

SnapshotVO 摘要信息

type State

type State int8
const (
	StateVisible State = iota // 显示
	StateHidden               // 隐藏
	StateTop                  // 置顶
)

func ParseState

func ParseState(v string) (State, error)

func (State) IsValid

func (s State) IsValid() bool

func (State) MarshalCBOR added in v0.8.14

func (s State) MarshalCBOR() ([]byte, error)

func (State) MarshalText

func (s State) MarshalText() ([]byte, error)

func (State) OpenAPISchema

func (State) OpenAPISchema(s *openapi.Schema)

func (State) String

func (s State) String() string

String fmt.Stringer

func (*State) UnmarshalCBOR added in v0.8.14

func (s *State) UnmarshalCBOR(p []byte) error

func (*State) UnmarshalText

func (s *State) UnmarshalText(p []byte) error

Jump to

Keyboard shortcuts

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