收口审计治理与套餐任务进展

Constraint: 在线热修前必须保存当前迭代分支全部有效代码进展
Confidence: medium
Scope-risk: broad
Directive: 后续修改需保持审计事件与业务事务边界一致
Tested: git diff --cached --check
Not-tested: 未运行全量测试,提交用于切换分支前保存既有工作
This commit is contained in:
2026-08-05 14:30:54 +08:00
parent b3499adfca
commit 5e552d99bc
178 changed files with 16797 additions and 5674 deletions

View File

@@ -76,7 +76,8 @@ class AdminAPIClient:
def login(self, username: str, password: str) -> str:
"""使用后台账号登录并返回 Access Token。"""
result = self._post_json(
result = self._request_json(
"POST",
LOGIN_PATH,
{"username": username, "password": password, "device": "web"},
token=None,
@@ -96,7 +97,8 @@ class AdminAPIClient:
def create_order(self, token: str, identifier: str, package_id: int) -> HTTPResult:
"""为单个资产创建钱包套餐订单。"""
return self._post_json(
return self._request_json(
"POST",
ORDER_PATH,
{
"identifier": identifier,
@@ -106,13 +108,30 @@ class AdminAPIClient:
token=token,
)
def _post_json(self, path: str, payload: dict[str, Any], token: str | None) -> HTTPResult:
body = json.dumps(payload, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
def get_json(self, path: str, token: str) -> HTTPResult:
"""调用后台 GET 接口。"""
return self._request_json("GET", path, None, token)
def patch_json(self, path: str, payload: dict[str, Any], token: str) -> HTTPResult:
"""调用后台 PATCH 接口。"""
return self._request_json("PATCH", path, payload, token)
def _request_json(
self,
method: str,
path: str,
payload: dict[str, Any] | None,
token: str | None,
) -> HTTPResult:
body = None
if payload is not None:
body = json.dumps(payload, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"User-Agent": "junhong-batch-package-purchase/1.0",
}
if payload is not None:
headers["Content-Type"] = "application/json"
if token:
headers["Authorization"] = f"Bearer {token}"
@@ -120,7 +139,7 @@ class AdminAPIClient:
url=self.base_url + path,
data=body,
headers=headers,
method="POST",
method=method,
)
try:
with urlopen(request, timeout=self.timeout) as response: