feat: support editable boxing assignments

This commit is contained in:
Misaka_Company
2026-05-13 11:22:49 +08:00
parent 53abead657
commit 905988bed8
4 changed files with 225 additions and 5 deletions

View File

@@ -19,7 +19,14 @@ 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.box_service import ZongpaiNotFoundError, DuplicateBoxItemError, InvalidZongpaiError, DuplicateZongpaiBindError
from app.services.box_service import (
BoxItemNotFoundError,
DuplicateBoxItemError,
DuplicateZongpaiBindError,
InvalidBoxItemError,
InvalidZongpaiError,
ZongpaiNotFoundError,
)
app = FastAPI(title="CargoTrace API", version="0.1.0")
@@ -120,6 +127,28 @@ async def duplicate_zongpai_bind_handler(request: Request, exc: DuplicateZongpai
)
@app.exception_handler(BoxItemNotFoundError)
async def box_item_not_found_handler(request: Request, exc: BoxItemNotFoundError):
return JSONResponse(
status_code=404,
content={
"error_code": "BOX_ITEM_NOT_FOUND",
"message": "指定装箱明细不存在",
},
)
@app.exception_handler(InvalidBoxItemError)
async def invalid_box_item_handler(request: Request, exc: InvalidBoxItemError):
return JSONResponse(
status_code=400,
content={
"error_code": "INVALID_BOX_ITEM",
"message": "装箱明细记录不合法或不允许修改",
},
)
@app.get("/")
async def root():
return {"message": "Welcome to CargoTrace API"}