This commit is contained in:
zlwu committed 2026-05-23 21:27:10 +08:00
1 parent 05684ba2a4
commit 7fbf71b6e1
150 files changed
+19834 -12611

No files matched your search

+32 -32
View File
@@ -101,9 +101,9 @@ async def list_check_items(
result_list = [check_item_svc._row_to_dict(r) for r in items]
return success_response(_page_payload(result_list, total, page, pageSize))
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.get("/sample-reception-check-items/active")
@@ -116,9 +116,9 @@ async def list_active_check_items(
items = check_item_svc.list_active_check_items(db, tenant_no)
return success_response(items)
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.post("/sample-reception-check-items")
@@ -145,11 +145,11 @@ async def create_check_item(
)
return success_response(check_item_svc._row_to_dict(obj))
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.put("/sample-reception-check-items/{row_id}")
@@ -175,11 +175,11 @@ async def update_check_item(
)
return success_response(check_item_svc._row_to_dict(obj))
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.delete("/sample-reception-check-items/{row_id}")
@@ -193,11 +193,11 @@ async def delete_check_item(
check_item_svc.soft_delete_check_item(db, row_id, tenant_no=tenant_no)
return success_response(None)
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
# ---------- 样本接收 ----------
@@ -220,9 +220,9 @@ async def list_pending_samples(
)
return success_response(_page_payload(items, total, page, pageSize))
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.get("/sample-receptions/received")
@@ -242,9 +242,9 @@ async def list_received_samples(
)
return success_response(_page_payload(items, total, page, pageSize))
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.get("/sample-receptions/{reception_id}")
@@ -257,12 +257,12 @@ async def get_sample_reception_detail(
tenant_no = _get_tenant_no(db, user)
item = sr_svc.get_reception_by_id(db, reception_id, tenant_no)
if not item:
return error_response("接收记录不存在", code=404)
return error_response(404, "接收记录不存在")
return success_response(item)
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
class ReceptionCheckSubmit(BaseModel):
@@ -318,7 +318,7 @@ async def post_sample_reception(
dept_id = (sys_user.dept_id or "") if sys_user else ""
rt = parse_datetime(body.reception_time)
if not rt:
return error_response("样本接收时间格式无效")
return error_response(400, "样本接收时间格式无效")
checks_payload = [
{"checkItemId": c.check_item_id, "checked": c.checked} for c in body.checks
]
@@ -344,11 +344,11 @@ async def post_sample_reception(
detail = sr_svc.get_reception_by_id(db, obj.id, tenant_no)
return success_response(detail or {"id": obj.id})
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.put("/sample-receptions/{reception_id}")
@@ -363,7 +363,7 @@ async def put_sample_reception(
user_id = _get_current_user_id(user)
rt = parse_datetime(body.reception_time)
if not rt:
return error_response("样本接收时间格式无效")
return error_response(400, "样本接收时间格式无效")
checks_payload = [
{"checkItemId": c.check_item_id, "checked": c.checked} for c in body.checks
]
@@ -386,11 +386,11 @@ async def put_sample_reception(
detail = sr_svc.get_reception_by_id(db, obj.id, tenant_no)
return success_response(detail or {"id": obj.id})
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))
@router.put("/sample-receptions/{reception_id}")
@@ -405,7 +405,7 @@ async def put_sample_reception(
user_id = _get_current_user_id(user)
rt = parse_datetime(body.reception_time)
if not rt:
return error_response("样本接收时间格式无效")
return error_response(400, "样本接收时间格式无效")
checks_payload = [
{"checkItemId": c.check_item_id, "checked": c.checked} for c in body.checks
]
@@ -428,8 +428,8 @@ async def put_sample_reception(
detail = sr_svc.get_reception_by_id(db, obj.id, tenant_no)
return success_response(detail or {"id": obj.id})
except PermissionError as e:
return error_response(str(e), code=403)
return error_response(403, str(e))
except ValueError as e:
return error_response(str(e))
return error_response(400, str(e))
except Exception as e:
return error_response(str(e))
return error_response(400, str(e))