items.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. from typing import List, Optional
  2. from pydantic import BaseModel
  3. class Item(BaseModel):
  4. name: str
  5. price: float
  6. quantity: int
  7. class Order(BaseModel):
  8. """Order model matching the database schema"""
  9. customerName: str
  10. items: List[Item]
  11. totalAmount: float
  12. orderDate: str
  13. table: int
  14. class Product(BaseModel):
  15. """Product model matching the database schema"""
  16. id: int
  17. name: str
  18. type: Optional[str] = None
  19. description: Optional[str] = None
  20. price: int
  21. image: Optional[str] = None
  22. status: int = 1 # 0: Inactive, 1: Active
  23. quantity: Optional[int] = 1 # Optional quantity for the product
  24. promo_id:Optional[int] # ID of the promotional offer if applicable
  25. promo_price:Optional[int] # Promotional price if applicable
  26. promo_day:Optional[int] # Day of the week for promo (1-7)
  27. class ProductEditRequest(BaseModel):
  28. """Request model for editing a product"""
  29. name: Optional[str] = None
  30. type: Optional[str] = None
  31. description: Optional[str] = None
  32. price: Optional[int] = None
  33. image: Optional[str] = None
  34. status: Optional[int] = None # 0: Inactive, 1: Active
  35. quantity: Optional[int] = None # Optional quantity for the product
  36. class ProductCreateRequest(BaseModel):
  37. """Request model for creating a new product"""
  38. id: int
  39. name: str
  40. type: str
  41. description: str
  42. price: int
  43. image: str
  44. status: Optional[int] = 1 # 0: Inactive, 1: Active
  45. quantity: Optional[int] = 1 # Optional quantity for the product
  46. class ProductTypes:
  47. """Enumeration of product types"""
  48. BEER = "Cerveza"
  49. FOOD = "Coctel"
  50. @staticmethod
  51. def get_all_types() -> List[str]:
  52. """Returns a list of all product types"""
  53. atributos = {}
  54. for nombre in dir(ProductTypes):
  55. if not nombre.startswith('_'): # Excluir atributos privados/especiales
  56. valor = getattr(ProductTypes, nombre)
  57. if not callable(valor): # Excluir métodos
  58. atributos[nombre] = valor
  59. return list(atributos.values())
  60. if __name__ == "__main__":
  61. print(ProductTypes.get_all_types())