add auth check

This commit is contained in:
2026-08-03 11:16:49 +08:00
parent 6330b99860
commit 92780cedef
18 changed files with 381 additions and 242 deletions
+2 -14
View File
@@ -2,13 +2,10 @@
def _post(payload, timeout=10):
import requests
from api import data_record_url
from api import device_post
try:
response = requests.post(data_record_url, json=payload, timeout=timeout)
response.raise_for_status()
result = response.json()
result = device_post(payload, timeout=timeout)
except Exception as exc:
raise ValueError(f"辨识反馈服务请求失败: {exc}") from exc
if not result.get("success"):
@@ -18,13 +15,10 @@ def _post(payload, timeout=10):
def register_identification_result(run_id: str, timeout=10) -> None:
"""Register one uploaded CSV as the customer's current review target."""
from api import the_folder
if not run_id:
raise ValueError("辨识结果缺少 run_id")
_post({
"type": "registerIdentificationResult",
"deviceId": the_folder,
"runId": run_id,
"fileName": run_id,
}, timeout=timeout)
@@ -32,11 +26,8 @@ def register_identification_result(run_id: str, timeout=10) -> None:
def get_identification_feedback(run_id: str, timeout=10):
"""Return None while pending, otherwise return the integer 0 or 1."""
from api import the_folder
result = _post({
"type": "getIdentificationFeedback",
"deviceId": the_folder,
"runId": run_id,
}, timeout=timeout)
if not result.get("ready"):
@@ -49,10 +40,7 @@ def get_identification_feedback(run_id: str, timeout=10):
def acknowledge_identification_feedback(run_id: str, timeout=10) -> None:
"""Delete the consumed review record so stale feedback cannot be reused."""
from api import the_folder
_post({
"type": "ackIdentificationFeedback",
"deviceId": the_folder,
"runId": run_id,
}, timeout=timeout)