31 lines
906 B
Python
31 lines
906 B
Python
|
|
"""基础档案待确认分类的批量补充。"""
|
||
|
|
|
||
|
|
from typing import Literal
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||
|
|
|
||
|
|
|
||
|
|
class CategoryBatch(BaseModel):
|
||
|
|
model_config = ConfigDict(extra="forbid")
|
||
|
|
ids: list[int] = Field(min_length=1, max_length=200)
|
||
|
|
|
||
|
|
@field_validator("ids")
|
||
|
|
@classmethod
|
||
|
|
def validate_ids(cls, value):
|
||
|
|
if any(item < 1 for item in value) or len(value) != len(set(value)):
|
||
|
|
raise ValueError("档案 ID 必须为不重复的正整数")
|
||
|
|
return value
|
||
|
|
|
||
|
|
|
||
|
|
class CustomerCategoryBatch(CategoryBatch):
|
||
|
|
category: Literal["personal", "manager_personal", "enterprise"]
|
||
|
|
|
||
|
|
|
||
|
|
class ProductCategoryBatch(CategoryBatch):
|
||
|
|
category: Literal["municipal_water", "rail_transit"]
|
||
|
|
|
||
|
|
|
||
|
|
class CustomerOwnershipBatch(CategoryBatch):
|
||
|
|
new_owner_personnel_id: int = Field(ge=1)
|
||
|
|
reason: str | None = Field(default=None, max_length=255)
|