fix: unify error response format with error_code, message and domain fields
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,13 +2,27 @@ from fastapi import APIRouter, Depends
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.schemas.common import ErrorResponse
|
||||
from app.schemas.location import LocationRequest, LocationResponse
|
||||
from app.services.location_service import register_location
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/location", response_model=LocationResponse)
|
||||
@router.post(
|
||||
"/location",
|
||||
response_model=LocationResponse,
|
||||
responses={
|
||||
400: {
|
||||
"description": "总排号或货位号格式不合法",
|
||||
"model": ErrorResponse,
|
||||
},
|
||||
409: {
|
||||
"description": "该总排号已存在货位记录",
|
||||
"model": ErrorResponse,
|
||||
},
|
||||
},
|
||||
)
|
||||
def create_location(req: LocationRequest, db: Session = Depends(get_db)):
|
||||
record = register_location(db, req)
|
||||
return LocationResponse(
|
||||
|
||||
Reference in New Issue
Block a user