domain

package
v0.0.0-...-536d685 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const CustomerTable = "customers"
View Source
const DiscountTable = "discounts"
View Source
const LogisticsTable = "logistics"
View Source
const ProductTable = "products"
View Source
const (
	UserTable = "users"
)
View Source
const WarehousePortTable = "warehouses_and_ports"

Variables

This section is empty.

Functions

This section is empty.

Types

type Customer

type Customer struct {
	ID        uuid.UUID `json:"id,omitempty" jsonschema:"description=ID,title=ID"`
	Name      string    `json:"name" jsonschema:"required,description=Name of the customer,title=Name"`
	Email     string    `json:"email" jsonschema:"required,description=Email of the customer,title=Email"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type CustomerRepository

type CustomerRepository interface {
	FindMany(ctx context.Context, pagination *Pagination, filters map[string]interface{}) ([]*Customer, error)
	FindByID(ctx context.Context, id uuid.UUID) (*Customer, error)
	Store(ctx context.Context, c *Customer) (*Customer, error)
	Update(ctx context.Context, c *Customer, id uuid.UUID) (*Customer, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type CustomerUsecase

type CustomerUsecase interface {
	GetMany(pagination *Pagination, filters map[string]interface{}) ([]*Customer, error)
	GetByID(id uuid.UUID) (*Customer, error)
	Create(c *Customer) (*Customer, error)
	Modify(c *Customer, id uuid.UUID) (*Customer, error)
	Remove(id uuid.UUID) error
}

type Discount

type Discount struct {
	ID           uuid.UUID     `json:"id,omitempty"`
	Type         LogisticsType `json:"type" jsonschema:"required,description=Type of logistics,title=Type"`
	QuantityFrom int           `json:"quantity_from" jsonschema:"required,description=Starting quantity for discount,title=Quantity From"`
	QuantityTo   int           `json:"quantity_to" jsonschema:"required,description=Ending quantity for discount,title=Quantity To"`
	Percentage   float64       `json:"percentage" jsonschema:"required,description=Discount percentage,title=Percentage"`
	CreatedAt    time.Time     `json:"created_at,omitempty"`
	UpdatedAt    time.Time     `json:"updated_at,omitempty"`
}

type DiscountRepository

type DiscountRepository interface {
	FindMany(ctx context.Context, pagination *Pagination, filters map[string]interface{}) ([]*Discount, error)
	FindByID(ctx context.Context, id uuid.UUID) (*Discount, error)
	FindByTypeAndQuantity(ctx context.Context, dtype LogisticsType, quantity int) (*Discount, error)
	Store(ctx context.Context, d *Discount) (*Discount, error)
	Update(ctx context.Context, d *Discount, id uuid.UUID) (*Discount, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type DiscountUsecase

type DiscountUsecase interface {
	GetMany(pagination *Pagination, filters map[string]interface{}) ([]*Discount, error)
	GetByTypeAndQuantity(dtype LogisticsType, quantity int) (*Discount, error)
	Create(d *Discount) (*Discount, error)
	Modify(d *Discount, id uuid.UUID) (*Discount, error)
	Remove(id uuid.UUID) error
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type JwtCustomClaims

type JwtCustomClaims struct {
	Email string    `json:"email"`
	ID    uuid.UUID `json:"id"`
	jwt.StandardClaims
}

JwtCustomClaims representa los claims personalizados que se incluyen en el JWT de la plataforma .

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	ID uuid.UUID `json:"id"`
	jwt.StandardClaims
}

JwtCustomRefreshClaims representa los claims personalizados que se incluyen en el JWT de actualización en la plataforma .

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email,omitempty" jsonschema:"required,description=Email of the user,title=Email"`
	Password string `json:"password,omitempty" jsonschema:"required,description=Password of the user,title=Password"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type LoginUsecase

type LoginUsecase interface {
	GetUserByEmail(c context.Context, email string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type Logistics

type Logistics struct {
	ID                    uuid.UUID     `json:"id,omitempty"`
	CustomerID            string        `json:"customer_id" jsonschema:"required,description=ID of the customer,title=Customer ID,type=string"`
	ProductID             string        `json:"product_id" jsonschema:"required,description=ID of the product,title=Product ID,type=string"`
	WarehousePortID       string        `json:"warehouse_port_id" jsonschema:"required,description=ID of the warehouse port,title=Warehouse Port ID,type=string"`
	Type                  LogisticsType `json:"type" jsonschema:"required,description=Type of logistics,title=Type"`
	Quantity              int           `json:"quantity" jsonschema:"required,description=Quantity of items,title=Quantity"`
	RegistrationDate      time.Time     `json:"registration_date" jsonschema:"required,description=Date of registration,title=Registration Date"`
	DeliveryDate          time.Time     `json:"delivery_date" jsonschema:"required,description=Date of delivery,title=Delivery Date"`
	ShippingPrice         float64       `json:"shipping_price" jsonschema:"required,description=Price of shipping,title=Shipping Price"`
	DiscountShippingPrice float64       `json:"discount_shipping_price,omitempty"`
	VehiclePlate          string        `json:"vehicle_plate,omitempty"`
	FleetNumber           string        `json:"fleet_number,omitempty"`
	GuideNumber           string        `json:"guide_number" jsonschema:"required,description=Guide number,title=Guide Number"`
	DiscountPercent       float64       `json:"discount_percent,omitempty"`
	CreatedAt             time.Time     `json:"created_at,omitempty"`
	UpdatedAt             time.Time     `json:"updated_at,omitempty"`
}

func (*Logistics) Validate

func (ll *Logistics) Validate() error

type LogisticsRepository

type LogisticsRepository interface {
	FindMany(ctx context.Context, pagination *Pagination, filters map[string]interface{}) ([]*Logistics, error)
	FindByID(ctx context.Context, id uuid.UUID) (*Logistics, error)
	Store(ctx context.Context, ll *Logistics) (*Logistics, error)
	Update(ctx context.Context, ll *Logistics, id uuid.UUID) (*Logistics, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type LogisticsType

type LogisticsType string
const (
	Land     LogisticsType = "land"
	Maritime LogisticsType = "maritime"
)

type LogisticsUsecase

type LogisticsUsecase interface {
	GetMany(pagination *Pagination, filters map[string]interface{}) ([]*Logistics, error)
	GetByID(id uuid.UUID) (*Logistics, error)
	Create(ll *Logistics) (*Logistics, error)
	Modify(ll *Logistics, id uuid.UUID) (*Logistics, error)
	Remove(id uuid.UUID) error
}

type Pagination

type Pagination struct {
	Limit  *int `json:"limit,omitempty"`
	Offset *int `json:"offset,omitempty"`
}

type Product

type Product struct {
	ID        uuid.UUID `json:"id,omitempty"`
	Name      string    `json:"name" jsonschema:"required,description=Name of the product,title=Name"`
	Type      string    `json:"type" jsonschema:"required,description=Type of product (land or maritime),title=Type"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

type ProductRepository

type ProductRepository interface {
	FindMany(ctx context.Context, pagination *Pagination, filters map[string]interface{}) ([]*Product, error)
	FindByID(ctx context.Context, id uuid.UUID) (*Product, error)
	Store(ctx context.Context, p *Product) (*Product, error)
	Update(ctx context.Context, p *Product, id uuid.UUID) (*Product, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type ProductUsecase

type ProductUsecase interface {
	GetMany(pagination *Pagination, filters map[string]interface{}) ([]*Product, error)
	GetByID(id uuid.UUID) (*Product, error)
	Create(p *Product) (*Product, error)
	Modify(p *Product, id uuid.UUID) (*Product, error)
	Remove(id uuid.UUID) error
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refreshToken" binding:"required"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type RefreshTokenUsecase

type RefreshTokenUsecase interface {
	GetUserByEmail(c context.Context, id string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
	ExtractIDFromToken(requestToken string, secret string) (string, error)
}

type SignupRequest

type SignupRequest struct {
	Email    string `json:"email,omitempty" jsonschema:"description=Email,format=email,title=Email,required"`
	Password string `json:"password,omitempty" jsonschema:"description=Password,title=Password,required"`
}

type SignupResponse

type SignupResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type SignupUsecase

type SignupUsecase interface {
	Create(c context.Context, user *User) (*User, error)
	GetUserByEmail(c context.Context, email string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type SuccessResponse

type SuccessResponse struct {
	Message string `json:"message"`
}

type User

type User struct {
	ID        uuid.UUID `json:"id,omitempty"`
	Email     string    `json:"email" jsonschema:"required,description=Email of the user,title=Email"`
	Password  string    `json:"password" jsonschema:"required,description=Password of the user,title=Password"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

func (*User) ComparePassword

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

ComparePassword compara la contraseña proporcionada con la contraseña almacenada del usuario.

func (*User) SetPassword

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

SetPassword encripta la contraseña y la asigna al usuario.

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, user *User) (*User, error)
	FindByID(ctx context.Context, id uuid.UUID) (*User, error)
	FindByEmail(ctx context.Context, email string) (*User, error)
	Update(ctx context.Context, user *User) (*User, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

UserRepository define los métodos necesarios para interactuar con la base de datos de registros de usuarios.

type UserUseCase

type UserUseCase interface {
	GetByID(ctx context.Context, id uuid.UUID) (*User, error)
	GetByEmail(ctx context.Context, email string) (*User, error)
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id uuid.UUID) error
}

UserUseCase define los métodos necesarios para interactuar con la lógica de negocio de registros de usuarios.

type WarehousePortRepository

type WarehousePortRepository interface {
	FindMany(ctx context.Context, pagination *Pagination, filters map[string]interface{}) ([]*WarehousesAndPorts, error)
	FindByID(ctx context.Context, id uuid.UUID) (*WarehousesAndPorts, error)
	Store(ctx context.Context, wp *WarehousesAndPorts) (*WarehousesAndPorts, error)
	Update(ctx context.Context, wp *WarehousesAndPorts, id uuid.UUID) (*WarehousesAndPorts, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

type WarehousePortUsecase

type WarehousePortUsecase interface {
	GetMany(pagination *Pagination, filters map[string]interface{}) ([]*WarehousesAndPorts, error)
	GetByID(id uuid.UUID) (*WarehousesAndPorts, error)
	Create(wp *WarehousesAndPorts) (*WarehousesAndPorts, error)
	Modify(wp *WarehousesAndPorts, id uuid.UUID) (*WarehousesAndPorts, error)
	Remove(id uuid.UUID) error
}

type WarehousesAndPorts

type WarehousesAndPorts struct {
	ID        uuid.UUID `json:"id,omitempty"`
	Name      string    `json:"name" jsonschema:"required,description=Name of the warehouse or port,title=Name"`
	Type      string    `json:"type" jsonschema:"required,description=Type of the location (land or maritime),title=Type"`
	Location  string    `json:"location" jsonschema:"required,description=Location of the warehouse or port,title=Location"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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