128 lines
2.5 KiB
Python
128 lines
2.5 KiB
Python
from typing import Optional, Any
|
|
|
|
from schemas.attr_select import AttrSelectSchema, AttrOptionSchema
|
|
from schemas.base import BaseSchema, BaseResponse
|
|
|
|
|
|
# region Entity
|
|
|
|
|
|
class AttributeTypeSchema(BaseSchema):
|
|
id: int
|
|
type: str
|
|
name: str
|
|
|
|
|
|
class CreateAttributeSchema(BaseSchema):
|
|
label: str
|
|
is_applicable_to_group: bool
|
|
is_nullable: bool
|
|
default_value: Optional[Any]
|
|
default_option_id: Optional[int] = None
|
|
description: str
|
|
type_id: int
|
|
select_id: Optional[int] = None
|
|
|
|
|
|
class AttributeSchema(CreateAttributeSchema):
|
|
id: int
|
|
is_built_in: bool
|
|
type: AttributeTypeSchema
|
|
default_option: Optional[AttrOptionSchema] = None
|
|
select: Optional[AttrSelectSchema]
|
|
|
|
|
|
class UpdateAttributeSchema(BaseSchema):
|
|
label: Optional[str] = None
|
|
is_applicable_to_group: Optional[bool] = None
|
|
is_nullable: Optional[bool] = None
|
|
default_value: Optional[Any] = None
|
|
default_option_id: Optional[int] = None
|
|
description: Optional[str] = None
|
|
|
|
|
|
class ModuleAttributeSchema(AttributeSchema):
|
|
original_label: str
|
|
|
|
|
|
class DealModuleAttributeSchema(BaseSchema):
|
|
attribute_id: int
|
|
label: str
|
|
original_label: str
|
|
value: Optional[Any]
|
|
type: AttributeTypeSchema
|
|
select: Optional[AttrSelectSchema]
|
|
default_value: Any
|
|
description: str
|
|
is_applicable_to_group: bool
|
|
is_nullable: bool
|
|
|
|
|
|
class UpdateDealModuleAttributeSchema(BaseSchema):
|
|
attribute_id: int
|
|
is_applicable_to_group: bool
|
|
value: Optional[Any] = None
|
|
|
|
|
|
# endregion
|
|
|
|
# region Request
|
|
|
|
|
|
class CreateAttributeRequest(BaseSchema):
|
|
entity: CreateAttributeSchema
|
|
|
|
|
|
class UpdateAttributeRequest(BaseSchema):
|
|
entity: UpdateAttributeSchema
|
|
|
|
|
|
class UpdateAttributeLabelRequest(BaseSchema):
|
|
module_id: int
|
|
attribute_id: int
|
|
label: str
|
|
|
|
|
|
class UpdateDealModuleAttributesRequest(BaseSchema):
|
|
attributes: list[UpdateDealModuleAttributeSchema]
|
|
|
|
|
|
# endregion
|
|
|
|
# region Response
|
|
|
|
|
|
class GetAllAttributesResponse(BaseSchema):
|
|
items: list[AttributeSchema]
|
|
|
|
|
|
class CreateAttributeResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class UpdateAttributeResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class DeleteAttributeResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class UpdateAttributeLabelResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
class GetAllAttributeTypesResponse(BaseSchema):
|
|
items: list[AttributeTypeSchema]
|
|
|
|
|
|
class GetDealModuleAttributesResponse(BaseSchema):
|
|
attributes: list[DealModuleAttributeSchema]
|
|
|
|
|
|
class UpdateDealModuleAttributesResponse(BaseResponse):
|
|
pass
|
|
|
|
|
|
# endregion
|