model

package
v0.0.0-...-5158b42 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChangePassword

func ChangePassword(username string, password string, newPassword string) error

修改密码

func CheckPassword

func CheckPassword(username string, password string) error

检查前端登录密码

func CheckPasswordBackEnd

func CheckPasswordBackEnd(username string, password string) error

检查后端登录密码

func CheckUser

func CheckUser(username string) bool

检查用户是否存在

func CreateUser

func CreateUser(data *User) error

添加用户

func ScryptPassword

func ScryptPassword(password string) string

加密密码

func UpdateUserInfo

func UpdateUserInfo(username string, email string, phone string) (err error)

更新用户信息

Types

type Article

type Article struct {
	gorm.Model

	Category Category
	Title    string `gorm:"type:varchar(100);not null" json:"title"`
	Content  string `gorm:"type:longtext;" json:"content"`
	Desc     string `gorm:"type:varchar(200);not null" json:"desc"`
	Cid      int    `gorm:"type:int;not null" json:"cid"` // categoryId
}

type Category

type Category struct {
	gorm.Model

	Name string `gorm:"type:varchar(100);not null" json:"name"`
}

type User

type User struct {
	gorm.Model

	UserName string `gorm:"type:varchar(20);not null" json:"username" validate:"required,min=4,max=12"`
	Password string `gorm:"type:varchar(100);not null" json:"password" validate:"required,min=4,max=120"`
	Email    string `gorm:"type:varchar(100);not null" json:"email"`
	Phone    string `gorm:"type:varchar(100);not null" json:"phone"`
	Role     int    `gorm:"type:int;not null" json:"role" validate:"min=0,max=2"`
}

func GetUserInfo

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

获取用户信息

func GetUsers

func GetUsers(pageSize int, pageNum int) (users []User, total uint64, err error)

获取用户列表

Jump to

Keyboard shortcuts

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