UserModel

package
v0.0.0-...-0b4b916 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type UserImpl

type UserImpl struct {
	Id int64 `json:"userid" gorm:"column:id; primaryKey; autoIncrement"`
	//Email 邮箱,不能为空, 必须是邮箱格式,且不能重复;
	Email string `json:"email" gorm:"column:email;unique" binding:"required,email"`
	//Username 用户名,创建自定义验证器: 长度在 6-20 之间,且不能重复,只能包含大小写字母,数字,下划线;第一个字符必须是字母;
	Username string `json:"username" gorm:"column:username;unique" binding:"usernameValid"`
	//Password 密码, 长度在 6-20 之间,只能包含字母,数字,下划线;
	Password string `json:"-" gorm:"column:password" binding:"passwordValid"`
	// admin 0 和 1
	Admin int `json:"admin" gorm:"column:admin"`
	// active 0 和 1
	Active int `json:"active" gorm:"column:active"`
	// nickname
	Nickname string `json:"nickname" gorm:"column:nickname"`
	// description
	Description string `json:"description" gorm:"column:description"`
	// avatar
	Avatar string `json:"avatar" gorm:"column:avatar"`

	CreateAt time.Time `json:"create_time" gorm:"column:create_time;type:datetime(0); autoCreateTime"`
	UpdateAt time.Time `json:"update_time" gorm:"column:update_time;type:datetime(0); autoUpdateTime"`
	CreateBy int64     `json:"-" gorm:"column:create_by"`
	UpdateBy int64     `json:"-" gorm:"column:update_by"`
}

UserImpl 创建 Users struct

func New

func New(attrs ...UserModelAttrFunc) *UserImpl

func (*UserImpl) CheckPassword

func (u *UserImpl) CheckPassword(password string) bool

检查密码

func (*UserImpl) GeneratePassword

func (u *UserImpl) GeneratePassword() error

生成密码

func (*UserImpl) Mutate

func (u *UserImpl) Mutate(attrs ...UserModelAttrFunc) *UserImpl

func (*UserImpl) TableName

func (u *UserImpl) TableName() string

type UserModelAttrFunc

type UserModelAttrFunc func(u *UserImpl)

func WithEmail

func WithEmail(email string) UserModelAttrFunc

func WithPassword

func WithPassword(pwd string) UserModelAttrFunc

func WithUserId

func WithUserId(id int64) UserModelAttrFunc

func WithUsername

func WithUsername(name string) UserModelAttrFunc

type UserModelAttrFuncs

type UserModelAttrFuncs []UserModelAttrFunc

Jump to

Keyboard shortcuts

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