models

package
v1.0.1-0...-3379034 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 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 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"`

	DateTimezone     string
	ModifiedTimezone string
}

Comment in database.

func (Comment) TableName

func (Comment) TableName() string

TableName ...

func (*Comment) ToProto

func (c *Comment) ToProto(redact func(c *proto.Comment)) *proto.Comment

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

type Comments

type Comments []*Comment

Comments ...

func (Comments) ToProto

func (cs Comments) ToProto(redact func(c *proto.Comment)) []*proto.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 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

	DateTimezone     string
	ModifiedTimezone string
}

Post ...

func (Post) TableName

func (Post) TableName() string

TableName ...

func (*Post) ToProto

func (p *Post) ToProto(redact func(p *proto.Post) error) (*proto.Post, error)

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

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"`

	Origin *proto.Metas_Origin `json:"origin:omitempty" yaml:"origin,omitempty"`
}

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

func PostMetaFrom

func PostMetaFrom(p *proto.Metas) *PostMeta

func (*PostMeta) IsEmpty

func (m *PostMeta) IsEmpty() bool

func (*PostMeta) Scan

func (m *PostMeta) Scan(value any) error

func (*PostMeta) ToProto

func (m *PostMeta) ToProto() *proto.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) ToProto

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

ToProtocols ...

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