model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: MIT Imports: 2 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 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 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 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