model

package
v0.0.0-...-10283fc Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2023 License: MIT Imports: 4 Imported by: 0

README

Models

数据模型层

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB *gorm.DB
)
View Source
var (
	ErrRecordNotFound = gorm.ErrRecordNotFound
)

Functions

func Init

func Init() (*gorm.DB, func(), error)

Init 初始化数据库

Types

type UserModel

type UserModel struct {
	ID        int64  `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"id"`
	Username  string `gorm:"column:username" json:"username"`
	Nickname  string `gorm:"column:nickname" json:"nickname"`
	Phone     string `gorm:"column:phone" json:"phone"`
	Email     string `gorm:"column:email" json:"email"`
	Password  string `gorm:"column:password" json:"password"`
	Avatar    string `gorm:"column:avatar" json:"avatar"`
	Gender    string `gorm:"column:gender" json:"gender"`
	Birthday  string `gorm:"column:birthday" json:"birthday"`
	Bio       string `gorm:"column:bio" json:"bio"`
	LoginAt   int64  `gorm:"column:login_at" json:"login_at"` // login time for last times
	Status    int32  `gorm:"column:status" json:"status"`
	CreatedAt int64  `gorm:"column:created_at" json:"created_at"`
	UpdatedAt int64  `gorm:"column:updated_at" json:"updated_at"`
}

UserModel define a user base info struct.

func (*UserModel) BeforeCreate

func (u *UserModel) BeforeCreate(tx *gorm.DB) (err error)

func (*UserModel) TableName

func (u *UserModel) TableName() string

TableName 表名

Jump to

Keyboard shortcuts

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