models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArticleStatusDraft     = 0
	ArticleStatusPublished = 1
)

Variables

This section is empty.

Functions

func Art2TextPoint

func Art2TextPoint(a *Article) *string

func Gist2TextPoint

func Gist2TextPoint(g *Gist) *string

Types

type Article

type Article struct {
	BaseModel

	Title   string `gorm:"type:varchar(255);notnull;" json:"title"`
	Status  uint   `gorm:"type:tinyint;notnull;comment:0=draft,1=published,2=hidden-不在列表显示" json:"status"`
	Rune    uint   `gorm:"type:smallint;notnull;comment:不合范式的冗余字段" json:"rune"`
	Image   string `gorm:"type:varchar(255);notnull" json:"image"`
	Summary string `gorm:"type:varchar(2000);notnull" json:"summary"`

	ArticleContent *ArticleContent `json:"content"`
	Tags           []Tag           `gorm:"many2many:article_tags" json:"tags"`
}

type ArticleContent

type ArticleContent struct {
	ArticleID uint   `gorm:"primaryKey" json:"-"`
	Text      string `gorm:"type:text;notnull;" json:"text"`
	HTML      string `gorm:"type:mediumtext;notnull;" json:"html"`
}

type ArticleTags

type ArticleTags struct {
	ID        uint `gorm:"primaryKey" json:"id"`
	ArticleID uint `gorm:"notnull" json:"article_id"`
	TagID     uint `gorm:"notnull" json:"tag_id"`
}

type Attachment

type Attachment struct {
	BaseModel

	Key     string `gorm:"type:varchar(255);notnull;index;comment:访问地址" json:"key"`
	Summary string `gorm:"type:varchar(2000);notnull" json:"summary"`
}

type BaseModel

type BaseModel struct {
	ID      uint `json:"id"`
	Created uint `gorm:"notnull;autoCreateTime" json:"created"`
	Updated uint `gorm:"notnull;autoUpdateTime" json:"updated"`

	IsDel soft_delete.DeletedAt `gorm:"type:tinyint(1);notnull;softDelete:flag" json:"-"`
}

type Comment

type Comment struct {
	BaseModel

	Name    string `gorm:"type:varchar(255);notnull" validate:"min=1,max=50" json:"name"`
	Email   string `gorm:"type:varchar(255);notnull" validate:"email,max=100" json:"email"`
	Link    string `gorm:"type:varchar(255);notnull" json:"link" validate:"omitempty,custom_url,max=255"`
	Content string `gorm:"type:varchar(1000);notnull" validate:"min=1,max=1000" json:"content"`

	ArticleID      uint `gorm:"notnull" json:"article_id"`
	ReplyCommentID uint `gorm:"notnull" json:"reply_comment_id"`
	RootCommentID  uint `gorm:"notnull" json:"root_comment_id"`
}

type Gist

type Gist struct {
	BaseModel

	Title      string      `gorm:"type:varchar(255);notnull" json:"title"`
	Lang       string      `gorm:"type:varchar(20);notnull" json:"lang"`
	Content    string      `gorm:"type:text;notnull" json:"content"`
	GistOutput *GistOutput `json:"output"`
}

type GistFts

type GistFts struct {
	ID      uint   `json:"id"`
	Title   string `json:"title"`
	Lang    string `json:"lang"`
	Content string `json:"content"`
}

func Text2ArtGistFts

func Text2ArtGistFts(id uint, s *string) *GistFts

func Text2Gist

func Text2Gist(id uint, s *string) *GistFts

type GistOutput

type GistOutput struct {
	GistID uint   `gorm:"primaryKey" json:"-"`
	HTML   string `gorm:"type:text;notnull;" json:"html"`
}

type LoginRecord

type LoginRecord struct {
	ID      uint `gorm:"primaryKey" json:"id"`
	Created uint `gorm:"notnull;autoCreateTime" json:"created"`
	//IP      uint `json:"ip"`
	IP       string `gorm:"type:varchar(39);notnull" json:"ip"`
	IsFailed bool   `gorm:"default:false" json:"is_failed"`
}

TODO duckDB

type Pagination

type Pagination struct {
	Page     int `json:"page"`
	PageSize int `json:"page_size"`
	Count    int `json:"count"`
}

type SearchURLParams

type SearchURLParams[T int | string] struct {
	Page         int            `json:"page"`
	PageSize     int            `json:"page_size"`
	FilterText   string         `json:"filter_text"`
	FilterValues map[string][]T `json:"filter_values"`
	SortKey      struct {
		ID    string `json:"id"`
		Order string `json:"order"`
	} `json:"sort_key"`
}

type Settings

type Settings struct {
	BaseModel

	Title        string `gorm:"type:varchar(255);notnull" json:"title"`
	Background   string `gorm:"type:text;notnull;" json:"background"`
	MarginBottom int    `gorm:"notnull;default:0" json:"marginBottom"`
}

type Tag

type Tag struct {
	BaseModel

	Name  string `gorm:"type:varchar(20);notnull;index" json:"name"`
	Color string `gorm:"type:varchar(15);notnull" json:"color"`
}

type User

type User struct {
	BaseModel

	Name      string `gorm:"type:varchar(100);notnull;index" json:"name"`
	Pass      string `gorm:"type:char(60);notnull" json:"pass"`
	LastLogin uint   `gorm:"notnull" json:"last_login"`
}

Jump to

Keyboard shortcuts

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