entity

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleAdministrator = Role("Administrator")
	RoleGeneral       = Role("General")

	GenderMale    = Gender("Male")
	GenderFemale  = Gender("Female")
	GenderUnknown = Gender("Unknown")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Activate

type Activate struct {
	Authenticate
	NewPassword string `json:"newPassword" binding:"required,password"`
}

Activate is validation struct of using during activate user

type Authenticate

type Authenticate struct {
	Account  string `json:"account" binding:"required,min=8,max=20"`
	Password string `json:"password" binding:"required,password"`
}

Authenticate is validation struct of using during authentication

type Claim added in v1.6.0

type Claim struct {
	Expire string `json:"expire"`
	Token  string `json:"token"`
}

Claim is struct of logged in user claim data

type Date added in v1.6.0

type Date struct {
	time.Time
}

func (Date) MarshalJSON added in v1.6.0

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) Scan added in v1.6.0

func (d *Date) Scan(value any) error

func (*Date) UnmarshalJSON added in v1.6.0

func (d *Date) UnmarshalJSON(b []byte) error

func (Date) Value added in v1.6.0

func (d Date) Value() (driver.Value, error)

type Error

type Error struct {
	Code    int   `json:"code"`
	Message any   `json:"message"`
	Error   error `json:"-"`
}

Error is struct of error object

type Gender added in v1.6.0

type Gender string

type GeneratedPassword added in v1.6.0

type GeneratedPassword struct {
	Password string `json:"password"`
}

GeneratedPassword is struct of generated password

type RegistrationUser added in v1.6.0

type RegistrationUser struct {
	Account     string  `json:"account" binding:"required,min=8,max=20"`
	Name        string  `json:"name" binding:"required,max=50"`
	Gender      string  `json:"gender" binding:"required,oneof=Male Female Unknown"`
	MailAddress string  `json:"mailAddress" binding:"required,email"`
	Birthday    string  `json:"birthday" binding:"required,date"`
	Role        *string `json:"role" binding:"omitempty,oneof=Administrator General"`
}

RegistrationUser is struct of request data for registration user

type Role added in v1.6.0

type Role string

type State

type State struct {
	Status      string `json:"status"`
	Environment string `json:"environment"`
	LogLevel    string `json:"logLevel"`
	TimeZone    string `json:"timezone"`
}

State is struct of Application state

type User

type User struct {
	ID          uint       `gorm:"primary_key" json:"id"`
	Account     string     `gorm:"type:varchar(20);not null;unique_index" json:"account"`
	Name        string     `gorm:"type:varchar(50);not null" json:"name"`
	Password    string     `gorm:"type:varchar(255);not null" json:"-"`
	Gender      Gender     `gorm:"type:enum('Male','Female','Unknown');not null" json:"gender"`
	MailAddress string     `gorm:"type:varchar(255);not null" json:"mailAddress"`
	Birthday    Date       `gorm:"type:date;not null" json:"birthday"`
	Role        Role       `gorm:"type:enum('Administrator','General');not null"`
	LastLogged  *time.Time `gorm:"type:datetime" json:"-"`
	IsActive    bool       `gorm:"type:tinyint;not null" json:"-"`
	IsEnable    bool       `gorm:"type:tinyint;not null" json:"-"`
	CreatedAt   time.Time  `gorm:"type:datetime;not null" sql:"default:current_timestamp" json:"-"`
}

User is struct of authenticated user data

func (*User) DefaultRole added in v1.6.0

func (u *User) DefaultRole() Role

DefaultRole is get user default role

func (*User) Valid added in v1.6.0

func (u *User) Valid() bool

Valid is valid user data

Jump to

Keyboard shortcuts

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