models

package
v0.0.0-...-58bd1cf Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ConfigStyleChecks         = "C"
	ConfigStyleVerticalChecks = "VC"
	ConfigStyleOrderedChecks  = "OC"
	ConfigStyleRadios         = "R"
	ConfigStyleVerticalRadios = "VR"
	ConfigStyleSelect         = "S"
	ConfigStyleMultiSelect    = "MS"
	ConfigStyleTextarea       = "T"
	ConfigStyleNumeric        = "N"
	ConfigStyleDecimal        = "D"
)
View Source
const (
	UserStartID = int64(101)

	RoleSuper   = "$"
	RoleDevel   = "%"
	RoleAdmin   = "A"
	RoleEditor  = "E"
	RoleViewer  = "V"
	RoleApiOnly = "Z"

	UserActive   = "A"
	UserDisabled = "D"
)
View Source
const (
	PrefixTmpFile = "t"
	PrefixJobFile = "j"
	PrefixPetFile = "p"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name       string    `gorm:"size:64;not null;primaryKey"`
	Value      string    `gorm:"not null"`
	Style      string    `gorm:"size:2;not null"`
	Order      int       `gorm:"not null"`
	Required   bool      `gorm:"not null"`
	Secret     bool      `gorm:"not null"`
	Viewer     string    `gorm:"size:1;not null"`
	Editor     string    `gorm:"size:1;not null"`
	Validation string    `gorm:"not null"`
	CreatedAt  time.Time `gorm:"not null;<-:create" json:"created_at"`
	UpdatedAt  time.Time `gorm:"not null;autoUpdateTime:false" json:"updated_at"`
}

func (*Config) DisplayValue

func (c *Config) DisplayValue() string

func (*Config) IsSameMeta

func (c *Config) IsSameMeta(n *Config) bool

func (*Config) Readonly

func (c *Config) Readonly(role string) bool

func (*Config) String

func (c *Config) String() string

func (*Config) Values

func (c *Config) Values() []string

type Pet

type Pet struct {
	ID            int64           `gorm:"not null;primaryKey;autoIncrement" json:"id" form:"id"`
	Name          string          `gorm:"size:100;not null" json:"name" form:"name,strip" validate:"required,maxlen=100"`
	Gender        string          `gorm:"size:1;not null" json:"gender" form:"gender,strip" validate:"required"`
	BornAt        time.Time       `gorm:"not null" json:"born_at" form:"born_at" validate:"required"`
	Origin        string          `gorm:"size:10;not null" json:"origin" form:"origin,strip" validate:"required"`
	Temper        string          `gorm:"size:1;not null" json:"temper" form:"temper,strip" validate:"required"`
	Habits        pqx.StringArray `gorm:"type:character(1)[]" json:"habits" form:"habits,strip"`
	Amount        int             `gorm:"not null" json:"amount" form:"amount"`
	Price         float64         `gorm:"not null;precision:10;scale:2" json:"price" form:"price"`
	ShopName      string          `gorm:"size:200;not null" json:"shop_name" form:"shop_name,strip" validate:"omitempty,maxlen=200"`
	ShopAddress   string          `gorm:"size:200;not null" json:"shop_address" form:"shop_address,strip" validate:"omitempty,maxlen=200"`
	ShopTelephone string          `gorm:"size:20;not null" json:"shop_telephone" form:"shop_telephone,strip" validate:"omitempty,maxlen=200"`
	ShopLink      string          `gorm:"size:1000;not null" json:"shop_link" form:"shop_link,strip" validate:"omitempty,maxlen=1000,url"`
	Description   string          `gorm:"not null" json:"description" form:"description"`
	CreatedAt     time.Time       `gorm:"not null;<-:create" json:"created_at"`
	UpdatedAt     time.Time       `gorm:"not null;autoUpdateTime:true" json:"updated_at"`
}

func (*Pet) PhotoPath

func (p *Pet) PhotoPath() string

func (*Pet) PhotoURI

func (p *Pet) PhotoURI() string

func (*Pet) String

func (p *Pet) String() string

type User

type User struct {
	ID        int64     `gorm:"not null;primaryKey;autoIncrement" json:"id" form:"id"`
	Name      string    `gorm:"size:100;not null" json:"name" form:"name,strip" validate:"required,maxlen=100"`
	Email     string    `gorm:"size:200;not null;uniqueIndex:idx_users_email" json:"email" form:"email,strip" validate:"required,maxlen=200,email"`
	Password  string    `gorm:"size:200;not null" json:"password" form:"password,strip" validate:"omitempty,printascii"`
	Role      string    `gorm:"size:1;not null" json:"role" form:"role,strip" validate:"required"`
	Status    string    `gorm:"size:1;not null" json:"status" form:"status,strip" validate:"required"`
	CIDR      string    `gorm:"column:cidr;not null" json:"cidr" form:"cidr,strip" validate:"omitempty,cidrs"`
	Secret    int64     `gorm:"not null" json:"secret" form:"secret"`
	CreatedAt time.Time `gorm:"not null;<-:create" json:"created_at"`
	UpdatedAt time.Time `gorm:"not null;autoUpdateTime:true" json:"updated_at"`
}

func (*User) CIDRs

func (u *User) CIDRs() (cidrs []*net.IPNet)

func (*User) DisplayName

func (u *User) DisplayName() string

func (*User) GetPassword

func (u *User) GetPassword() string

func (*User) GetUsername

func (u *User) GetUsername() string

func (*User) HasRole

func (u *User) HasRole(role string) bool

func (*User) Initials

func (u *User) Initials() string

func (*User) IsAdmin

func (u *User) IsAdmin() bool

func (*User) IsApiOnly

func (u *User) IsApiOnly() bool

func (*User) IsDevel

func (u *User) IsDevel() bool

func (*User) IsEditor

func (u *User) IsEditor() bool

func (*User) IsSuper

func (u *User) IsSuper() bool

func (*User) IsViewer

func (u *User) IsViewer() bool

func (*User) SetPassword

func (u *User) SetPassword(password string)

func (*User) String

func (u *User) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳