user

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type User

type User struct {
	metav1.ObjectMeta `json:"metadata,omitempty"`
	Status            int       `json:"status"             gorm:"column:status"   validate:"omitempty"`
	Nickname          string    `json:"nickname"           gorm:"column:nickname" validate:"required,min=1,max=30"`
	Password          string    `json:"password,omitempty" gorm:"column:password" validate:"required"`
	Email             string    `json:"email"              gorm:"column:email"    validate:"required,email,min=1,max=100"`
	Phone             string    `json:"phone"              gorm:"column:phone"    validate:"omitempty"`
	IsAdmin           int       `json:"isAdmin,omitempty"  gorm:"column:isAdmin"  validate:"omitempty"`
	TotalPolicy       int64     `json:"totalPolicy"        gorm:"-"               validate:"omitempty"`
	LoginAt           time.Time `json:"loginAt,omitempty"  gorm:"column:loginAt"`
}

User 是数据库中 user 记录 struct 格式的映射.

func (*User) AfterCreate

func (u *User) AfterCreate(tx *gorm.DB) error

AfterCreate 在创建数据库记录之后更新资源 ID.

func (*User) BeforeCreate

func (u *User) BeforeCreate(tx *gorm.DB) (err error)

BeforeCreate 在创建数据库记录之前加密明文密码.

func (*User) Compare

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

Compare 验证用户密码是否正确.

func (*User) TableName

func (u *User) TableName() string

TableName 用来指定映射的 MySQL 表名.

func (*User) Validate

func (u *User) Validate() field.ErrorList

Validate 检查一个 user 对象是否合法.

Jump to

Keyboard shortcuts

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