model

package
v0.0.0-...-bc86f42 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBEngine

func NewDBEngine(databaseConfig *config.DatabaseConfig) (*gorm.DB, error)

创建数据库

Types

type Article

type Article struct {
	gorm.Model
	Title        string `gorm:"type:varchar(60);not null;comment:标题"`
	Description  string `gorm:"type:varchar(600);not null;comment:摘要"`
	Content      string `gorm:"type:text;not null;comment:内容"`
	AuthorId     int    `gorm:"type:int(10);unsigned;not null;comment:作者 ID"`
	Author       string `gorm:"type:varchar(20);not null;comment:作者"`
	CategoryId   int    `gorm:"type:tinyint(3);not null;comment:分类 ID"`
	CategoryName string `gorm:"type:varchar(20);not null;comment:分类名称"`
	TagId        int    `gorm:"type:int(10);unsigned;not null;comment:标签 ID"`
	TagName      string `gorm:"type:varchar(20);not null;comment:标签名称"`
}

func (Article) Create

func (a Article) Create(db *gorm.DB) error

func (Article) Delete

func (a Article) Delete(db *gorm.DB) (int64, error)

func (Article) GetById

func (a Article) GetById(db *gorm.DB, id uint) (Article, error)

func (Article) List

func (a Article) List(db *gorm.DB) ([]Article, error)

func (Article) Update

func (a Article) Update(db *gorm.DB) (int64, error)

type Category

type Category struct {
	gorm.Model
	Name string `gorm:"type:varchar(20);not null;comment:分类名称"`
}

func (Category) Create

func (c Category) Create(db *gorm.DB) error

func (Category) Delete

func (c Category) Delete(db *gorm.DB) (int64, error)

func (Category) GetById

func (c Category) GetById(db *gorm.DB, id uint) (Category, error)

func (Category) List

func (c Category) List(db *gorm.DB) ([]Category, error)

func (Category) Update

func (c Category) Update(db *gorm.DB) (int64, error)

type Tag

type Tag struct {
	gorm.Model
	Name string `gorm:"type:varchar(20);not null;comment:标签名称"`
}

func (Tag) Create

func (t Tag) Create(db *gorm.DB) error

func (Tag) Delete

func (t Tag) Delete(db *gorm.DB) (int64, error)

func (Tag) GetById

func (t Tag) GetById(db *gorm.DB, id uint) (Tag, error)

func (Tag) List

func (t Tag) List(db *gorm.DB) ([]Tag, error)

func (Tag) Update

func (t Tag) Update(db *gorm.DB) (int64, error)

type User

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(20);not null;index:idx_username_email;comment:用户名"`
	Email    string `gorm:"type:varchar(20);not null;unique;index:idx_username_email;comment:邮箱地址"`
	Password string `gorm:"type:varchar(20);not null;comment:密码"`
}

func (User) Create

func (u User) Create(db *gorm.DB) error

func (User) Delete

func (u User) Delete(db *gorm.DB) (int64, error)

func (User) GetByEmail

func (u User) GetByEmail(db *gorm.DB) (User, error)

func (User) GetById

func (u User) GetById(db *gorm.DB, id uint) (User, error)

func (User) List

func (u User) List(db *gorm.DB, pageOffset, pageSize int) ([]User, error)

func (User) Update

func (u User) Update(db *gorm.DB) (int64, error)

Jump to

Keyboard shortcuts

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