Documentation
¶
Overview ¶
Package comment 评论
Index ¶
- Variables
- func StateValidator(v State) bool
- type CommentQuery
- type CommentTO
- type CommentVO
- type Module
- func (m *Module) HandleDeleteComment(ctx *web.Context, creator, comment int64) web.Responser
- func (m *Module) HandleGetComment(ctx *web.Context, comment int64) web.Responser
- func (m *Module) HandleGetComments(ctx *web.Context) web.Responser
- func (m *Module) HandleGetCommentsByTarget(ctx *web.Context, target int64) web.Responser
- func (m *Module) HandleGetSnapshot(ctx *web.Context, snapshot int64) web.Responser
- func (m *Module) HandleGetSnapshots(ctx *web.Context, comment int64) web.Responser
- func (m *Module) HandlePatchComment(ctx *web.Context, creator, comment int64) web.Responser
- func (m *Module) HandlePostComment(ctx *web.Context, creator, target int64) web.Responser
- func (m *Module) HandleSetState(ctx *web.Context, comment int64, s State, status int) web.Responser
- type SnapshotVO
- type State
Constants ¶
This section is empty.
Variables ¶
var ( StateRule = filter.V(StateValidator, locales.InvalidValue) StateSliceRule = filter.SV[[]State](StateValidator, locales.InvalidValue) StateFilter = filter.NewBuilder(StateRule) StateSliceFilter = filter.NewBuilder(StateSliceRule) )
Functions ¶
func StateValidator ¶
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 (*Module) HandleDeleteComment ¶
HandleDeleteComment 删除指定的评论
comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;
func (*Module) HandleGetComment ¶
HandleGetComment 获取评论信息
返回参数的实际类型为 CommentVO; comment 为评论的 ID,使用都需要确保值的正确性;
func (*Module) HandleGetComments ¶
HandleGetComments 获取评论列表
查询参数为 CommentQuery,返回对象为 [query.Page[CommentVO]]
func (*Module) HandleGetCommentsByTarget ¶
HandleGetCommentsByTarget 获取指定对象的评论列表
查询参数为 query.Limit,返回对象为 [query.Page[CommentVO]],只返回不 hidden 的条目。
func (*Module) HandleGetSnapshot ¶
HandleGetSnapshot 获取快照的详细信息
NOTE: 关联的评论一旦删除,快照也将不可获取。
snapshot 为快照的 ID;
func (*Module) HandlePatchComment ¶
HandlePatchComment 修改评论的内容
comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;
func (*Module) HandlePostComment ¶
HandlePostComment 添加新的评论
creator 为创建者的 ID,调用者需要确保值的正确性;target 为评论对象的 ID; 提交类型为 CommentTO;
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
func ParseState ¶
func (State) MarshalText ¶
MarshalText encoding.TextMarshaler
func (State) OpenAPISchema ¶
func (*State) UnmarshalText ¶
UnmarshalText encoding.TextUnmarshaler