19 lines
603 B
Python
19 lines
603 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.database import get_db
|
|
from app.schemas.location import LocationRequest, LocationResponse
|
|
from app.services.location_service import register_location
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
@router.post("/location", response_model=LocationResponse)
|
|
def create_location(req: LocationRequest, db: Session = Depends(get_db)):
|
|
record = register_location(db, req)
|
|
return LocationResponse(
|
|
zongpai_no=record.zongpai_no,
|
|
location_code=record.location_code,
|
|
created_at=record.created_at.isoformat(),
|
|
)
|