items.py 2.3 KB

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