entity

package
v0.0.0-...-422268b Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmailOrPasswordInvalid = errors.New("email or password invalid")
	ErrEmailExisted           = errors.New("email has already existed")
	ErrCannotGetUser          = errors.New("cannot get user info")
	ErrCannotGetUsers         = errors.New("cannot get users info")
	ErrCannotCreateUser       = errors.New("cannot create new user")
)

Functions

This section is empty.

Types

type User

type User struct {
	core.SQLModel
	Email     string      `json:"email" gorm:"column:email;"`
	Password  string      `json:"-" gorm:"column:password;"`
	Salt      string      `json:"-" gorm:"column:salt;"`
	LastName  string      `json:"last_name" gorm:"column:last_name;"`
	FirstName string      `json:"first_name" gorm:"column:first_name;"`
	Phone     string      `json:"phone" gorm:"column:phone;"`
	Avatar    *core.Image `json:"avatar" gorm:"column:avatar;"`
	Role      UserRole    `json:"role" gorm:"column:role;"`
	Status    int         `json:"status" gorm:"column:status;"`
}

func NewUser

func NewUser(firstName, lastName, email string) User

func (*User) GetEmail

func (u *User) GetEmail() string

func (*User) GetRole

func (u *User) GetRole() string

func (*User) GetUserID

func (u *User) GetUserID() int

func (*User) Mask

func (u *User) Mask()

func (User) TableName

func (User) TableName() string

type UserCreate

type UserCreate struct {
	core.SQLModel `json:",inline"`
	FirstName     string `json:"first_name" gorm:"column:first_name;"`
	LastName      string `json:"last_name" gorm:"column:last_name;"`
	Email         string `json:"email" gorm:"column:email;"`
	Password      string `json:"password" gorm:"column:password;"`
	Role          string `json:"-" gorm:"column:role;"`
	Salt          string `json:"-" gorm:"column:salt;"`
}

func (UserCreate) TableName

func (UserCreate) TableName() string

type UserLogin

type UserLogin struct {
	Email    string `json:"email" form:"email" gorm:"column:email;"`
	Password string `json:"password" form:"password" gorm:"column:password;"`
}

func (UserLogin) TableName

func (UserLogin) TableName() string

type UserRole

type UserRole int
const (
	RoleUser UserRole = 1 << iota
	RoleAdmin
	RoleMod
)

func (*UserRole) MarshalJSON

func (role *UserRole) MarshalJSON() ([]byte, error)

func (*UserRole) Scan

func (role *UserRole) Scan(value interface{}) error

func (UserRole) String

func (role UserRole) String() string

func (*UserRole) Value

func (role *UserRole) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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