persistence

package
v0.0.0-...-ca96c0c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PAYMENT_SATUS_OPEN      PaymentStatus = "Aberto"
	PAYMENT_STATUS_APPROVED               = "Aprovado"
	PAYMENT_STATUS_REFUSED                = "Recusado"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CategoriesRepository

type CategoriesRepository interface {
	InsertCategory(ctx context.Context, in *models.Category) (*models.Category, error)
	GetCategoryByID(ctx context.Context, id uuid.UUID) (*models.Category, error)
	DeleteCategory(ctx context.Context, id uuid.UUID) error
	ListCategories(ctx context.Context, limit int, offset int) (*models.CategoryList, error)
}

func NewCategoriesPersistence

func NewCategoriesPersistence(db *gorm.DB, log kitlog.Logger) CategoriesRepository

type Category

type Category struct {
	ID        uuid.UUID `gorm:"id,primaryKey"`
	CreatedAt time.Time
	UpdatedAt sql.NullTime
	Name      string
}

type Order

type Order struct {
	ID        uuid.UUID `gorm:"id,primaryKey"`
	UserID    uuid.UUID
	PaymentID uuid.UUID
	CreatedAt time.Time
	UpdatedAt sql.NullTime
	DeletedAt sql.NullTime
	Price     decimal.Decimal
	Status    OrderStatus
	Products  json.RawMessage `json:"products" gorm:"type:jsonb"`
}

type OrderProduct

type OrderProduct struct {
	ID          uuid.UUID       `gorm:"id,primaryKey" json:"id"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	CategoryID  uuid.UUID       `json:"category_id"`
	Price       decimal.Decimal `json:"price"`
}

type OrderStatus

type OrderStatus int
const (
	ORDER_STATUS_UNSET OrderStatus = iota
	ORDER_STATUS_OPEN
	ORDER_STATUS_WAITING_PAYMENT
	ORDER_STATUS_RECEIVED
	ORDER_STATUS_PREPARING
	ORDER_STATUS_DONE
	ORDER_STATUS_FINISHED
	ORDER_STATUS_CANCELED
)

type OrdersRepository

type OrdersRepository interface {
	GetOrder(ctx context.Context, orderID uuid.UUID) (*models.Order, error)
	GetOrderByPaymentID(ctx context.Context, paymentID uuid.UUID) (*models.Order, error)
	CreateOrder(ctx context.Context, order *models.Order) (*models.Order, error)
	UpdateOrder(ctx context.Context, order *models.Order) (*models.Order, error)
	DeleteOrder(ctx context.Context, orderID uuid.UUID) error
	ListOrdersByUser(ctx context.Context, limit, offset int, userID uuid.UUID) (*models.OrderList, error)
	ListOrders(ctx context.Context, limit, offset int) (*models.OrderList, error)
}

func NewOrdersPersistence

func NewOrdersPersistence(db *gorm.DB, log kitlog.Logger) OrdersRepository

type Payment

type Payment struct {
	ID        uuid.UUID `gorm:"id,primaryKey"`
	CreatedAt time.Time
	UpdatedAt sql.NullTime
	Value     decimal.Decimal `json:"value"`
	OrderID   uuid.UUID
	Status    PaymentStatus
}

type PaymentRepository

type PaymentRepository interface {
	CreatePayment(ctx context.Context, payment *models.Payment) (*models.Payment, error)
	GetPayment(ctx context.Context, paymentID uuid.UUID) (*models.Payment, error)
	UpdatePayment(ctx context.Context, payment *models.Payment) (*models.Payment, error)
}

func NewPaymentsPersistence

func NewPaymentsPersistence(db *gorm.DB, log kitlog.Logger) PaymentRepository

type PaymentStatus

type PaymentStatus string

type Product

type Product struct {
	ID          uuid.UUID       `gorm:"id,primaryKey" json:"id"`
	CreatedAt   time.Time       `json:"created_at"`
	UpdatedAt   sql.NullTime    `json:"updated_at"`
	Name        string          `json:"name"`
	Description string          `json:"description"`
	CategoryID  uuid.UUID       `json:"category_id"`
	Price       decimal.Decimal `json:"price"`
}

type ProductList

type ProductList struct {
	// contains filtered or unexported fields
}

type ProductsRepository

type ProductsRepository interface {
	GetProduct(ctx context.Context, id uuid.UUID) (*models.Product, error)
	InsertProduct(ctx context.Context, product *models.Product) (*models.Product, error)
	UpdateProduct(ctx context.Context, product *models.Product) (*models.Product, error)
	DeleteProduct(ctx context.Context, uuid uuid.UUID) error
	ListProductsByCategory(ctx context.Context, categoryID uuid.UUID, limit, offset int) (*models.ProductList, error)
	GetProductsPriceSumByID(ctx context.Context, ids []uuid.UUID) (*models.ProductsSum, error)
}

func NewProductsPersistence

func NewProductsPersistence(db *gorm.DB, log kitlog.Logger) ProductsRepository

type User

type User struct {
	ID        uuid.UUID `gorm:"id,primaryKey"`
	CreatedAt time.Time
	UpdatedAt sql.NullTime
	DeletedAt sql.NullTime
	Document  string
	Name      string
	Email     string
	IsAdmin   bool
}

Jump to

Keyboard shortcuts

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