model

package
v0.0.0-...-433f0a2 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUser

func AddUser(user *User) int

AddUser 创建用户

func InitDb

func InitDb()

func UserExit

func UserExit(userName string) int

UserExit 用户是否存在

Types

type Article

type Article struct {
	BaseModel
	Title      string `gorm:"type:varchar(100);not null;comment:标题" json:"title"`
	CategoryId int    `gorm:"type;int;not null;column:cid;comment:标签编号" json:"c_id""`
	Desc       string `gorm:"type:varchar(200);comment:描述" json:"desc"`
	Content    string `gorm:"type:text;comment:内容" json:"content"`
	Img        string `gorm:"type:varchar(100);comment:图片" json:"img"`
	UserId     int    `gorm:"type:int;not null;comment:用户编号" json:"user_id"`
	CommonTimestampsField
	CommonSoftDeletesField
}

type BaseModel

type BaseModel struct {
	ID uint64 `gorm:"column:id;primaryKey;autoIncrement;" json:"id,omitempty"`
}

BaseModel 模型基类

type Category

type Category struct {
	BaseModel
	Name    string `gorm:"type:varchar(20);not null;comment:标签名称" json:"name"`
	Article []Article
	CommonTimestampsField
	CommonSoftDeletesField
}

type CommonSoftDeletesField

type CommonSoftDeletesField struct {
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index" json:"deleted_at,omitempty"`
}

CommonSoftDeletesField 软删除

type CommonTimestampsField

type CommonTimestampsField struct {
	CreatedAt time.Time `gorm:"column:created_at;" json:"created_at,omitempty"`
	UpdatedAt time.Time `gorm:"column:updated_at;index;" json:"updated_at,omitempty"`
}

CommonTimestampsField 时间戳

type User

type User struct {
	BaseModel
	UserName string `gorm:"type:varchar(20);not null;comment:用户名称" json:"user_name" form:"user_name" binding:"required"`
	Password string `gorm:"type:varchar(20);not null;comment:密码" json:"password" form:"password" binding:"required"`

	Article []Article
	CommonTimestampsField
	CommonSoftDeletesField
	// contains filtered or unexported fields
}

func GetUsers

func GetUsers(pageSize, pageNum int) []User

Jump to

Keyboard shortcuts

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