model

package
v0.0.0-...-a770161 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteUser

func DeleteUser(id uint64) error

func GetSelfDB

func GetSelfDB() *gorm.DB

func InitSelfDB

func InitSelfDB() *gorm.DB

Types

type BaseModel

type BaseModel struct {
	Id        uint64     `gorm:"primary_key;AUTO_INCREMENT;column:id" json:"_"`
	CreatedAt time.Time  `gorm:"column:created_at" json:"-"`
	UpdatedAt time.Time  `gorm:"column:updated_at" json:"-"`
	DeletedAt *time.Time `gorm:"column:deleted_at" sql:"index" json:"-"`
}

type Database

type Database struct {
	Self *gorm.DB
}
var DB *Database

func (*Database) Close

func (db *Database) Close()

func (*Database) Init

func (db *Database) Init()

type Token

type Token struct {
	Token string `json:"token"`
}

type UserInfo

type UserInfo struct {
	Id        uint64 `json:"id"`
	Username  string `json:"username"`
	SayHello  string `json:"sayHello"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type UserList

type UserList struct {
	Lock  *sync.Mutex
	IdMap map[uint64]*UserInfo
}

type UserModel

type UserModel struct {
	BaseModel
	Username string `json:"username" gorm:"column:username;not null" binding:"required" validate:"min=1,max=32"`
	Password string `json:"password" gorm:"column:password;not null" binding:"required" validate:"min=5,max=128"`
}

func GetUser

func GetUser(username string) (*UserModel, error)

func ListUser

func ListUser(username string, offset, limit int) ([]*UserModel, uint64, error)

func (*UserModel) Compare

func (u *UserModel) Compare(pwd string) error

func (*UserModel) Create

func (u *UserModel) Create() error

func (*UserModel) Encrypt

func (u *UserModel) Encrypt() (err error)

func (*UserModel) TableName

func (u *UserModel) TableName() string

func (*UserModel) Update

func (u *UserModel) Update() error

func (*UserModel) Validate

func (u *UserModel) Validate() error

Jump to

Keyboard shortcuts

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