feat(dispatch): 주문/패키지/송장 번호로 받는 사람 찾기 검색
배치 목록 상단에 검색 박스 추가. 주문번호·패키지번호·송장번호 일부만 입력하면 전체 출고 배치에서 해당 박스의 받는 사람(이름·전화·주소)과 소속 배치를 찾아준다. - db.search_parcels: 3개 식별자 ILIKE 부분일치 + 배치 조인(파라미터 바인딩) - GET /dispatch/api/search: 2글자 이상, dispatch 권한 가드 - batches.html: 디바운스 검색 UI, 매칭 강조, 한/영 토글 연동 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -715,6 +715,20 @@ async def api_parcels(
|
||||
return JSONResponse({"parcels": st.list_parcels(batch_id=batch_id)})
|
||||
|
||||
|
||||
@router.get("/api/search")
|
||||
async def api_search(
|
||||
request: Request, q: str = "", _: dict[str, Any] = Depends(_require_user)
|
||||
) -> JSONResponse:
|
||||
"""주문번호/패키지번호/송장번호(부분 일치)로 박스 검색 → 받는 사람/배치 반환."""
|
||||
st = _store(request)
|
||||
if st is None:
|
||||
raise HTTPException(status_code=503, detail="dispatch_db 미설정")
|
||||
query = (q or "").strip()
|
||||
if len(query) < 2:
|
||||
return JSONResponse({"query": query, "results": []})
|
||||
return JSONResponse({"query": query, "results": st.search_parcels(query=query)})
|
||||
|
||||
|
||||
@router.get("/health")
|
||||
async def health() -> dict[str, str]:
|
||||
return {"status": "ok", "module": "dispatch"}
|
||||
|
||||
Reference in New Issue
Block a user