model

package
v0.0.0-...-367fef7 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Id           string  `gorm:"primary_key;unique;not null;index;type:varchar(32)" json:"id"` // 地址ID
	Uid          string  `gorm:"not null;index;type:varchar(32)" json:"uid"`                   // 用户ID, 与默认地址联合唯一,用户只能有一个唯一的收货地址
	Name         string  `gorm:"not null;index;type:varchar(32)" json:"name"`                  // 收货人
	Phone        string  `gorm:"not null;index;type:varchar(32)" json:"phone"`                 // 收货人电话
	ProvinceCode string  `gorm:"not null;index;type:varchar(2)" json:"province_code"`          // 省份代码
	CityCode     string  `gorm:"not null;index;type:varchar(4)" json:"city_code"`              // 城市代码
	AreaCode     string  `gorm:"not null;index;type:varchar(6)" json:"area_code"`              // 地区代码
	StreetCode   string  `gorm:"not null;index;type:varchar(9)" json:"street_code"`            // 街道代码
	Address      string  `gorm:"not null;index;type:varchar(32)" json:"address"`               // 详细地址
	IsDefault    bool    `gorm:"not null;index;" json:"is_default"`                            // 是否为默认地址, 跟 UID 联合唯一
	Note         *string `gorm:"null;index;type:varchar(12)" json:"note"`                      // 备注, 通常备注是 家/公司/学校 等
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    *time.Time `sql:"index"`
}

func (*Address) BeforeCreate

func (news *Address) BeforeCreate(db *gorm.DB) error

func (*Address) TableName

func (news *Address) TableName() string

type Admin

type Admin struct {
	Id        int64       `gorm:"primary_key" json:"id"`                                  // 用户ID
	Username  string      `gorm:"not null;unique;index;type:varchar(36)" json:"username"` // 用户名, 用于登陆
	Name      string      `gorm:"not null;index;type:varchar(36)" json:"name"`            // 管理员名
	Password  string      `gorm:"not null;type:varchar(36)" json:"password"`              // 登陆密码
	IsSuper   bool        `gorm:"not null;" json:"is_super"`                              // 是否是超级管理员, 超级管理员全站应该只有一个
	Status    AdminStatus `gorm:"not null;" json:"status"`                                // 状态
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

func (*Admin) BeforeCreate

func (news *Admin) BeforeCreate(db *gorm.DB) error

func (*Admin) TableName

func (news *Admin) TableName() string

type AdminStatus

type AdminStatus int32
const (
	AdminStatusBanned      AdminStatus = -100 // 账号被禁用
	AdminStatusInactivated AdminStatus = -1   // 账号未激活
	AdminStatusInit        AdminStatus = 0    // 初始化状态
)

type Article

type Article struct {
	Id        int64  `gorm:"primary_key;AUTO_INCREMENT"`      // 文章ID
	Title     string `gorm:"not null;index;type:varchar(36)"` // 文章标题
	Content   string `gorm:"not null;type:text"`              // 文章内容
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt // 逻辑删除 for Delete()
}

func (*Article) AfterCreate

func (news *Article) AfterCreate(db *gorm.DB) error

func (*Article) AfterDelete

func (news *Article) AfterDelete(db *gorm.DB) error

func (*Article) BeforeCreate

func (news *Article) BeforeCreate(db *gorm.DB) error

func (*Article) BeforeDelete

func (news *Article) BeforeDelete(db *gorm.DB) error

func (*Article) TableName

func (news *Article) TableName() string

Jump to

Keyboard shortcuts

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