31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
|
|
from fastapi import APIRouter, Depends, Query, HTTPException
|
||
|
|
from sqlalchemy.orm import Session
|
||
|
|
from typing import List
|
||
|
|
from app.utils.database import get_db
|
||
|
|
from app.services.location_service import LocationService
|
||
|
|
from app.schemas.location import LocationQueryRequest
|
||
|
|
from app.schemas.common import BaseWmsApiResponse, WmsApiResponse
|
||
|
|
from app.models.location import TAppLocation
|
||
|
|
|
||
|
|
router = APIRouter(prefix="/wms/location", tags=["库位管理"])
|
||
|
|
|
||
|
|
|
||
|
|
def get_location_service(db: Session = Depends(get_db)) -> LocationService:
|
||
|
|
return LocationService(db)
|
||
|
|
|
||
|
|
|
||
|
|
@router.post("/genLocations", response_model=BaseWmsApiResponse)
|
||
|
|
async def gen_locations(
|
||
|
|
location_query: LocationQueryRequest,
|
||
|
|
location_service: LocationService = Depends(get_location_service)
|
||
|
|
) -> BaseWmsApiResponse:
|
||
|
|
return location_service.gen_locations(location_query)
|
||
|
|
|
||
|
|
|
||
|
|
@router.get("/getUsedLocations", response_model=WmsApiResponse)
|
||
|
|
async def get_used_locations(
|
||
|
|
equipment_id: int = Query(..., description="设备ID"),
|
||
|
|
location_type: int = Query(..., description="库位类型"),
|
||
|
|
location_service: LocationService = Depends(get_location_service)
|
||
|
|
) -> WmsApiResponse:
|
||
|
|
return location_service.get_used_locations(equipment_id, location_type)
|