apskel-pos-backend/internal/models/product_ingredient.go

54 lines
1.9 KiB
Go
Raw Permalink Normal View History

2025-08-03 23:55:51 +07:00
package models
import (
"time"
"github.com/google/uuid"
)
type ProductIngredient struct {
2025-09-12 15:37:19 +07:00
ID uuid.UUID `json:"id"`
OrganizationID uuid.UUID `json:"organization_id"`
OutletID *uuid.UUID `json:"outlet_id"`
ProductID uuid.UUID `json:"product_id"`
IngredientID uuid.UUID `json:"ingredient_id"`
Quantity float64 `json:"quantity"`
WastePercentage float64 `json:"waste_percentage"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
2025-08-03 23:55:51 +07:00
// Relations
Product *Product `json:"product,omitempty"`
Ingredient *Ingredient `json:"ingredient,omitempty"`
}
type CreateProductIngredientRequest struct {
2025-09-12 15:37:19 +07:00
OutletID *uuid.UUID `json:"outlet_id"`
ProductID uuid.UUID `json:"product_id" validate:"required"`
IngredientID uuid.UUID `json:"ingredient_id" validate:"required"`
Quantity float64 `json:"quantity" validate:"required,gt=0"`
WastePercentage float64 `json:"waste_percentage" validate:"min=0,max=100"`
2025-08-03 23:55:51 +07:00
}
type UpdateProductIngredientRequest struct {
2025-09-12 15:37:19 +07:00
OutletID *uuid.UUID `json:"outlet_id"`
Quantity float64 `json:"quantity" validate:"required,gt=0"`
WastePercentage float64 `json:"waste_percentage" validate:"min=0,max=100"`
2025-08-03 23:55:51 +07:00
}
type ProductIngredientResponse struct {
2025-09-12 15:37:19 +07:00
ID uuid.UUID `json:"id"`
OrganizationID uuid.UUID `json:"organization_id"`
OutletID *uuid.UUID `json:"outlet_id"`
ProductID uuid.UUID `json:"product_id"`
IngredientID uuid.UUID `json:"ingredient_id"`
Quantity float64 `json:"quantity"`
WastePercentage float64 `json:"waste_percentage"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
2025-08-03 23:55:51 +07:00
// Relations
Product *Product `json:"product,omitempty"`
Ingredient *Ingredient `json:"ingredient,omitempty"`
}