fix: service schemas fixed
This commit is contained in:
@ -1,7 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import field_validator
|
||||
|
||||
from modules.fulfillment_base.schemas.service_category import ServiceCategorySchema
|
||||
from schemas.base import BaseSchema, BaseResponse
|
||||
|
||||
@ -26,20 +24,20 @@ class CreateServiceSchema(BaseSchema):
|
||||
cost: Optional[float]
|
||||
lexorank: str
|
||||
|
||||
@field_validator("category_id", mode="before")
|
||||
@classmethod
|
||||
def set_category_id(cls, v, info):
|
||||
if v is None and "category" in info.data:
|
||||
return info.data["category"].id
|
||||
return v
|
||||
|
||||
|
||||
class ServiceSchema(CreateServiceSchema):
|
||||
id: int
|
||||
|
||||
|
||||
class UpdateServiceSchema(ServiceSchema):
|
||||
pass
|
||||
class UpdateServiceSchema(BaseSchema):
|
||||
name: Optional[str] = None
|
||||
category: Optional[ServiceCategorySchema] = None
|
||||
category_id: Optional[int] = None
|
||||
price: Optional[float] = None
|
||||
service_type: Optional[int] = None
|
||||
price_ranges: Optional[list[ServicePriceRangeSchema]] = None
|
||||
cost: Optional[float] = None
|
||||
lexorank: Optional[str] = None
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from typing import Optional
|
||||
|
||||
from schemas.base import BaseSchema, BaseResponse
|
||||
|
||||
|
||||
@ -14,8 +16,10 @@ class ServiceCategorySchema(CreateServiceCategorySchema):
|
||||
id: int
|
||||
|
||||
|
||||
class UpdateServiceCategorySchema(ServiceCategorySchema):
|
||||
pass
|
||||
class UpdateServiceCategorySchema(BaseSchema):
|
||||
name: Optional[str] = None
|
||||
deal_service_rank: Optional[str] = None
|
||||
product_service_rank: Optional[str] = None
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
Reference in New Issue
Block a user