feat: support off-shelf location registration

This commit is contained in:
Misaka_Company
2026-05-13 12:43:17 +08:00
parent 905988bed8
commit afc540005c
6 changed files with 123 additions and 5 deletions

View File

@@ -18,7 +18,7 @@ except Exception as e:
from app.api.v1.location import router as location_router
from app.api.v1.box import router as box_router
from app.services.location_service import DuplicateLocationError
from app.services.location_service import AlreadyOffShelfError, DuplicateLocationError
from app.services.box_service import (
BoxItemNotFoundError,
DuplicateBoxItemError,
@@ -47,6 +47,19 @@ async def duplicate_location_handler(request: Request, exc: DuplicateLocationErr
)
@app.exception_handler(AlreadyOffShelfError)
async def already_off_shelf_handler(request: Request, exc: AlreadyOffShelfError):
return JSONResponse(
status_code=409,
content={
"error_code": "ALREADY_OFF_SHELF",
"message": "该总排号已下架至转运区域,不可重新上架",
"location_code": exc.location_code,
"registered_at": exc.registered_at,
},
)
@app.exception_handler(RequestValidationError)
async def validation_error_handler(request: Request, exc: RequestValidationError):
for err in exc.errors():