数据:增加测试批次模型与迁移契约
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
from datetime import datetime
|
||||
from typing import Annotated, Literal
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
from pydantic.alias_generators import to_camel
|
||||
|
||||
from module_business.domain.enums import TestBatchStatus
|
||||
|
||||
PositiveId = Annotated[int, Field(gt=0)]
|
||||
|
||||
|
||||
class TestBatchApiModel(BaseModel):
|
||||
model_config = ConfigDict(
|
||||
alias_generator=to_camel,
|
||||
from_attributes=True,
|
||||
populate_by_name=True,
|
||||
extra='forbid',
|
||||
)
|
||||
|
||||
|
||||
class TestBatchCreateModel(TestBatchApiModel):
|
||||
batch_name: str = Field(min_length=1, max_length=100)
|
||||
remark: str | None = Field(default=None, max_length=500)
|
||||
|
||||
|
||||
class TestBatchEditModel(TestBatchApiModel):
|
||||
remark: str | None = Field(default=None, max_length=500)
|
||||
|
||||
|
||||
class TestBatchUserAssignModel(TestBatchApiModel):
|
||||
user_ids: list[PositiveId]
|
||||
|
||||
|
||||
class TestBatchModel(TestBatchApiModel):
|
||||
batch_id: PositiveId
|
||||
batch_code: str
|
||||
batch_name: str
|
||||
status: TestBatchStatus
|
||||
remark: str | None = None
|
||||
create_by: str
|
||||
create_time: datetime
|
||||
update_by: str
|
||||
update_time: datetime
|
||||
closed_by: int | None = None
|
||||
closed_at: datetime | None = None
|
||||
purged_by: int | None = None
|
||||
purged_at: datetime | None = None
|
||||
purge_summary: dict[str, int] | None = None
|
||||
|
||||
|
||||
class TestBatchOptionModel(TestBatchApiModel):
|
||||
batch_id: PositiveId
|
||||
batch_code: str
|
||||
batch_name: str
|
||||
status: TestBatchStatus
|
||||
|
||||
|
||||
class BatchImpactModel(TestBatchApiModel):
|
||||
table_name: str
|
||||
label: str
|
||||
count: int = Field(ge=0)
|
||||
keys: list[str]
|
||||
|
||||
|
||||
class TestBatchDetailModel(TestBatchModel):
|
||||
user_ids: list[int]
|
||||
data_summary: list[BatchImpactModel]
|
||||
|
||||
|
||||
class TestBatchPreviewModel(TestBatchApiModel):
|
||||
batch_id: PositiveId
|
||||
batch_name: str
|
||||
preview_token: str
|
||||
expires_at: datetime
|
||||
total_count: int = Field(ge=0)
|
||||
impacts: list[BatchImpactModel]
|
||||
|
||||
|
||||
class PurgePreviewModel(TestBatchPreviewModel):
|
||||
online_purge_allowed: bool
|
||||
online_purge_limit: int = Field(ge=0)
|
||||
blocking_reason: str | None = None
|
||||
|
||||
|
||||
AdoptionRootType = Literal[
|
||||
'strain',
|
||||
'customer',
|
||||
'site',
|
||||
'line',
|
||||
'warehouse',
|
||||
'pallet',
|
||||
'inbound',
|
||||
'filling',
|
||||
'shipment',
|
||||
'usage',
|
||||
'return',
|
||||
]
|
||||
|
||||
|
||||
class AdoptionRootModel(TestBatchApiModel):
|
||||
resource_type: AdoptionRootType
|
||||
resource_ids: list[PositiveId] = Field(min_length=1)
|
||||
|
||||
|
||||
class AdoptionPreviewRequestModel(TestBatchApiModel):
|
||||
roots: list[AdoptionRootModel] = Field(min_length=1)
|
||||
|
||||
|
||||
class AdoptionExecuteRequestModel(AdoptionPreviewRequestModel):
|
||||
batch_name: str = Field(min_length=1, max_length=100)
|
||||
preview_token: str = Field(min_length=32, max_length=128)
|
||||
|
||||
|
||||
class PurgeExecuteRequestModel(TestBatchApiModel):
|
||||
batch_name: str = Field(min_length=1, max_length=100)
|
||||
preview_token: str = Field(min_length=32, max_length=128)
|
||||
Reference in New Issue
Block a user