article

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: 14 Imported by: 0

Documentation

Overview

Package article 文章管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticlePatchTO

type ArticlePatchTO struct {
	Author   string   `json:"author" yaml:"author" cbor:"author"`
	Title    string   `json:"title" yaml:"title" cbor:"title"`
	Images   []string `json:"images" yaml:"images" cbor:"images"`
	Keywords string   `json:"keywords" yaml:"keywords" cbor:"keywords"`
	Summary  string   `json:"summary" yaml:"summary" cbor:"summary"`
	Content  string   `json:"content" yaml:"content" cbor:"content"`
	Topics   []int64  `json:"topics" yaml:"topics" cbor:"topics"`
	Tags     []int64  `json:"tags" yaml:"tags" cbor:"tags"`
	// contains filtered or unexported fields
}

func (*ArticlePatchTO) Filter

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

type ArticleTO

type ArticleTO struct {
	Author   string   `json:"author" yaml:"author" cbor:"author"`
	Title    string   `json:"title" yaml:"title" cbor:"title"`
	Images   []string `json:"images" yaml:"images" cbor:"images"`
	Keywords string   `json:"keywords" yaml:"keywords" cbor:"keywords"`
	Summary  string   `json:"summary" yaml:"summary" cbor:"summary"`
	Content  string   `json:"content" yaml:"content" cbor:"content"`
	Topics   []int64  `json:"topics" yaml:"topics" cbor:"topics"`
	Tags     []int64  `json:"tags" yaml:"tags" cbor:"tags"`
	Slug     string   `json:"slug" yaml:"slug" cbor:"slug"`
	Views    int      `json:"views" yaml:"views" cbor:"views"`
	Order    int      `json:"order" yaml:"order" cbor:"order"`
	// contains filtered or unexported fields
}

func (*ArticleTO) Filter

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

type ArticleVO

type ArticleVO struct {
	ID       int64         `orm:"name(id)" json:"id" yaml:"id" cbor:"id"`
	Snapshot int64         `orm:"name(snapshot)" json:"snapshot" yaml:"snapshot" cbor:"snapshot"` // 此文章对应的快照 ID
	Slug     string        `orm:"name(slug);len(100);unique(slug)" json:"slug" yaml:"slug" cbor:"slug"`
	Views    int           `orm:"name(views)" json:"views" yaml:"views" cbor:"views"`
	Order    int           `orm:"name(order)" json:"order" yaml:"order" cbor:"order"`
	Author   string        `orm:"name(author);len(20)" json:"author" yaml:"author" cbor:"author"`
	Title    string        `orm:"name(title);len(100)" json:"title" yaml:"title" cbor:"title"`
	Images   types.Strings `orm:"name(images);len(1000)" json:"images" yaml:"images" cbor:"images"`
	Keywords string        `orm:"name(keywords)" json:"keywords" yaml:"keywords" cbor:"keywords"`
	Summary  string        `orm:"name(summary);len(2000)" json:"summary" yaml:"summary" cbor:"summary"`
	Content  string        `orm:"name(content);len(-1)" json:"content" yaml:"content" cbor:"content"`

	Created  time.Time `orm:"name(created)" json:"created" yaml:"created" cbor:"created"`
	Modified time.Time `orm:"name(modified)" json:"modified" yaml:"modified" cbor:"modified"`

	// 分类信息
	Topics []int64 `orm:"-" json:"topics" yaml:"topics" cbor:"topics"`
	Tags   []int64 `orm:"-" json:"tags" yaml:"tags" cbor:"tags"`

	// 用于保存最后一次的快照 ID
	Last int64 `orm:"name(last)" json:"-" yaml:"-" cbor:"-"`
}

ArticleVO 文章的详细内容

type Articles added in v0.13.0

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

Articles 提供文章内容管理模块

func Install

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

Install 安装数据

mod 所属模块;tablePrefix 表名前缀;ts 关联的标签列表;

func NewArticles added in v0.13.0

func NewArticles(mod *cmfx.Module, tablePrefix string) *Articles

NewArticles 声明 Articles 对象

mod 所属的模块; tablePrefix 其它表都以此作为表名前缀;

func (*Articles) HandleDeleteArticle added in v0.13.0

func (m *Articles) HandleDeleteArticle(ctx *web.Context, article, deleter int64) web.Responser

HandleDeleteArticle 删除指定的文章

article 为文章的 ID; deleter 为删除者的 ID,调用者需要确保值的正确性;

func (*Articles) HandleGetArticle added in v0.13.0

func (m *Articles) HandleGetArticle(ctx *web.Context, article int64) web.Responser

HandleGetArticle 获取指定文章的详细信息

返回参数的实际类型为 ArticleVO; article 为文章的 ID,使用都需要确保值的正确性;

func (*Articles) HandleGetArticles added in v0.13.0

func (m *Articles) HandleGetArticles(ctx *web.Context) web.Responser

HandleGetArticles 获取文章列表

查询参数为 OverviewQuery,返回对象为 [query.Page[OverviewVO]]

func (*Articles) HandleGetArticlesByTag added in v0.13.0

func (m *Articles) HandleGetArticlesByTag(ctx *web.Context, tag int64) web.Responser

HandleGetArticlesByTag 获取文章列表

查询参数为 TagOverviewQuery,返回对象为 [query.Page[OverviewVO]]

func (*Articles) HandleGetArticlesByTopic added in v0.13.0

func (m *Articles) HandleGetArticlesByTopic(ctx *web.Context, topic int64) web.Responser

HandleGetArticlesByTopic 获取文章列表

查询参数为 TopicOverviewQuery,返回对象为 [query.Page[OverviewVO]]

func (*Articles) HandleGetSnapshot added in v0.13.0

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

HandleGetSnapshot 获取快照的详细信息

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

snapshot 为快照的 ID;

func (*Articles) HandleGetSnapshots added in v0.13.0

func (m *Articles) HandleGetSnapshots(ctx *web.Context, article int64) web.Responser

HandleGetSnapshots 获取文章的快照列表

article 文章 ID; 返回 []OverviewVO;

func (*Articles) HandlePatchArticle added in v0.13.0

func (m *Articles) HandlePatchArticle(ctx *web.Context, article, modifier int64) web.Responser

HandlePatchArticle 修改文章的内容

article 为文章的 ID; modifier 为修改者的 ID,调用者需要确保值的正确性;

func (*Articles) HandlePostArticle added in v0.13.0

func (m *Articles) HandlePostArticle(ctx *web.Context, creator int64) web.Responser

HandlePostArticle 创建新的文章

creator 为创建者的 ID,调用者需要确保值的正确性; 提交类型为 ArticleTO

func (*Articles) Tags added in v0.13.0

func (m *Articles) Tags() *tag.Tags

Tags 用到的标签分类

func (*Articles) Topics added in v0.13.0

func (m *Articles) Topics() *linkage.Linkages

Topics 用到的主题分类

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 {
	ID       int64     `json:"id" yaml:"id" cbor:"id" orm:"name(id)"`
	Slug     string    `json:"slug" yaml:"slug" cbor:"slug" orm:"name(slug)"`
	Views    int       `json:"views" yaml:"views" cbor:"views" orm:"name(views)"`
	Order    int       `json:"order" yaml:"order" cbor:"order" orm:"name(order)"`
	Author   string    `json:"author" yaml:"author" cbor:"author" orm:"name(author)"`
	Title    string    `json:"title" yaml:"title" cbor:"title" orm:"name(title)"`
	Created  time.Time `json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
	Modified time.Time `json:"modified" yaml:"modified" cbor:"modified" orm:"name(modified)"`
}

OverviewVO 文章摘要信息

type SnapshotOverviewVO

type SnapshotOverviewVO struct {
	Article int64     `json:"article" yaml:"article" cbor:"article" orm:"name(article)"` // 关联的文章
	ID      int64     `json:"id" yaml:"id" cbor:"id" orm:"name(id)"`                     // 快照 ID
	Author  string    `json:"author" yaml:"author" cbor:"author" orm:"name(author)"`
	Title   string    `json:"title" yaml:"title" cbor:"title" orm:"name(title)"`
	Created time.Time `json:"created" yaml:"created" cbor:"created" orm:"name(created)"`
}

SnapshotOverviewVO 文章快照的摘要信息

type SnapshotVO

type SnapshotVO struct {
	ID       int64         `orm:"name(id)" json:"id" yaml:"id" cbor:"id"`                     // 快照 ID
	Article  int64         `orm:"name(article)" json:"article" yaml:"article" cbor:"article"` // 快照关联的文章 ID
	Slug     string        `orm:"name(slug);len(100);unique(slug)" json:"slug" yaml:"slug" cbor:"slug"`
	Author   string        `orm:"name(author);len(20)" json:"author" yaml:"author" cbor:"author"`
	Title    string        `orm:"name(title);len(100)" json:"title" yaml:"title" cbor:"title"`
	Images   types.Strings `orm:"name(images);len(1000)" json:"images" yaml:"images" cbor:"images"`
	Keywords string        `orm:"name(keywords)" json:"keywords" yaml:"keywords" cbor:"keywords"`
	Summary  string        `orm:"name(summary);len(2000)" json:"summary" yaml:"summary" cbor:"summary"`
	Content  string        `orm:"name(content);len(-1)" json:"content" yaml:"content" cbor:"content"`
	Created  time.Time     `orm:"name(created)" json:"created" yaml:"created" cbor:"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)

Jump to

Keyboard shortcuts

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