model

package
v0.0.0-...-e778533 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 4 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 Database

func Database(connString string)

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

Types

type User

type User struct {
	gorm.Model
	UserName       string
	PasswordDigest string
	Nickname       string
	Status         string
	Avatar         string  `gorm:"size:1000"`
	Video          []Video `gorm:"ForeignKey:UserID"`
}

User 用户模型

func GetUser

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

GetUser 用ID获取用户

func (*User) CheckPassword

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

CheckPassword 校验密码

func (*User) SetPassword

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

SetPassword 设置密码

type Video

type Video struct {
	gorm.Model
	Title  string
	Info   string
	UserID uint `gorm:"column:user_id"`
}

User 视频模型

Jump to

Keyboard shortcuts

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