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>
63 lines
1.4 KiB
Python
63 lines
1.4 KiB
Python
from pydantic import BaseModel, ConfigDict
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
|
|
class ProductCreate(BaseModel):
|
|
sku: str
|
|
name: str
|
|
description: Optional[str] = None
|
|
category: Optional[str] = None
|
|
unit: str = "件"
|
|
item_type: str = "finished"
|
|
cost_price: Decimal = Decimal("0")
|
|
sale_price: Decimal = Decimal("0")
|
|
min_stock: int = 0
|
|
max_stock: int = 1000
|
|
|
|
|
|
class ProductResponse(BaseModel):
|
|
id: int
|
|
sku: str
|
|
name: str
|
|
description: Optional[str]
|
|
category: Optional[str]
|
|
unit: str
|
|
item_type: str
|
|
cost_price: Decimal
|
|
sale_price: Decimal
|
|
min_stock: int
|
|
max_stock: int
|
|
material_cost: Decimal = Decimal("0")
|
|
is_active: bool
|
|
created_at: datetime
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
|
|
class ProductMaterialItemUpdate(BaseModel):
|
|
material_id: int
|
|
quantity: Decimal
|
|
loss_rate: Decimal = Decimal("0")
|
|
|
|
|
|
class ProductBOMUpdate(BaseModel):
|
|
items: List[ProductMaterialItemUpdate]
|
|
|
|
|
|
class ProductMaterialItemResponse(BaseModel):
|
|
material_id: int
|
|
material_sku: str
|
|
material_name: str
|
|
quantity: Decimal
|
|
unit_cost: Decimal
|
|
line_cost: Decimal
|
|
|
|
|
|
class ProductBOMResponse(BaseModel):
|
|
product_id: int
|
|
product_name: str
|
|
total_material_cost: Decimal
|
|
items: List[ProductMaterialItemResponse]
|