feat: deal attributes with select and options
This commit is contained in:
43
schemas/attr_select.py
Normal file
43
schemas/attr_select.py
Normal file
@ -0,0 +1,43 @@
|
||||
from typing import Any
|
||||
|
||||
from schemas.base import BaseSchema
|
||||
|
||||
|
||||
# region Entity
|
||||
|
||||
|
||||
class AttrSelectSchema(BaseSchema):
|
||||
id: int
|
||||
label: str
|
||||
is_built_in: bool
|
||||
|
||||
|
||||
class AttrOptionSchema(BaseSchema):
|
||||
id: int
|
||||
label: str
|
||||
value: Any
|
||||
|
||||
|
||||
class AttrSelectWithOptionsSchema(AttrSelectSchema):
|
||||
options: list[AttrOptionSchema]
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Request
|
||||
|
||||
|
||||
# endregion
|
||||
|
||||
# region Response
|
||||
|
||||
|
||||
class GetAllAttrSelectsResponse(BaseSchema):
|
||||
items: list[AttrSelectSchema]
|
||||
|
||||
|
||||
class GetAllAttrSelectOptionsResponse(BaseSchema):
|
||||
items: list[AttrOptionSchema]
|
||||
|
||||
|
||||
# endregion
|
||||
@ -12,6 +12,11 @@ class AttributeTypeSchema(BaseSchema):
|
||||
name: str
|
||||
|
||||
|
||||
class AttributeSelectSchema(BaseSchema):
|
||||
id: int
|
||||
label: str
|
||||
|
||||
|
||||
class CreateAttributeSchema(BaseSchema):
|
||||
label: str
|
||||
is_applicable_to_group: bool
|
||||
@ -19,12 +24,14 @@ class CreateAttributeSchema(BaseSchema):
|
||||
default_value: Optional[Any]
|
||||
description: str
|
||||
type_id: int
|
||||
select_id: Optional[int]
|
||||
|
||||
|
||||
class AttributeSchema(CreateAttributeSchema):
|
||||
id: int
|
||||
is_built_in: bool
|
||||
type: AttributeTypeSchema
|
||||
select: Optional[AttributeSelectSchema]
|
||||
|
||||
|
||||
class UpdateAttributeSchema(BaseSchema):
|
||||
@ -33,7 +40,6 @@ class UpdateAttributeSchema(BaseSchema):
|
||||
is_nullable: Optional[bool] = None
|
||||
default_value: Optional[Any] = None
|
||||
description: Optional[str] = None
|
||||
type: Optional[AttributeTypeSchema] = None
|
||||
|
||||
|
||||
class ModuleAttributeSchema(AttributeSchema):
|
||||
@ -46,6 +52,7 @@ class DealModuleAttributeSchema(BaseSchema):
|
||||
original_label: str
|
||||
value: Optional[Any]
|
||||
type: AttributeTypeSchema
|
||||
select: Optional[AttributeSelectSchema]
|
||||
default_value: Any
|
||||
description: str
|
||||
is_applicable_to_group: bool
|
||||
|
||||
Reference in New Issue
Block a user