Refactoring code for modular approach
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# models/api_models.py - Updated with Marketplace Support
|
||||
from pydantic import BaseModel, Field, field_validator, EmailStr
|
||||
# models/api_models.py - Updated with Marketplace Support and Pydantic v2
|
||||
from pydantic import BaseModel, Field, field_validator, EmailStr, ConfigDict
|
||||
from typing import Optional, List
|
||||
from datetime import datetime
|
||||
|
||||
@@ -36,6 +36,8 @@ class UserLogin(BaseModel):
|
||||
|
||||
|
||||
class UserResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
email: str
|
||||
username: str
|
||||
@@ -45,8 +47,6 @@ class UserResponse(BaseModel):
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class LoginResponse(BaseModel):
|
||||
access_token: str
|
||||
@@ -98,6 +98,8 @@ class ShopUpdate(BaseModel):
|
||||
|
||||
|
||||
class ShopResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
shop_code: str
|
||||
shop_name: str
|
||||
@@ -113,9 +115,6 @@ class ShopResponse(BaseModel):
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class ShopListResponse(BaseModel):
|
||||
shops: List[ShopResponse]
|
||||
@@ -185,12 +184,12 @@ class ProductUpdate(ProductBase):
|
||||
|
||||
|
||||
class ProductResponse(ProductBase):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
# NEW: Shop Product models
|
||||
class ShopProductCreate(BaseModel):
|
||||
@@ -207,6 +206,8 @@ class ShopProductCreate(BaseModel):
|
||||
|
||||
|
||||
class ShopProductResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
shop_id: int
|
||||
product: ProductResponse
|
||||
@@ -223,9 +224,6 @@ class ShopProductResponse(BaseModel):
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
class Config:
|
||||
from_attributes = True
|
||||
|
||||
|
||||
# Stock Models
|
||||
class StockBase(BaseModel):
|
||||
@@ -246,6 +244,8 @@ class StockUpdate(BaseModel):
|
||||
|
||||
|
||||
class StockResponse(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
id: int
|
||||
gtin: str
|
||||
location: str
|
||||
@@ -253,8 +253,6 @@ class StockResponse(BaseModel):
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class StockLocationResponse(BaseModel):
|
||||
location: str
|
||||
|
||||
Reference in New Issue
Block a user