Documentation
¶
Overview ¶
Package article 文章管理
Index ¶
- type ArticlePatchTO
- type ArticleTO
- type ArticleVO
- type Module
- func (m *Module) HandleDeleteArticle(ctx *web.Context, article, deleter int64) web.Responser
- func (m *Module) HandleGetArticle(ctx *web.Context, article int64) web.Responser
- func (m *Module) HandleGetArticles(ctx *web.Context) web.Responser
- func (m *Module) HandleGetArticlesByTag(ctx *web.Context, tag int64) web.Responser
- func (m *Module) HandleGetArticlesByTopic(ctx *web.Context, topic int64) web.Responser
- func (m *Module) HandleGetSnapshot(ctx *web.Context, snapshot int64) web.Responser
- func (m *Module) HandleGetSnapshots(ctx *web.Context, article int64) web.Responser
- func (m *Module) HandlePatchArticle(ctx *web.Context, article, modifier int64) web.Responser
- func (m *Module) HandlePostArticle(ctx *web.Context, creator int64) web.Responser
- func (m *Module) Tags() *tag.Module
- func (m *Module) Topics() *linkage.Module
- type OverviewQuery
- type OverviewVO
- type SnapshotOverviewVO
- type SnapshotVO
- type TagOverviewQuery
- type TopicOverviewQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArticlePatchTO ¶
type ArticlePatchTO struct {
XMLName struct{} `xml:"article" json:"-" yaml:"-" cbor:"-"`
Author string `json:"author" yaml:"author" cbor:"author" xml:"author"`
Title string `json:"title" yaml:"title" cbor:"title" xml:"title"`
Images []string `json:"images" yaml:"images" cbor:"images" xml:"images>image"`
Keywords string `json:"keywords" yaml:"keywords" cbor:"keywords" xml:"keywords"`
Summary string `json:"summary" yaml:"summary" cbor:"summary" xml:"summary"`
Content string `json:"content" yaml:"content" cbor:"content" xml:"content"`
Topics []int64 `json:"topics" yaml:"topics" cbor:"topics" xml:"topics>topic"`
Tags []int64 `json:"tags" yaml:"tags" cbor:"tags" xml:"tags>tag"`
// contains filtered or unexported fields
}
func (*ArticlePatchTO) Filter ¶
func (to *ArticlePatchTO) Filter(ctx *web.FilterContext)
type ArticleTO ¶
type ArticleTO struct {
XMLName struct{} `xml:"article" json:"-" yaml:"-" cbor:"-"`
Author string `json:"author" yaml:"author" cbor:"author" xml:"author"`
Title string `json:"title" yaml:"title" cbor:"title" xml:"title"`
Images []string `json:"images" yaml:"images" cbor:"images" xml:"images>image"`
Keywords string `json:"keywords" yaml:"keywords" cbor:"keywords" xml:"keywords"`
Summary string `json:"summary" yaml:"summary" cbor:"summary" xml:"summary"`
Content string `json:"content" yaml:"content" cbor:"content" xml:"content"`
Topics []int64 `json:"topics" yaml:"topics" cbor:"topics" xml:"topics>topic"`
Tags []int64 `json:"tags" yaml:"tags" cbor:"tags" xml:"tags>tag"`
Slug string `json:"slug" yaml:"slug" cbor:"slug" xml:"slug"`
Views int `json:"views" yaml:"views" cbor:"views" xml:"views"`
Order int `json:"order" yaml:"order" cbor:"order" xml:"order"`
// contains filtered or unexported fields
}
func (*ArticleTO) Filter ¶
func (to *ArticleTO) Filter(ctx *web.FilterContext)
type ArticleVO ¶
type ArticleVO struct {
XMLName struct{} `xml:"article" json:"-" yaml:"-" cbor:"-" orm:"-"`
ID int64 `orm:"name(id)" json:"id" yaml:"id" cbor:"id" xml:"id,attr"`
Snapshot int64 `orm:"name(snapshot)" json:"snapshot" yaml:"snapshot" cbor:"snapshot" xml:"snapshot,attr"` // 此文章对应的快照 ID
Slug string `orm:"name(slug);len(100);unique(slug)" json:"slug" yaml:"slug" cbor:"slug" xml:"slug"`
Views int `orm:"name(views)" json:"views" yaml:"views" cbor:"views" xml:"views,attr"`
Order int `orm:"name(order)" json:"order" yaml:"order" cbor:"order" xml:"order,attr"`
Author string `orm:"name(author);len(20)" json:"author" yaml:"author" cbor:"author" xml:"author"`
Title string `orm:"name(title);len(100)" json:"title" yaml:"title" cbor:"title" xml:"title"`
Images types.Strings `orm:"name(images);len(1000)" json:"images" yaml:"images" cbor:"images" xml:"images>image"`
Keywords string `orm:"name(keywords)" json:"keywords" yaml:"keywords" cbor:"keywords" xml:"keywords"`
Summary string `orm:"name(summary);len(2000)" json:"summary" yaml:"summary" cbor:"summary" xml:"summary,cdata"`
Content string `orm:"name(content);len(-1)" json:"content" yaml:"content" cbor:"content" xml:"content,cdata"`
Created time.Time `orm:"name(created)" json:"created" yaml:"created" cbor:"created" xml:"created"`
Modified time.Time `orm:"name(modified)" json:"modified" yaml:"modified" cbor:"modified" xml:"modified"`
// 分类信息
Topics []int64 `orm:"-" json:"topics" yaml:"topics" cbor:"topics" xml:"topics>topic"`
Tags []int64 `orm:"-" json:"tags" yaml:"tags" cbor:"tags" xml:"tags>tag"`
// 用于保存最后一次的快照 ID
Last int64 `orm:"name(last)" json:"-" yaml:"-" cbor:"-" xml:"-"`
}
ArticleVO 文章的详细内容
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) HandleDeleteArticle ¶
HandleDeleteArticle 删除指定的文章
article 为文章的 ID; deleter 为删除者的 ID,调用者需要确保值的正确性;
func (*Module) HandleGetArticle ¶
HandleGetArticle 获取指定文章的详细信息
返回参数的实际类型为 ArticleVO; article 为文章的 ID,使用都需要确保值的正确性;
func (*Module) HandleGetArticles ¶
HandleGetArticles 获取文章列表
查询参数为 OverviewQuery,返回对象为 [query.Page[OverviewVO]]
func (*Module) HandleGetArticlesByTag ¶
HandleGetArticlesByTag 获取文章列表
查询参数为 TagOverviewQuery,返回对象为 [query.Page[OverviewVO]]
func (*Module) HandleGetArticlesByTopic ¶
HandleGetArticlesByTopic 获取文章列表
查询参数为 TopicOverviewQuery,返回对象为 [query.Page[OverviewVO]]
func (*Module) HandleGetSnapshot ¶
HandleGetSnapshot 获取快照的详细信息
NOTE: 关联的文章一旦删除,快照也将不可获取。
snapshot 为快照的 ID;
func (*Module) HandlePatchArticle ¶
HandlePatchArticle 修改文章的内容
article 为文章的 ID; modifier 为修改者的 ID,调用者需要确保值的正确性;
func (*Module) HandlePostArticle ¶
HandlePostArticle 创建新的文章
creator 为创建者的 ID,调用者需要确保值的正确性; 提交类型为 ArticleTO;
type OverviewQuery ¶
type OverviewQuery struct {
query.Text
Created time.Time `query:"created"`
Tags []int64 `query:"tag"`
Topics []int64 `query:"topic"`
// contains filtered or unexported fields
}
func (*OverviewQuery) Filter ¶
func (q *OverviewQuery) Filter(ctx *web.FilterContext)
type OverviewVO ¶
type OverviewVO struct {
XMLName struct{} `xml:"overview" json:"-" yaml:"-" cbor:"-" orm:"-"`
ID int64 `xml:"id" json:"id" yaml:"id" cbor:"id" orm:"name(id)"`
Slug string `xml:"slug" json:"slug" yaml:"slug" cbor:"slug" orm:"name(slug)"`
Views int `xml:"views" json:"views" yaml:"views" cbor:"views" orm:"name(views)"`
Order int `xml:"order" json:"order" yaml:"order" cbor:"order" orm:"name(order)"`
Author string `xml:"author" json:"author" yaml:"author" cbor:"author" orm:"name(author)"`
Title string `xml:"title" json:"title" yaml:"title" cbor:"title" orm:"name(title)"`
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)"`
}
OverviewVO 文章摘要信息
type SnapshotOverviewVO ¶
type SnapshotOverviewVO struct {
XMLName struct{} `xml:"snapshot" json:"-" yaml:"-" cbor:"-" orm:"-"`
Article int64 `xml:"article" json:"article" yaml:"article" cbor:"article" orm:"name(article)"` // 关联的文章
ID int64 `xml:"id" json:"id" yaml:"id" cbor:"id" orm:"name(id)"` // 快照 ID
Author string `xml:"author" json:"author" yaml:"author" cbor:"author" orm:"name(author)"`
Title string `xml:"title" json:"title" yaml:"title" cbor:"title" orm:"name(title)"`
Created time.Time `xml:"created" json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
}
SnapshotOverviewVO 文章快照的摘要信息
type SnapshotVO ¶
type SnapshotVO struct {
XMLName struct{} `xml:"article" json:"-" yaml:"-" cbor:"-" orm:"-"`
ID int64 `orm:"name(id)" json:"id" yaml:"id" cbor:"id" xml:"id,attr"` // 快照 ID
Article int64 `orm:"name(article)" json:"article" yaml:"article" cbor:"article" xml:"article,attr"` // 快照关联的文章 ID
Slug string `orm:"name(slug);len(100);unique(slug)" json:"slug" yaml:"slug" cbor:"slug" xml:"slug"`
Author string `orm:"name(author);len(20)" json:"author" yaml:"author" cbor:"author" xml:"author"`
Title string `orm:"name(title);len(100)" json:"title" yaml:"title" cbor:"title" xml:"title"`
Images types.Strings `orm:"name(images);len(1000)" json:"images" yaml:"images" cbor:"images" xml:"images>image"`
Keywords string `orm:"name(keywords)" json:"keywords" yaml:"keywords" cbor:"keywords" xml:"keywords"`
Summary string `orm:"name(summary);len(2000)" json:"summary" yaml:"summary" cbor:"summary" xml:"summary,cdata"`
Content string `orm:"name(content);len(-1)" json:"content" yaml:"content" cbor:"content" xml:"content,cdata"`
Created time.Time `orm:"name(created)" json:"created" yaml:"created" cbor:"created" xml:"created"`
}
SnapshotVO 文章快照详细内容
type TagOverviewQuery ¶
type TagOverviewQuery struct {
query.Text
Created time.Time `query:"created"`
Topics []int64 `query:"topic"`
// contains filtered or unexported fields
}
func (*TagOverviewQuery) Filter ¶
func (q *TagOverviewQuery) Filter(ctx *web.FilterContext)
type TopicOverviewQuery ¶
type TopicOverviewQuery struct {
query.Text
Created time.Time `query:"created"`
Tags []int64 `query:"tag"`
// contains filtered or unexported fields
}
func (*TopicOverviewQuery) Filter ¶
func (q *TopicOverviewQuery) Filter(ctx *web.FilterContext)