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>
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
"""
|
|
仓库管理路由模块
|
|
|
|
提供仓库信息的管理功能,包括:
|
|
- 仓库列表查询(按默认仓库排序)
|
|
- 创建新仓库(自动生成仓库编码)
|
|
|
|
路由前缀: /api/warehouses
|
|
"""
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from typing import List
|
|
|
|
from shared.database.database import get_db_session
|
|
from shared.services.auth_service import get_current_active_user
|
|
from shared.models.identity import User
|
|
from ..schemas import WarehouseCreate, WarehouseResponse
|
|
from ..services.master_data_service import master_data_service
|
|
|
|
router = APIRouter(prefix="/warehouses", tags=["仓库管理"])
|
|
|
|
|
|
@router.get("", response_model=List[WarehouseResponse])
|
|
async def list_warehouses(
|
|
db_session: AsyncSession = Depends(get_db_session),
|
|
current_user: User = Depends(get_current_active_user)
|
|
):
|
|
return await master_data_service.list_warehouses(db_session)
|
|
|
|
|
|
@router.post("", response_model=WarehouseResponse, status_code=201)
|
|
async def create_warehouse(
|
|
warehouse_data: WarehouseCreate,
|
|
db_session: AsyncSession = Depends(get_db_session),
|
|
current_user: User = Depends(get_current_active_user)
|
|
):
|
|
return await master_data_service.create_warehouse(db_session, warehouse_data, current_user)
|