comment

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package comment 评论

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 {
	XMLName struct{} `xml:"comment" json:"-" yaml:"-" cbor:"-"`
	Content string   `json:"content" yaml:"content" cbor:"content" xml:"content"`
	Rate    int      `json:"rate" yaml:"rate" cbor:"rate" xml:"rate,attr"`
	Author  string   `json:"author" yaml:"author" cbor:"author" xml:"author"` // 显示的作者信息
	Parent  int64    `json:"parent" yaml:"parent" cbor:"parent" xml:"parent"` // 父评论
	// contains filtered or unexported fields
}

func (*CommentTO) Filter

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

type CommentVO

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

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

type Module

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

func Install

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

Install 安装数据

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

func Load

func Load(mod *cmfx.Module, tablePrefix string) *Module

func (*Module) HandleDeleteComment

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

HandleDeleteComment 删除指定的评论

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

func (*Module) HandleGetComment

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

HandleGetComment 获取评论信息

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

func (*Module) HandleGetComments

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

HandleGetComments 获取评论列表

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

func (*Module) HandleGetCommentsByTarget

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

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

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

func (*Module) HandleGetSnapshot

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

HandleGetSnapshot 获取快照的详细信息

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

snapshot 为快照的 ID;

func (*Module) HandleGetSnapshots

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

HandleGetSnapshots 获取评论的快照列表

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

func (*Module) HandlePatchComment

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

HandlePatchComment 修改评论的内容

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

func (*Module) HandlePostComment

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

HandlePostComment 添加新的评论

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

func (*Module) HandleSetState

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

HandleSetState 设置状态

type SnapshotVO

type SnapshotVO struct {
	XMLName struct{}  `xml:"comment" json:"-" yaml:"-" cbor:"-" orm:"-"`
	Comment int64     `xml:"comment" json:"comment" yaml:"comment" cbor:"comment" orm:"name(comment)"` // 关联的评论
	ID      int64     `xml:"id" json:"id" yaml:"id" cbor:"id" orm:"name(id)"`
	Created time.Time `xml:"created" json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
	Content string    `xml:"content" json:"content" yaml:"content" cbor:"content" orm:"name(content)"`
	Rate    int64     `xml:"rate" 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) MarshalText

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

MarshalText encoding.TextMarshaler

func (State) OpenAPISchema

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

func (State) String

func (s State) String() string

String fmt.Stringer

func (*State) UnmarshalText

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

UnmarshalText encoding.TextUnmarshaler

Jump to

Keyboard shortcuts

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