Documentation
¶
Index ¶
- Variables
- func StateValidator(v State) bool
- type CommentQuery
- type CommentTO
- type CommentVO
- type Comments
- func (m *Comments) HandleDeleteComment(ctx *web.Context, creator, comment int64) web.Responser
- func (m *Comments) HandleGetComment(ctx *web.Context, comment int64) web.Responser
- func (m *Comments) HandleGetComments(ctx *web.Context) web.Responser
- func (m *Comments) HandleGetCommentsByTarget(ctx *web.Context, target int64) web.Responser
- func (m *Comments) HandleGetSnapshot(ctx *web.Context, snapshot int64) web.Responser
- func (m *Comments) HandleGetSnapshots(ctx *web.Context, comment int64) web.Responser
- func (m *Comments) HandlePatchComment(ctx *web.Context, creator, comment int64) web.Responser
- func (m *Comments) HandlePostComment(ctx *web.Context, creator, target int64) web.Responser
- func (m *Comments) HandleSetState(ctx *web.Context, comment int64, s State, status int) web.Responser
- type SnapshotVO
- type State
Constants ¶
This section is empty.
Variables ¶
View Source
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 {
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 NewComments ¶ added in v0.13.0
func (*Comments) HandleDeleteComment ¶ added in v0.13.0
HandleDeleteComment 删除指定的评论
comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;
func (*Comments) HandleGetComment ¶ added in v0.13.0
HandleGetComment 获取评论信息
返回参数的实际类型为 CommentVO; comment 为评论的 ID,使用都需要确保值的正确性;
func (*Comments) HandleGetComments ¶ added in v0.13.0
HandleGetComments 获取评论列表
查询参数为 CommentQuery,返回对象为 [query.Page[CommentVO]]
func (*Comments) HandleGetCommentsByTarget ¶ added in v0.13.0
HandleGetCommentsByTarget 获取指定对象的评论列表
查询参数为 query.Limit,返回对象为 [query.Page[CommentVO]],只返回不 hidden 的条目。
func (*Comments) HandleGetSnapshot ¶ added in v0.13.0
HandleGetSnapshot 获取快照的详细信息
NOTE: 关联的评论一旦删除,快照也将不可获取。
snapshot 为快照的 ID;
func (*Comments) HandleGetSnapshots ¶ added in v0.13.0
HandleGetSnapshots 获取评论的快照列表
comment 评论的 ID; 返回 []SnapshotVO;
func (*Comments) HandlePatchComment ¶ added in v0.13.0
HandlePatchComment 修改评论的内容
comment 为评论的 ID; creator 作者,必须与添加时的 creator 一致;
func (*Comments) HandlePostComment ¶ added in v0.13.0
HandlePostComment 添加新的评论
creator 为创建者的 ID,调用者需要确保值的正确性;target 为评论对象的 ID; 提交类型为 CommentTO;
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
func ParseState ¶
func (State) MarshalCBOR ¶ added in v0.8.14
func (State) MarshalText ¶
func (State) OpenAPISchema ¶
func (*State) UnmarshalCBOR ¶ added in v0.8.14
func (*State) UnmarshalText ¶
Click to show internal directories.
Click to hide internal directories.