| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- from typing import List, Optional
- from pydantic import BaseModel
- class Item(BaseModel):
- name: str
- price: float
- quantity: int
- class Order(BaseModel):
- """Order model matching the database schema"""
- customerName: str
- items: List[Item]
- totalAmount: float
- orderDate: str
- table: int
- class Product(BaseModel):
- """Product model matching the database schema"""
- id: int
- name: str
- type: Optional[str] = None
- description: Optional[str] = None
- price: int
- image: Optional[str] = None
- status: int = 1 # 0: Inactive, 1: Active
- quantity: Optional[int] = 1 # Optional quantity for the product
- promo_id:Optional[int] # ID of the promotional offer if applicable
- promo_price:Optional[int] # Promotional price if applicable
- promo_day:Optional[int] # Day of the week for promo (1-7)
-
- class ProductEditRequest(BaseModel):
- """Request model for editing a product"""
- name: Optional[str] = None
- type: Optional[str] = None
- description: Optional[str] = None
- price: Optional[int] = None
- image: Optional[str] = None
- status: Optional[int] = None # 0: Inactive, 1: Active
- quantity: Optional[int] = None # Optional quantity for the product
- class ProductCreateRequest(BaseModel):
- """Request model for creating a new product"""
- id: int
- name: str
- type: str
- description: str
- price: int
- image: str
- status: Optional[int] = 1 # 0: Inactive, 1: Active
- quantity: Optional[int] = 1 # Optional quantity for the product
- class ProductTypes:
- """Enumeration of product types"""
- BEER = "Cerveza"
- FOOD = "Coctel"
- @staticmethod
- def get_all_types() -> List[str]:
- """Returns a list of all product types"""
- atributos = {}
- for nombre in dir(ProductTypes):
- if not nombre.startswith('_'): # Excluir atributos privados/especiales
- valor = getattr(ProductTypes, nombre)
- if not callable(valor): # Excluir métodos
- atributos[nombre] = valor
- return list(atributos.values())
-
- if __name__ == "__main__":
- print(ProductTypes.get_all_types())
|