model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const TableNameBlog = "blogs"
View Source
const TableNameCategory = "categories"
View Source
const TableNameComment = "comments"
View Source
const TableNamePage = "pages"
View Source
const TableNamePost = "posts"
View Source
const TableNamePostTag = "post_tag"
View Source
const TableNameTag = "tags"
View Source
const TableNameUser = "users"

Variables

This section is empty.

Functions

This section is empty.

Types

type Blog

type Blog struct {
	gorm.Model
	Name        string `gorm:"column:name;not null" json:"name"`
	Description string `gorm:"column:description;not null" json:"description"`
	UserID      uint   `gorm:"column:user_id;not null" json:"user_id"`
	User        User
}

func (*Blog) TableName

func (*Blog) TableName() string

type Category

type Category struct {
	gorm.Model
	Slug        string `gorm:"column:slug;not null" json:"slug"`
	Name        string `gorm:"column:name;not null" json:"name"`
	Description string `gorm:"column:description;not null" json:"description"`
}

func (*Category) TableName

func (*Category) TableName() string

type Comment

type Comment struct {
	gorm.Model
	Body   string `gorm:"column:body;not null" json:"body"`
	Email  string `gorm:"column:email;not null" json:"email"`
	IP     string `gorm:"column:ip;not null" json:"ip"`
	Post   Post
	PostID uint
	UserID uint `gorm:"column:user_id;not null" json:"user_id"`
	User   User
}

func (*Comment) TableName

func (*Comment) TableName() string

type Media added in v0.2.0

type Media struct {
	UpdatedAt   time.Time    `json:"updated_at" gorm:"index"`
	CreatedAt   time.Time    `json:"created_at" gorm:"index"`
	Thumbnail   string       `json:"thumbnail,omitempty" gorm:"size:500"`
	Tags        string       `json:"tags,omitempty" gorm:"size:200;index"`
	Title       string       `json:"title,omitempty" gorm:"size:200"`
	Alt         string       `json:"alt,omitempty"`
	Description string       `json:"description,omitempty"`
	Keywords    string       `json:"keywords,omitempty"`
	CreatorID   uint         `json:"-"`
	Creator     User         `json:"-"`
	Author      string       `json:"author" gorm:"size:64"`
	Published   bool         `json:"published"`
	PublishedAt sql.NullTime `json:"published_at"`
	ContentType string       `json:"content_type" gorm:"size:32"`
	Remark      string       `json:"remark"`
	Size        int64        `json:"size"`
	Directory   bool         `json:"directory" gorm:"index"`
	Path        string       `json:"path" gorm:"size:200;uniqueIndex:,composite:_path_name"`
	Name        string       `json:"name" gorm:"size:200;uniqueIndex:,composite:_path_name"`
	Ext         string       `json:"ext" gorm:"size:100"`
	Dimensions  string       `json:"dimensions" gorm:"size:200"` // x*y
	StorePath   string       `json:"-" gorm:"size:300"`
	External    bool         `json:"external"`
	PublicUrl   string       `json:"public_url,omitempty" gorm:"-"`
}

func (*Media) BuildPublicUrls added in v0.2.0

func (m *Media) BuildPublicUrls(mediaHost string, mediaPrefix string)

type MediaFolder added in v0.2.0

type MediaFolder struct {
	Name         string `json:"name"`
	Path         string `json:"path"`
	FilesCount   int64  `json:"filesCount"`
	FoldersCount int64  `json:"foldersCount"`
}

type Page

type Page struct {
	gorm.Model
	Slug        string    `gorm:"column:slug;not null" json:"slug"`
	Title       string    `gorm:"column:title;not null" json:"title"`
	Body        string    `gorm:"column:body;not null" json:"body"`
	PublishedAt time.Time `gorm:"column:published_at" json:"published_at"`
	UserID      uint      `gorm:"column:user_id;not null" json:"user_id"`
	User        User
}

func (*Page) TableName

func (*Page) TableName() string

type Post

type Post struct {
	gorm.Model
	Slug        string    `gorm:"column:slug;not null;uniqueIndex" json:"slug"`
	Title       string    `gorm:"column:title;not null" json:"title"`
	Description string    `gorm:"column:description;not null" json:"description"`
	Body        string    `gorm:"column:body;not null" json:"body"`
	CategoryID  uint      `gorm:"column:category_id" json:"category_id"`
	IsDraft     uint      `gorm:"column:is_draft" json:"is_draft"`
	PublishedAt time.Time `gorm:"column:published_at" json:"published_at"`
	UserID      uint      `gorm:"column:user_id;not null" json:"user_id"`
	User        User
	Category    Category
	Comments    []Comment
	Tags        []Tag `gorm:"many2many:post_tag"`
}

func (Post) GetTagsAsCharSeparated

func (p Post) GetTagsAsCharSeparated(sep string) string

func (Post) GetTagsAsCommaSeparated

func (p Post) GetTagsAsCommaSeparated() string

func (*Post) TableName

func (*Post) TableName() string

type PostTag

type PostTag struct {
	PostID uint `gorm:"column:post_id;not null" json:"post_id"`
	TagID  uint `gorm:"column:tag_id;not null" json:"tag_id"`
}

func (*PostTag) TableName

func (*PostTag) TableName() string

type Site added in v0.2.0

type Site struct {
	UpdatedAt time.Time `json:"updated_at"`
	CreatedAt time.Time `json:"created_at"`
	Domain    string    `json:"domain" gorm:"primarykey;size:200"`
	Name      string    `json:"name" gorm:"size:200"`
	Preview   string    `json:"preview" gorm:"size:200"`
	Disallow  bool      `json:"disallow"`
}

func (Site) String added in v0.2.0

func (s Site) String() string

type Tag

type Tag struct {
	gorm.Model
	Slug  string `gorm:"column:slug;not null" json:"slug"`
	Name  string `gorm:"column:name;not null;uniqueIndex" json:"name"`
	Posts []Post `gorm:"many2many:post_tag"`
}

func (*Tag) TableName

func (*Tag) TableName() string

type UploadResult added in v0.2.0

type UploadResult struct {
	PublicUrl   string `json:"publicUrl"`
	Thumbnail   string `json:"thumbnail"`
	Path        string `json:"path"`
	Name        string `json:"name"`
	External    bool   `json:"external"`
	StorePath   string `json:"storePath"`
	Dimensions  string `json:"dimensions"`
	Ext         string `json:"ext"`
	Size        int64  `json:"size"`
	ContentType string `json:"contentType"`
}

type User

type User struct {
	gorm.Model
	Username string    `gorm:"column:username;not null" json:"username"`
	Password string    `gorm:"column:password;not null;default:123456" json:"password"`
	Name     string    `gorm:"column:name;not null" json:"name"`
	Token    string    `gorm:"column:token;not null" json:"token"`
	Avatar   string    `gorm:"column:avatar;not null" json:"avatar"`
	Gender   uint      `gorm:"column:gender;not null;default:1" json:"gender"`
	Phone    string    `gorm:"column:phone;not null" json:"phone"`
	Email    string    `gorm:"column:email;not null" json:"email"`
	Addr     string    `gorm:"column:addr;not null" json:"addr"`
	IP       string    `gorm:"column:ip;not null" json:"ip"`
	LoginAt  time.Time `gorm:"column:login_at" json:"login_at"`
	LogoutAt time.Time `gorm:"column:logout_at" json:"logout_at"`
}

func (*User) TableName

func (*User) TableName() string

Jump to

Keyboard shortcuts

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