feat: add one-to-one box mode with duplicate bind check
Add box_mode field to BoxSaveRequest and DuplicateZongpaiBindError exception. In one-to-one mode, prevent the same zongpai from being packed into multiple boxes, returning 409 with existing box info. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
16
app/main.py
16
app/main.py
@@ -19,7 +19,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.box_service import ZongpaiNotFoundError, DuplicateBoxItemError, InvalidZongpaiError
|
||||
from app.services.box_service import ZongpaiNotFoundError, DuplicateBoxItemError, InvalidZongpaiError, DuplicateZongpaiBindError
|
||||
|
||||
app = FastAPI(title="CargoTrace API", version="0.1.0")
|
||||
|
||||
@@ -106,6 +106,20 @@ async def duplicate_box_handler(request: Request, exc: DuplicateBoxItemError):
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(DuplicateZongpaiBindError)
|
||||
async def duplicate_zongpai_bind_handler(request: Request, exc: DuplicateZongpaiBindError):
|
||||
return JSONResponse(
|
||||
status_code=409,
|
||||
content={
|
||||
"error_code": "DUPLICATE_ZONGPAI_BIND",
|
||||
"message": f"总排号 {exc.zongpai_no} 已绑定箱号 {exc.box_no},请勿重复装箱",
|
||||
"paichan_no": exc.paichan_no,
|
||||
"box_no": exc.box_no,
|
||||
"zongpai_no": exc.zongpai_no,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
return {"message": "Welcome to CargoTrace API"}
|
||||
|
||||
Reference in New Issue
Block a user