entities

package
v0.0.0-...-8a84ea6 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	ID           uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
	CustomerID   uint64 `json:"customer_id" gorm:"type:int8"`
	Principal    bool   `json:"principal" gorm:"type:bool;default:false"`
	PostalCode   string `json:"postal_code" gorm:"type:varchar(20)"`
	StreetName   string `json:"street_name" gorm:"type:varchar(250)"`
	StreetNumber string `json:"street_number" gorm:"type:varchar(5)"`
	District     string `json:"district" gorm:"type:varchar(150)"`
	City         string `json:"city" gorm:"type:varchar(150)"`
	Country      string `json:"country" gorm:"type:varchar(2);default:BR"`
}

Address -> Represent a entity customer_address

func (Address) Name

func (Address) Name() string

Name -> gorm config

func (Address) TableName

func (Address) TableName() string

TableName -> gorm config

func (*Address) Validate

func (a *Address) Validate() (map[string]string, error)

Validate -> validate instance

type Customer

type Customer struct {
	ID        uint64    `json:"id" gorm:"primaryKey;autoIncrement"`
	Login     string    `json:"login" gorm:"unique;type:varchar(15)"`
	FirstName string    `json:"firstname" gorm:"type:varchar(150)"`
	LastName  string    `json:"lastname" gorm:"type:varchar(150)"`
	CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"`
	Active    bool      `json:"active" gorm:"default:true"`
	Addresses []Address `json:"addresses" gorm:"foreignKey:CustomerID"`
	Emails    []Email   `json:"emails" gorm:"foreignKey:CustomerID"`
	Phones    []Phone   `json:"phones" gorm:"foreignKey:CustomerID"`
}

Customer -> Represent a entity customer

func (Customer) TableName

func (Customer) TableName() string

TableName -> gorm config

func (*Customer) Validate

func (c *Customer) Validate() (map[string]string, error)

Validate -> validate instance

type Email

type Email struct {
	ID         uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
	CustomerID uint64 `json:"customer_id"`
	Principal  bool   `json:"principal" gorm:"default:false"`
	Email      string `json:"email" gorm:"type:varchar(250)"`
}

Email -> Represent a entity customer_email

func (Email) Name

func (Email) Name() string

Name -> gorm config

func (Email) TableName

func (Email) TableName() string

TableName -> gorm config

func (*Email) Validate

func (e *Email) Validate() (map[string]string, error)

Validate -> validate instance

type Entity

type Entity interface {
	Name() string
	TableName() string
	Validate() (map[string]string, error)
}

Entity -> base entity

type Phone

type Phone struct {
	ID         uint64 `json:"id" gorm:"primaryKey;autoIncrement"`
	CustomerID uint64 `json:"customer_id"`
	Principal  bool   `json:"principal" gorm:"default:false"`
	Ddi        int    `json:"ddi" gorm:"default:55"`
	Phone      string `json:"phone" gorm:"type:varchar(20)"`
}

Phone -> Represent a entity customer_phone

func (Phone) Name

func (Phone) Name() string

Name -> gorm config

func (Phone) TableName

func (Phone) TableName() string

TableName -> gorm config

func (*Phone) Validate

func (p *Phone) Validate() (map[string]string, error)

Validate -> validate instance

type User

type User struct {
	Email    string `json:"email" gorm:"primaryKey"`
	Password string `json:"password" gorm:"type:varchar(200);not null"`
	IsAdmin  bool   `json:"is_admin" gorm:"default:false"`
}

User -> represent an user

func (*User) CreateToken

func (u *User) CreateToken() (string, int64, error)

CreateToken -> return jwk user token

func (*User) CryptPassword

func (u *User) CryptPassword() error

CryptPassword -> crypt password

func (*User) Validate

func (u *User) Validate() (map[string]string, error)

Validate -> validate instance

func (*User) VerifyPassword

func (u *User) VerifyPassword(password string) bool

VerifyPassword -> check password

Jump to

Keyboard shortcuts

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