models

package
v1.0.1-0...-219fbf5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Untitled = `无标题`

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	ID       int64       `json:"id"`
	Name     string      `json:"name"`
	Slug     string      `json:"slug"`
	ParentID int64       `json:"parent"`
	Path     string      `json:"path"`
	Children []*Category `json:"children"`
}

Category is a post category

func (Category) TableName

func (Category) TableName() string

TableName ...

type Comment

type Comment struct {
	ID         int64  `json:"id"`
	Parent     int64  `json:"parent"`
	Root       int64  `json:"root"`
	PostID     int64  `json:"post_id"`
	Author     string `json:"author"`
	Email      string `json:"email"`
	URL        string `json:"url"`
	IP         string `json:"ip"`
	Date       int32  `json:"date"`
	Modified   int32  `json:"modified"`
	SourceType string `json:"source_type"`
	Source     string `json:"source"`
}

Comment in database.

func (Comment) TableName

func (Comment) TableName() string

TableName ...

func (*Comment) ToProtocols

func (c *Comment) ToProtocols(redact func(c *protocols.Comment)) *protocols.Comment

ToProtocols ... 以下字段由 setCommentExtraFields 提供/清除。 - IsAdmin - Email - Ip - GeoLocation - CanEdit - Avatar - Content

type Comments

type Comments []*Comment

Comments ...

func (Comments) ToProtocols

func (cs Comments) ToProtocols(redact func(c *protocols.Comment)) []*protocols.Comment

ToProtocols ...

type Geo

type Geo struct {
	Name      string  `json:"name,omitempty" yaml:"name,omitempty"`           // 地理位置的名字
	Longitude float32 `json:"longitude,omitempty" yaml:"longitude,omitempty"` // 经度
	Latitude  float32 `json:"latitude,omitempty" yaml:"latitude,omitempty"`   // 纬度
}

本来想用 GeoJSON 的,但是感觉标准化程度还不高。 想想还是算了,我只是想不丢失早期说说的地理位置信息。 那就用最简单的方式:经、纬度、名字,后期再升级吧。 https://geojson.org/ https://en.wikipedia.org/wiki/GeoJSON

type Kind

type Kind string

文章的种类。 其实就是 type,准备换个名字。

type ObjectTag

type ObjectTag struct {
	ID     int64
	PostID int64
	TagID  int64
}

ObjectTag ...

func (ObjectTag) TableName

func (ObjectTag) TableName() string

TableName ...

type Option

type Option struct {
	ID    int64
	Name  string
	Value string
}

func (Option) TableName

func (Option) TableName() string

TableName ...

type Post

type Post struct {
	ID              int64
	Date            int32
	Modified        int32
	LastCommentedAt int32
	Title           string
	Slug            string
	Type            string
	Category        uint
	Status          string
	PageView        uint
	CommentStatus   uint
	Comments        uint
	Metas           PostMeta
	Source          string
	SourceType      string
}

Post ...

func (Post) TableName

func (Post) TableName() string

TableName ...

func (*Post) ToProtocols

func (p *Post) ToProtocols(redact func(p *protocols.Post) error) (*protocols.Post, error)

以下字段由 setPostExtraFields 提供/清除。 - Metas.Geo - Content

type PostForRelated

type PostForRelated struct {
	ID        int64  `json:"id"`
	Title     string `json:"title"`
	Relevance uint   `json:"relevance"`
}

type PostMeta

type PostMeta struct {
	Header   string `json:"header,omitempty" yaml:"header,omitempty"`
	Footer   string `json:"footer,omitempty" yaml:"footer,omitempty"`
	Outdated bool   `json:"outdated,omitempty" yaml:"outdated,omitempty"`
	Wide     bool   `json:"wide,omitempty" yaml:"wide,omitempty"`

	Weixin string `json:"weixin,omitempty" yaml:"weixin,omitempty"`

	Sources map[string]*PostMetaSource `json:"sources,omitempty" yaml:"sources,omitempty"`

	Geo *Geo `json:"geo,omitempty" yaml:"geo,omitempty"`
}

NOTE 如果要添加字段,记得同步 isEmpty 方法。

func PostMetaFrom

func PostMetaFrom(p *protocols.Metas) *PostMeta

func (*PostMeta) IsEmpty

func (m *PostMeta) IsEmpty() bool

func (*PostMeta) Scan

func (m *PostMeta) Scan(value interface{}) error

func (*PostMeta) ToProtocols

func (m *PostMeta) ToProtocols() *protocols.Metas

func (PostMeta) Value

func (m PostMeta) Value() (driver.Value, error)

type PostMetaSource

type PostMetaSource struct {
	Name        string `json:"name,omitempty" yaml:"name,omitempty"`
	URL         string `json:"url,omitempty" yaml:"url,omitempty"`
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	Time        int32  `json:"time,omitempty" yaml:"time,omitempty"`
}

type Posts

type Posts []*Post

Posts ...

func (Posts) ToProtocols

func (ps Posts) ToProtocols(redact func(p *protocols.Post) error) (posts []*protocols.Post, err error)

ToProtocols ...

type Redirect

type Redirect struct {
	ID         int64
	CreatedAt  int32
	SourcePath string
	TargetPath string
	StatusCode int
}

func (Redirect) TableName

func (Redirect) TableName() string

type Tag

type Tag struct {
	ID    int64
	Name  string
	Alias int64
}

Tag is a tag.

func (Tag) TableName

func (Tag) TableName() string

TableName ...

type TagWithCount

type TagWithCount struct {
	// taorm yet doesn't support embedded field scanning.
	Name  string
	Count int64
}

TagWithCount is a tag with associated post count.

Jump to

Keyboard shortcuts

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