64dc85bd14
- inventory业务层下沉(薄路由+service orchestration模式): - customer/supplier/warehouse -> master_data_service - material_routes(价格历史/趋势/供应商关联)-> material_service - product_routes(CRUD/BOM/from-task跨模块桥接)-> product_service - dashboard_routes(首页统计/低库存预警)-> dashboard_service - inventory侧新增service回归覆盖(dashboard 2 / master_data 10 / material 10 / product 14),含跨模块桥接测试种子 - Pydantic v2弃用清零:全仓14处 class Config 全部迁移到 model_config = ConfigDict(from_attributes=True)(含 shared auth) - datetime.utcnow() 弃用清零:auth_service 3处统一改 datetime.now(timezone.utc) - 同步文档:STATUS / ROADMAP / TECH_DEBT(D12清偿)/ AGENTS 代码地图 测试基线:126 passed, 4 skipped(无deprecation warning) Co-Authored-By: Claude Code <noreply@anthropic.com>
79 lines
2.3 KiB
Python
79 lines
2.3 KiB
Python
"""
|
|
物料管理相关数据模型
|
|
|
|
定义物料价格历史和物料供应商关联的数据结构
|
|
"""
|
|
from pydantic import BaseModel, ConfigDict, Field
|
|
from datetime import datetime
|
|
from typing import Optional, List, Dict
|
|
|
|
|
|
class MaterialPriceHistoryCreate(BaseModel):
|
|
"""创建物料价格历史的请求模型"""
|
|
price: float = Field(..., gt=0, description="物料价格")
|
|
supplier_id: Optional[int] = Field(None, description="供应商ID")
|
|
remark: Optional[str] = Field(None, description="备注")
|
|
|
|
|
|
class MaterialPriceHistoryResponse(BaseModel):
|
|
"""物料价格历史的响应模型"""
|
|
id: int
|
|
product_id: int
|
|
product_sku: str
|
|
product_name: str
|
|
price: float
|
|
effective_date: datetime
|
|
supplier_id: Optional[int]
|
|
supplier_name: Optional[str]
|
|
remark: Optional[str]
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class MaterialSupplierCreate(BaseModel):
|
|
"""创建物料供应商关联的请求模型"""
|
|
supplier_id: int = Field(..., description="供应商ID")
|
|
is_primary: bool = Field(False, description="是否为主要供应商")
|
|
contact_person: Optional[str] = Field(None, description="联系人")
|
|
contact_phone: Optional[str] = Field(None, description="联系电话")
|
|
lead_time: Optional[int] = Field(None, ge=1, description="交货周期(天)")
|
|
min_order_quantity: Optional[int] = Field(None, ge=1, description="最小订购量")
|
|
|
|
|
|
class MaterialSupplierResponse(BaseModel):
|
|
"""物料供应商关联的响应模型"""
|
|
id: int
|
|
product_id: int
|
|
product_sku: str
|
|
product_name: str
|
|
supplier_id: int
|
|
supplier_name: str
|
|
is_primary: bool
|
|
contact_person: Optional[str]
|
|
contact_phone: Optional[str]
|
|
lead_time: Optional[int]
|
|
min_order_quantity: Optional[int]
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class PriceHistoryItem(BaseModel):
|
|
"""价格历史项"""
|
|
date: datetime
|
|
price: float
|
|
supplier_name: Optional[str]
|
|
|
|
|
|
class MaterialPriceTrendResponse(BaseModel):
|
|
"""物料价格趋势的响应模型"""
|
|
product_id: int
|
|
product_sku: str
|
|
product_name: str
|
|
current_price: float
|
|
price_change: float
|
|
price_change_percent: float
|
|
price_history: List[PriceHistoryItem]
|