models

package
v0.0.0-...-01a878b Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InventoryItem

type InventoryItem struct {
	UUID uuid.UUID
	Qty  int
}

type Order

type Order struct {
	OrderId       uuid.UUID    `json:"order_id" validate:"omitempty"`
	Status        OrderStatus  `json:"status"`
	StatusMessage string       `json:"status_message"`
	Sum           int          `json:"sum" validate:"omitempty"`
	OrderList     []*OrderItem `json:"order_list"`
}

func (*Order) CalculateSum

func (o *Order) CalculateSum()

func (*Order) GetSum

func (o *Order) GetSum() int

type OrderItem

type OrderItem struct {
	ItemId uuid.UUID `json:"item_id" validate:"omitempty"`
	Cost   int       `json:"cost" validate:"min=1"`
	Qty    int       `json:"qty" validate:"min=1"`
	Sum    int       `json:"sum" validate:"omitempty"`
}

func (*OrderItem) CalculateSum

func (o *OrderItem) CalculateSum()

func (*OrderItem) GetSum

func (o *OrderItem) GetSum() int

type OrderStatus

type OrderStatus int64
const (
	OrderStatusUndefined OrderStatus = iota
	OrderStatusCreated
	OrderStatusConfirmed
	OrderStatusPackaged
	OrderStatusInDelivery
	OrderStatusCompleted
	OrderStatusCancelled
)

func (OrderStatus) ToString

func (s OrderStatus) ToString() string

type OrderStatusNotify

type OrderStatusNotify struct {
	OrderId       uuid.UUID   `json:"order_id"`
	Status        OrderStatus `json:"status"`
	StatusMessage string      `json:"status_message"`
}

type Product

type Product struct {
	ProductID   uuid.UUID `json:"product_id" db:"product_id" validate:"omitempty"`
	Name        string    `json:"product_name" db:"product_name" validate:"required,lte=30"`
	Color       string    `json:"color" db:"color" validate:"required,lte=30"`
	Factory     string    `json:"factory" db:"factory" validate:"required,lte=30"`
	Description string    `json:"description" db:"description" validate:"required,lte=126"`
	Cost        int       `json:"cost" db:"cost" validate:"required"`
	CreatedAt   time.Time `json:"created_at,omitempty" db:"created_at"`
	UpdatedAt   time.Time `json:"updated_at,omitempty" db:"updated_at"`
}

Product full model

type ProductList

type ProductList struct {
	TotalCount int        `json:"total_count"`
	TotalPages int        `json:"total_pages"`
	Page       int        `json:"page"`
	Size       int        `json:"size"`
	HasMore    bool       `json:"has_more"`
	Products   []*Product `json:"products"`
}

type Session

type Session struct {
	SessionID string    `json:"session_id" redis:"session_id"`
	UserID    uuid.UUID `json:"user_id" redis:"user_id"`
}

Session model

type User

type User struct {
	UserID    uuid.UUID `json:"user_id" db:"user_id" redis:"user_id" validate:"omitempty"`
	FirstName string    `json:"first_name" db:"first_name" redis:"first_name" validate:"required,lte=30"`
	LastName  string    `json:"last_name" db:"last_name" redis:"last_name" validate:"required,lte=30"`
	Email     string    `json:"email,omitempty" db:"email" redis:"email" validate:"omitempty,lte=60,email"`
	Password  string    `json:"password,omitempty" db:"password" redis:"password" validate:"omitempty,required,gte=6"`
	Role      *string   `json:"role,omitempty" db:"role" redis:"role" validate:"omitempty,lte=10"`
	CreatedAt time.Time `json:"created_at,omitempty" db:"created_at" redis:"created_at"`
	UpdatedAt time.Time `json:"updated_at,omitempty" db:"updated_at" redis:"updated_at"`
	LoginDate time.Time `json:"login_date" db:"login_date" redis:"login_date"`
}

User full model

func (*User) ComparePasswords

func (u *User) ComparePasswords(password string) error

Compare user password and payload

func (*User) HashPassword

func (u *User) HashPassword() error

Hash user password with bcrypt

func (*User) PrepareCreate

func (u *User) PrepareCreate() error

Prepare user for register

func (*User) PrepareUpdate

func (u *User) PrepareUpdate() error

Prepare user for register

func (*User) SanitizePassword

func (u *User) SanitizePassword()

Sanitize user password

type UserWithToken

type UserWithToken struct {
	User  *User  `json:"user"`
	Token string `json:"token"`
}

Find user query

type UsersList

type UsersList struct {
	TotalCount int     `json:"total_count"`
	TotalPages int     `json:"total_pages"`
	Page       int     `json:"page"`
	Size       int     `json:"size"`
	HasMore    bool    `json:"has_more"`
	Users      []*User `json:"users"`
}

All Users response

Jump to

Keyboard shortcuts

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