items.py 2.1 KB

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