model

package
v0.0.0-...-54fccd2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PassWordCost 密码加密难度
	PassWordCost = 12
	// Active 激活用户
	Active string = "active"
	// Inactive 未激活用户
	Inactive string = "inactive"
	// Suspend 被封禁用户
	Suspend string = "suspend"
)

Variables

View Source
var DB *gorm.DB

DB 数据库链接单例

Functions

func CheckRegistered

func CheckRegistered(account string) (bool, error)

CheckRegistered 同用户名检测

func Database

func Database(connString string)

Database 在中间件中初始化mysql链接

Types

type User

type User struct {
	gorm.Model
	Account        string
	PasswordDigest string
	Nickname       string
	Status         string
	Avatar         string `gorm:"size:1000"`
}

User 用户模型

func GetUser

func GetUser(ID interface{}) (User, error)

GetUser 用ID获取用户

func (*User) CheckPassword

func (user *User) CheckPassword(password string) bool

CheckPassword 校验密码

func (*User) Create

func (user *User) Create() error

创建用户

func (*User) MakeToken

func (user *User) MakeToken() (string, int64, error)

MakeToken 生成token

func (*User) Save

func (item *User) Save() error

保存

func (*User) SetPassword

func (user *User) SetPassword(password string) error

SetPassword 设置密码

func (*User) UserID

func (user *User) UserID() string

UserID 返回string版的uid

Jump to

Keyboard shortcuts

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