协作台账:新表 huya_external_orders 替代 Excel 多人协同表(设计见
docs/设计-虎牙外部CK协作台账.md),一条 CK 一行,所有人共享、改动留痕。
- 前端 pages/HuyaCollabPage.tsx + 菜单「虎牙 → 外部单协作」/huya/collab:
内联编辑(带乐观锁 version)、图片缩略图、详情抽屉(字段表单 + 两个图片槽位 +
操作时间线)、粘贴导入弹窗(带 TSV 预览)、批量/单条验证 CK、页头统计条、筛选
- 两套状态机:业务 pending→bound→recharged→scripted→done(旁路 void)、
凭据 unverified/valid/invalid/disabled;唯一写入口在 services/huya_collab_service.py,
字段级审计 + 整数 version 乐观锁(不用 updated_at:DATETIME 只到秒)
- CK 只读探针 check_user_bind_game_account(真机判据:响应非 None 且 status == 200),
成功即覆盖写绑定快照 bind_game_account/bind_game_role/bind_game_channel(迁移 0056),
失败只改凭据状态、不动业务状态;人工只能停用/恢复(POST /{id}/ck/status)
- 贴/换/重建 CK、TSV 批量导入(SAVEPOINT 单行隔离,部分失败不整体失败)、
权限 huya:collab:view/edit/manage(删除只给运营)
- 孤儿图清理脚本 scripts/cleanup_orphan_file_assets.py(默认 --dry-run)
图片上传(协作台账截图用):OSS/本地双后端 + 缩略图变体 + /api/files 代理回读,
权限 file:upload / file:view。
验证:pytest 880 passed / 6 skipped;ruff format 全绿、ruff check 仅剩既有告警;
前端 tsc -b / eslint / vite build 通过;接口端到端冒烟 29 项全绿(TestClient,探针用假客户端);
探针真机冒烟 3 例(有效 CK=True、别人 uid=False、裸 cookie=False)。
112 lines
2.9 KiB
Python
112 lines
2.9 KiB
Python
"""虎牙 API:按账号 / 登录 / 注册 / Cookie / 工作台 / 设备拆分。"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from .accounts import (
|
|
assign_account,
|
|
batch_assign_accounts,
|
|
batch_tag,
|
|
batch_tag_selection,
|
|
create_browser_exchange_kit,
|
|
delete_account,
|
|
delete_accounts_batch,
|
|
delete_accounts_batch_selection,
|
|
import_cookies,
|
|
import_password_accounts,
|
|
list_accounts,
|
|
list_huya_account_ids,
|
|
list_tags,
|
|
set_account_tag,
|
|
)
|
|
from .accounts import router as accounts_router
|
|
from .collab import router as collab_router
|
|
from .cookies import router as cookies_router
|
|
from .devices import router as devices_router
|
|
from .login import (
|
|
app_password_login_account,
|
|
app_password_login_selected_accounts,
|
|
auto_sms_login_account,
|
|
fetch_account_sms_code,
|
|
password_login_account,
|
|
password_login_selected_accounts,
|
|
send_sms_code,
|
|
sms_login_account,
|
|
test_sms_url_endpoint,
|
|
)
|
|
from .login import router as login_router
|
|
from .register import router as register_router
|
|
from .workbench import (
|
|
cleanup_orphan_tasks,
|
|
create_task_batch,
|
|
get_config,
|
|
get_task,
|
|
import_workbench_cookies,
|
|
list_goods,
|
|
list_huya_workbench_accounts,
|
|
list_recharge_goods,
|
|
list_tasks,
|
|
stop_batch,
|
|
task_types,
|
|
tasks_summary,
|
|
update_config,
|
|
update_huya_workbench_accounts,
|
|
ws_huya_logs,
|
|
)
|
|
from .pay import redirect_huya_pay
|
|
from .pay import router as pay_router
|
|
from .workbench import router as workbench_router
|
|
|
|
router = APIRouter(prefix="/api/huya", tags=["虎牙"])
|
|
router.include_router(accounts_router)
|
|
router.include_router(login_router)
|
|
router.include_router(register_router)
|
|
router.include_router(cookies_router)
|
|
router.include_router(workbench_router)
|
|
router.include_router(devices_router)
|
|
router.include_router(pay_router)
|
|
# 外部 CK 协作台账(共享表,替代 Excel)
|
|
router.include_router(collab_router)
|
|
|
|
__all__ = [
|
|
"app_password_login_account",
|
|
"app_password_login_selected_accounts",
|
|
"assign_account",
|
|
"auto_sms_login_account",
|
|
"batch_assign_accounts",
|
|
"batch_tag",
|
|
"batch_tag_selection",
|
|
"cleanup_orphan_tasks",
|
|
"create_browser_exchange_kit",
|
|
"create_task_batch",
|
|
"delete_account",
|
|
"delete_accounts_batch",
|
|
"delete_accounts_batch_selection",
|
|
"fetch_account_sms_code",
|
|
"get_config",
|
|
"get_task",
|
|
"import_cookies",
|
|
"import_password_accounts",
|
|
"import_workbench_cookies",
|
|
"list_accounts",
|
|
"list_goods",
|
|
"list_huya_account_ids",
|
|
"list_huya_workbench_accounts",
|
|
"list_recharge_goods",
|
|
"list_tags",
|
|
"list_tasks",
|
|
"password_login_account",
|
|
"password_login_selected_accounts",
|
|
"redirect_huya_pay",
|
|
"router",
|
|
"send_sms_code",
|
|
"set_account_tag",
|
|
"sms_login_account",
|
|
"stop_batch",
|
|
"task_types",
|
|
"tasks_summary",
|
|
"test_sms_url_endpoint",
|
|
"update_config",
|
|
"update_huya_workbench_accounts",
|
|
"ws_huya_logs",
|
|
]
|