64 lines
1.9 KiB
Python
64 lines
1.9 KiB
Python
from pydantic import BaseModel, ConfigDict, Field
|
|
from pydantic.alias_generators import to_camel
|
|
from pydantic_validation_decorator import NotBlank
|
|
from typing import Optional
|
|
from module_admin.annotation.pydantic_annotation import as_query
|
|
|
|
|
|
|
|
|
|
class Test_eutModel(BaseModel):
|
|
"""
|
|
产品管理表对应pydantic模型
|
|
"""
|
|
model_config = ConfigDict(alias_generator=to_camel, from_attributes=True)
|
|
|
|
id: Optional[int] = Field(default=None, description='产品ID')
|
|
test_order_id: Optional[int] = Field(default=None, description='订单ID')
|
|
test_flow_id: Optional[int] = Field(default=None, description='流程ID')
|
|
test_flow_name: Optional[str] = Field(default=None, description='流程名称')
|
|
test_eut_type_id: Optional[int] = Field(default=None, description='产品类别ID')
|
|
eut_type_name: Optional[str] = Field(default=None, description='产品类别名称')
|
|
sn: Optional[str] = Field(default=None, description='sn号')
|
|
batch_no: Optional[str] = Field(default=None, description='批次号')
|
|
version: Optional[str] = Field(default=None, description='版本号')
|
|
sample_appearance: Optional[int] = Field(default=None, description='外观')
|
|
memo: Optional[str] = Field(default=None, description='备注说明')
|
|
|
|
@NotBlank(field_name='sn', message='sn号不能为空')
|
|
def get_sn(self):
|
|
return self.sn
|
|
|
|
|
|
def validate_fields(self):
|
|
self.get_sn()
|
|
|
|
|
|
|
|
|
|
class Test_eutQueryModel(Test_eutModel):
|
|
"""
|
|
产品管理不分页查询模型
|
|
"""
|
|
pass
|
|
|
|
|
|
@as_query
|
|
class Test_eutPageQueryModel(Test_eutQueryModel):
|
|
"""
|
|
产品管理分页查询模型
|
|
"""
|
|
|
|
page_num: int = Field(default=1, description='当前页码')
|
|
page_size: int = Field(default=10, description='每页记录数')
|
|
|
|
|
|
class DeleteTest_eutModel(BaseModel):
|
|
"""
|
|
删除产品管理模型
|
|
"""
|
|
|
|
model_config = ConfigDict(alias_generator=to_camel)
|
|
|
|
ids: str = Field(description='需要删除的产品ID')
|