model

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Article

type Article struct {
	ID        string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	CreatedAt time.Time
	UpdatedAt time.Time

	Slug       string         `form:"slug" validate:"required" gorm:"unique_index"`
	Title      string         `form:"title" validate:"required"`
	Content    string         `form:"content" validate:"required" gorm:"text"`
	TemplateID byte           `form:"template" validate:"required"`
	IsBook     bool           `form:"is_book"`
	RawTags    string         `form:"tags" gorm:"-"`
	Tags       pq.StringArray `gorm:"index;type:varchar(255)[]" validate:"-" form:"-"`
	ReadNum    uint           `gorm:"default:0;"`
	CommentNum uint           `gorm:"default:0;"`
	Version    uint           `gorm:"default:1;"`
	BookRefer  *string        `form:"book_refer" validate:"omitempty,uuid4" gorm:"type:uuid;index;default:NULL"`

	Comments         []*Comment
	ArticleHistories []*ArticleHistory
	Toc              []*ArticleTOC
	Chapters         []*Article       `gorm:"foreignkey:BookRefer" form:"-" validate:"-"`
	Book             *Article         `gorm:"-" validate:"-" form:"-"`
	SibilingArticle  *SibilingArticle `gorm:"-" validate:"-" form:"-"`

	// for form
	NewVersion bool `gorm:"-" form:"new_version"`
}

Article 文章表

func (*Article) AfterFind

func (t *Article) AfterFind()

AfterFind hook

func (*Article) BeforeSave

func (t *Article) BeforeSave()

BeforeSave hook

func (*Article) GenTOC

func (t *Article) GenTOC()

GenTOC 生成标题树

func (*Article) GetIndexID

func (t *Article) GetIndexID() string

GetIndexID get index data id

func (*Article) RelatedCount

func (t *Article) RelatedCount(db *gorm.DB, pool *ants.Pool, checkPoolSubmit func(*sync.WaitGroup, error))

RelatedCount 合计专栏下文章计数

type ArticleHistory

type ArticleHistory struct {
	ArticleID string `gorm:"type:uuid;index"`
	Article   Article
	Version   uint   `gorm:"index"`
	Desc      string `gorm:"text"`
	Content   string `gorm:"text"`
	CreatedAt time.Time
}

ArticleHistory 文章修订历史

func (*ArticleHistory) GetIndexID

func (t *ArticleHistory) GetIndexID() string

GetIndexID get index data id

type ArticleIndex

type ArticleIndex struct {
	Slug    string
	Version float64
	Title   string
}

ArticleIndex index data

type ArticleTOC

type ArticleTOC struct {
	Title     string
	Slug      string
	SubTitles []*ArticleTOC
	Parent    *ArticleTOC `gorm:"-"`
	Level     int         `gorm:"-"`
	ShowLevel int         `gorm:"-"`
}

ArticleTOC 文章标题

type Comment

type Comment struct {
	ID        string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	CreatedAt time.Time

	ReplyTo   *string `gorm:"type:uuid;index;default:NULL" form:"reply_to"`
	Nickname  string  `form:"nickname" validate:"required"`
	Content   string  `form:"content" validate:"required" gorm:"text"`
	Website   string  `form:"website"`
	Version   uint    `form:"-"`
	Email     string  `form:"email"`
	IP        string  `gorm:"inet"`
	UserAgent string
	IsAdmin   bool

	ArticleID     *string `gorm:"type:uuid;index;default:NULL" form:"article_id" validate:"required,uuid"`
	Article       *Article
	ChildComments []*Comment `gorm:"foreignkey:ReplyTo" form:"-" validate:"-"`
}

Comment 评论表

type Config

type Config struct {
	Debug      bool
	ServerChan string
	Database   string
	Akismet    string
	Email      struct {
		Host string
		Port int
		User string
		Pass string
		SSL  bool
	}
	User User
	Site struct {
		SpaceName         string
		SpaceDesc         string
		SpaceKeywords     string
		HomeTopContent    string
		HomeBottomContent string
		Domain            string
		Theme             string
		HeaderMenus       []Menu
		FooterMenus       []Menu
	}

	ConfigFilePath string
}

Config 系统配置

func (*Config) Save

func (c *Config) Save() error

Save ..

type Menu struct {
	Name  string
	Link  string
	Icon  string
	Black bool
}

Menu 自定义菜单

type SibilingArticle

type SibilingArticle struct {
	Next Article
	Prev Article
}

SibilingArticle 相邻文章

type User

type User struct {
	Email    string
	Nickname string
	/*
		Password 用户密码
		* default password: 123456
		* gen password: https://bcrypt-generator.com/
	*/
	Password     string
	Token        string
	TokenExpires int64
}

User 用户表

Jump to

Keyboard shortcuts

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