models

package
v0.0.0-...-368a27e Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Users map[string]*User
)

???????????

Functions

func CheckIsSuperuser

func CheckIsSuperuser(id int) (exist bool)

检查用户是否是超级用户

func DbInit

func DbInit()

func UserUpdate

func UserUpdate(user *User, fields ...string) error

更新User信息

Types

type User

type User struct {
	UserId     int       `orm:"column(user_id);auto"`
	RegionId   int       `orm:"column(region_id);null"`
	Username   string    `orm:"column(username);size(120)" json:"name"`
	Password   string    `orm:"column(password);size(200)"`
	Email      string    `orm:"column(email);size(200)"`
	Tel        string    `orm:"column(tel);size(11)"`
	Status     int16     `orm:"column(status);null"`
	Superuser  string    `orm:"column(superuser);size(2);"`
	Nickname   string    `orm:"column(nickname);size(64);"`
	Sex        string    `orm:"column(sex);size(10);null"`
	LastIp     string    `orm:"column(lastip);size(20);null"`
	Last_login time.Time `orm:"column(last_login);type(datetime);null"`
	Wtime      time.Time `orm:"column(wtime);type(datetime);null"`
}

Superuser = 6 为超级管理员

func UserGetById

func UserGetById(id int) (*User, error)

通过ID获取User

func UserGetByName

func UserGetByName(username string) (*User, error)

通过username获取User

func (*User) TableName

func (t *User) TableName() string

返回表名

func (*User) Update

func (u *User) Update(fields ...string) error

为User添加一个方法,简化更新操作

Jump to

Keyboard shortcuts

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