立项配置数据入库、审计日志数据入库、编辑页UI界面美化、设备管理内容补充、审计日志显示优化
This commit is contained in:
@@ -0,0 +1,81 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, field_validator
|
||||
|
||||
|
||||
class MaterialEquipmentCreate(BaseModel):
|
||||
name: str
|
||||
spec_model: str
|
||||
unit: str | None = None
|
||||
brand: str
|
||||
origin: str | None = None
|
||||
production_permit_file_name: str | None = None
|
||||
tech_index_file_name: str | None = None
|
||||
need_calibration: bool
|
||||
calibration_cycle_days: int | None = None
|
||||
|
||||
@field_validator("name", "spec_model", "brand", mode="before")
|
||||
@classmethod
|
||||
def _strip_required(cls, value: str) -> str:
|
||||
text = (value or "").strip()
|
||||
if not text:
|
||||
raise ValueError("不能为空")
|
||||
return text
|
||||
|
||||
@field_validator("unit", "origin", "production_permit_file_name", "tech_index_file_name", mode="before")
|
||||
@classmethod
|
||||
def _strip_optional(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
text = value.strip()
|
||||
return text or None
|
||||
|
||||
|
||||
class MaterialEquipmentUpdate(BaseModel):
|
||||
name: str | None = None
|
||||
spec_model: str | None = None
|
||||
unit: str | None = None
|
||||
brand: str | None = None
|
||||
origin: str | None = None
|
||||
production_permit_file_name: str | None = None
|
||||
tech_index_file_name: str | None = None
|
||||
need_calibration: bool | None = None
|
||||
calibration_cycle_days: int | None = None
|
||||
|
||||
@field_validator("name", "spec_model", "brand", mode="before")
|
||||
@classmethod
|
||||
def _strip_required(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
text = value.strip()
|
||||
if not text:
|
||||
raise ValueError("不能为空")
|
||||
return text
|
||||
|
||||
@field_validator("unit", "origin", "production_permit_file_name", "tech_index_file_name", mode="before")
|
||||
@classmethod
|
||||
def _strip_optional(cls, value: str | None) -> str | None:
|
||||
if value is None:
|
||||
return None
|
||||
text = value.strip()
|
||||
return text or None
|
||||
|
||||
|
||||
class MaterialEquipmentRead(BaseModel):
|
||||
id: uuid.UUID
|
||||
study_id: uuid.UUID
|
||||
name: str
|
||||
spec_model: str
|
||||
unit: str | None
|
||||
brand: str
|
||||
origin: str | None
|
||||
production_permit_file_name: str | None
|
||||
tech_index_file_name: str | None
|
||||
need_calibration: bool
|
||||
calibration_cycle_days: int | None
|
||||
created_by: uuid.UUID | None
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
Reference in New Issue
Block a user