feat(douyu): 新增斗鱼查询工作台与失效CK人工重登预算支持 (v0.4.26)

This commit is contained in:
yml
2026-11-30 17:11:14 +08:00
parent 74ceb398b6
commit fdc01826a3
18 changed files with 2863 additions and 37 deletions
+593 -20
View File
@@ -3,10 +3,14 @@
from __future__ import annotations
import asyncio
import csv
import io
import secrets
import uuid
from datetime import UTC, datetime, timedelta
from typing import Any, cast
from weakref import WeakKeyDictionary
from zoneinfo import ZoneInfo
from fastapi import (
APIRouter,
@@ -15,6 +19,7 @@ from fastapi import (
HTTPException,
Query,
Request,
Response,
UploadFile,
WebSocket,
WebSocketDisconnect,
@@ -46,6 +51,8 @@ from ..models import (
DouyuWorkbenchAccount,
DouyuXpdGoodsSnapshot,
ExecutionJob,
LoginAttempt,
LoginTask,
PlatformFulfillmentTask,
User,
)
@@ -58,6 +65,9 @@ from ..schemas import (
DouyuConfigUpdate,
DouyuExchangeResultImageOut,
DouyuGoodsOut,
DouyuQueryWorkbenchExportRequest,
DouyuQueryWorkbenchLookupRequest,
DouyuQueryWorkbenchReloginRequest,
DouyuSupplyTargetConfigOut,
DouyuSupplyTargetOut,
DouyuSupplyTargetUpdate,
@@ -107,6 +117,7 @@ from ..services.douyu_service import (
DOUYU_ACTIVE_TASK_STATUSES,
DOUYU_CONFIG_FIELDS,
DOUYU_HANDBOOK_TASK_TYPES,
LOGIN_ATTEMPT_IN_FLIGHT_STATUSES,
SUPPORTED_DOUYU_TASK_TYPES,
DouyuActivePaymentError,
DouyuLeaseConflictError,
@@ -123,10 +134,14 @@ from ..services.douyu_service import (
)
from ..services.execution_jobs import (
JOB_DOUYU_BATCH,
JOB_LOGIN_BATCH,
JOB_RELOGIN_BATCH,
LANE_AUTH,
LANE_FULFILLMENT,
STATUS_QUEUED,
STATUS_RUNNING,
TERMINAL_STATUSES,
enqueue_execution_job,
event_payload,
execution_events_after,
get_execution_job,
@@ -134,6 +149,11 @@ from ..services.execution_jobs import (
)
from ..services.file_service import FileUploadError
from ..services.file_storage import StorageUnavailableError, max_upload_size_bytes
from ..services.login_quota_service import (
CATEGORY_MANUAL,
get_login_quota_usage_summary,
)
from ..services.login_service import get_relogin_limits
from ..services.platform_fulfillment import service as platform_fulfillment_service
router = APIRouter(prefix="/api/douyu", tags=["斗鱼活动"])
@@ -315,18 +335,19 @@ def _can_view_all(user: User) -> bool:
return user.role != "support" and user_has_permission(user, "account:view_all")
def _visible_task_accounts_query(db: Session, current: User):
def _visible_task_accounts_query(
db: Session, current: User, *, include_all: bool = False
):
"""返回当前用户可用于斗鱼任务的账号查询。
只要账号还持有 Cookie 就可见:排队中的普通登录(pending/running)和
只要账号还持有 Cookie 就可见;排队中的普通登录(pending/running)和
重登失败(relogin_failed)都会保留旧 CK,不能让账号从工作台消失。
查询工作台场景(include_all=True)允许展示无 CK / 已失效等全部可见账号。
"""
cookie_ids = select(Account.id).where(cookie_holding_filter())
query = (
db.query(Account)
.options(joinedload(Account.assigned_user))
.filter(Account.id.in_(cookie_ids))
)
query = db.query(Account).options(joinedload(Account.assigned_user))
if not include_all:
cookie_ids = select(Account.id).where(cookie_holding_filter())
query = query.filter(Account.id.in_(cookie_ids))
if _can_view_all(current):
return query
if user_has_permission(current, "account:view_assigned"):
@@ -617,8 +638,9 @@ def _apply_task_account_filters(
tag: str = "",
account_names: str = "",
ids: str = "",
ck_status: str = "",
):
"""按工作台导入弹窗的搜索、标签、多行账号名筛选任务账号。"""
"""按工作台导入弹窗的搜索、标签、多行账号名与 CK/冷却状态筛选任务账号。"""
id_list = [
int(item)
for item in dict.fromkeys(
@@ -633,6 +655,43 @@ def _apply_task_account_filters(
selected_names = _parse_account_names(account_names)
if selected_names:
query = query.filter(Account.username.in_(selected_names))
ck_filter = (ck_status or "").strip()
if ck_filter == "valid":
query = query.filter(
Account.cookie.isnot(None),
Account.cookie != "",
Account.ck_check_status == "valid",
)
elif ck_filter == "invalid":
query = query.filter(
or_(Account.ck_check_status == "invalid", Account.status == "invalid")
)
elif ck_filter == "no_cookie":
query = query.filter(or_(Account.cookie.is_(None), Account.cookie == ""))
elif ck_filter == "unknown":
query = query.filter(
Account.cookie.isnot(None),
Account.cookie != "",
or_(
Account.ck_check_status.is_(None),
Account.ck_check_status.notin_(("valid", "invalid")),
),
)
elif ck_filter == "cooldown_ready":
now = datetime.now(UTC)
query = query.filter(
Account.role_bind_status == BIND_BOUND,
or_(
Account.role_change_available_at.is_(None),
Account.role_change_available_at <= now,
),
)
elif ck_filter == "cooldown_waiting":
now = datetime.now(UTC)
query = query.filter(
Account.role_bind_status == BIND_BOUND,
Account.role_change_available_at > now,
)
search_text = (search or "").strip()
if search_text:
pattern = f"%{search_text}%"
@@ -673,7 +732,56 @@ def _order_task_accounts(
return query.order_by(Account.id.desc())
def _account_out(account: Account) -> DouyuTaskAccountOut:
def _in_flight_login_account_ids(db: Session, account_ids: list[int]) -> set[int]:
if not account_ids:
return set()
wanted = {int(aid) for aid in account_ids}
active_task_ids = {
int(aid)
for (aid,) in db.query(LoginTask.account_id)
.filter(
LoginTask.account_id.in_(account_ids),
or_(
LoginTask.attempt_status.in_(LOGIN_ATTEMPT_IN_FLIGHT_STATUSES),
LoginTask.status.in_(LOGIN_ATTEMPT_IN_FLIGHT_STATUSES),
),
)
.all()
}
active_attempt_ids = {
int(aid)
for (aid,) in db.query(LoginAttempt.account_id)
.filter(
LoginAttempt.account_id.in_(account_ids),
LoginAttempt.status.in_(("pending", "running")),
)
.all()
}
active_job_ids: set[int] = set()
job_rows = (
db.query(ExecutionJob.payload_json)
.filter(
ExecutionJob.job_type.in_((JOB_LOGIN_BATCH, JOB_RELOGIN_BATCH)),
ExecutionJob.status.in_((STATUS_QUEUED, STATUS_RUNNING)),
)
.all()
)
for (payload,) in job_rows:
if not isinstance(payload, dict):
continue
for raw_id in payload.get("account_ids") or []:
try:
aid = int(raw_id)
except (TypeError, ValueError):
continue
if aid in wanted:
active_job_ids.add(aid)
return active_task_ids | active_attempt_ids | active_job_ids
def _account_out(
account: Account, *, in_flight_login_ids: set[int] | None = None
) -> DouyuTaskAccountOut:
elite_cooldown = account.role_bind_status == BIND_BOUND
esports_cooldown = account.esports_bind_status == BIND_BOUND
return DouyuTaskAccountOut(
@@ -714,6 +822,18 @@ def _account_out(account: Account) -> DouyuTaskAccountOut:
assigned_username=account.assigned_user.username
if account.assigned_user
else None,
account_status=account.status or "",
has_cookie=bool(account.cookie),
points_expire_at=account.points_expire_at,
role_change_available_at=account.role_change_available_at,
role_change_official_at=account.role_change_official_at,
overview_queried_at=account.overview_queried_at,
updated_at=account.updated_at,
in_flight_login=(
int(account.id) in in_flight_login_ids
if in_flight_login_ids is not None
else False
),
)
@@ -881,22 +1001,21 @@ def list_task_accounts(
tag: str = Query(""),
ids: str = Query(""),
account_names: str = Query(""),
ck_status: str = "",
include_all: bool = False,
page: int | None = Query(None, ge=1),
page_size: int = Query(50, ge=1, le=200),
db: Session = Depends(get_db),
current: User = Depends(get_current_user),
):
"""查看可执行斗鱼任务的账号(必须有成功 Cookie)。
tag 按账号标签精确筛选;ids 为逗号分隔的账号 ID,用于工作台按已导入账号过滤;
account_names 为多行斗鱼账户名(每行一个),按粘贴顺序精确匹配;为空时返回全部。
"""
"""查看斗鱼账号。默认只返回持有 Cookie 的可执行账号;include_all=true 时返回全部可见账号(供查询工作台使用)。"""
query, selected_names, selected_ids = _apply_task_account_filters(
_visible_task_accounts_query(db, current),
_visible_task_accounts_query(db, current, include_all=include_all),
search=search,
tag=tag,
account_names=account_names,
ids=ids,
ck_status=ck_status,
)
total = None
if page is not None:
@@ -906,7 +1025,15 @@ def list_task_accounts(
query = query.offset((page - 1) * page_size).limit(page_size)
else:
query = query.limit(500)
result = [_account_out(account) for account in query.all()]
rows = query.all()
in_flight_ids = (
_in_flight_login_account_ids(db, [int(account.id) for account in rows])
if include_all
else None
)
result = [
_account_out(account, in_flight_login_ids=in_flight_ids) for account in rows
]
if page is not None:
return {
"items": result,
@@ -922,15 +1049,18 @@ def list_task_account_ids(
search: str = Query(""),
tag: str = Query(""),
account_names: str = Query(""),
ck_status: str = "",
include_all: bool = False,
db: Session = Depends(get_db),
current: User = Depends(get_current_user),
):
"""返回当前用户可导入工作台的全部账号 ID,不受列表分页限制。"""
query, selected_names, selected_ids = _apply_task_account_filters(
_visible_task_accounts_query(db, current),
_visible_task_accounts_query(db, current, include_all=include_all),
search=search,
tag=tag,
account_names=account_names,
ck_status=ck_status,
)
account_ids = [
account_id
@@ -993,7 +1123,7 @@ def relogin_invalid_task_accounts(
@router.get("/workbench-accounts")
def list_workbench_accounts(
handbook_scope: str = Query(..., pattern="^(elite|esports|peace)$"),
handbook_scope: str = Query(..., pattern="^(elite|esports|peace|query)$"),
db: Session = Depends(get_db),
current: User = Depends(get_current_user),
):
@@ -1070,6 +1200,449 @@ def update_workbench_accounts(
return {"account_ids": account_ids, "success": True}
_SHANGHAI_TZ = ZoneInfo("Asia/Shanghai")
_ACCOUNT_STATUS_LABELS = {
"active": "正常",
"invalid": "CK失效",
"imported": "未登录",
"manual": "待人工",
"disabled": "已停用",
}
def _manual_budget_summary(db: Session) -> dict[str, Any]:
overview = get_login_quota_usage_summary(db)
manual_cat = next(
(
item
for item in overview.get("categories", [])
if item.get("category") == CATEGORY_MANUAL
),
{},
)
return {
"category": CATEGORY_MANUAL,
"label": str(manual_cat.get("label") or "人工登录"),
"quota_day": overview.get("quota_day", ""),
"manual_daily_limit": int(manual_cat.get("limit") or 0),
"manual_daily_used": int(manual_cat.get("used") or 0),
"manual_daily_remaining": int(manual_cat.get("remaining") or 0),
"daily_limit": int(overview.get("daily_limit") or 0),
"daily_used": int(overview.get("daily_used") or 0),
"daily_remaining": int(overview.get("daily_remaining") or 0),
"hourly_limit": int(overview.get("hourly_limit") or 0),
"hourly_used": int(overview.get("hourly_used") or 0),
"hourly_remaining": int(overview.get("hourly_remaining") or 0),
}
def _is_invalid_or_missing_ck(account: Account) -> bool:
if not account.cookie:
return True
return account.ck_check_status == "invalid" or account.status == "invalid"
def _query_workbench_member_ids(db: Session, current: User) -> list[int]:
query = (
db.query(DouyuWorkbenchAccount.account_id)
.join(Account, Account.id == DouyuWorkbenchAccount.account_id)
.filter(
DouyuWorkbenchAccount.user_id == current.id,
DouyuWorkbenchAccount.handbook_scope == "query",
)
)
if not _can_view_all(current):
query = query.filter(Account.assigned_to == current.id)
return [
int(aid)
for (aid,) in query.order_by(
DouyuWorkbenchAccount.sort_order.asc(),
DouyuWorkbenchAccount.id.asc(),
).all()
]
def _format_shanghai_dt(value: datetime | None) -> str:
if value is None:
return ""
aware = value if value.tzinfo else value.replace(tzinfo=UTC)
return aware.astimezone(_SHANGHAI_TZ).strftime("%Y-%m-%d %H:%M:%S")
def _format_cooldown_duration(seconds: int) -> str:
seconds = max(0, int(seconds))
days, rem = divmod(seconds, 86400)
hours, rem = divmod(rem, 3600)
minutes, _ = divmod(rem, 60)
if days > 0:
return f"{days}天{hours}小时{minutes}分"
if hours > 0:
return f"{hours}小时{minutes}分"
return f"{minutes}分"
@router.post("/query-workbench/lookup")
def lookup_query_workbench_accounts(
req: DouyuQueryWorkbenchLookupRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("douyu:task")),
):
"""按粘贴的斗鱼账户名列表批量解析账号(包含 CK 失效与未登录账号),并返回未匹配名清单。"""
names = _parse_account_names("\n".join(req.account_names))
if not names:
raise HTTPException(status_code=400, detail="请先输入至少一个斗鱼账号名")
visible_rows = (
_visible_task_accounts_query(db, current, include_all=True)
.filter(Account.username.in_(names))
.enable_eagerloads(False)
.with_entities(Account.id, Account.username)
.all()
)
by_name: dict[str, int] = {}
for account_id, username in visible_rows:
if username and username not in by_name:
by_name[str(username)] = int(account_id)
matched_ids: list[int] = []
matched_names: list[str] = []
unmatched_names: list[str] = []
for name in names:
aid = by_name.get(name)
if aid is not None:
matched_ids.append(aid)
matched_names.append(name)
else:
unmatched_names.append(name)
return {
"account_ids": matched_ids,
"matched_names": matched_names,
"unmatched_names": unmatched_names,
"total_input": len(names),
}
@router.get("/query-workbench/invalid-ids")
def list_query_workbench_invalid_ids(
db: Session = Depends(get_db),
current: User = Depends(require_permission("douyu:task")),
):
"""返回当前用户查询工作台内全部 CK 失效或无 CK 账号 ID,供一键「选中失效 CK」。"""
member_ids = _query_workbench_member_ids(db, current)
if not member_ids:
return {
"account_ids": [],
"invalid_ck_ids": [],
"no_cookie_ids": [],
"total_invalid": 0,
}
rows = (
_visible_task_accounts_query(db, current, include_all=True)
.filter(Account.id.in_(member_ids))
.enable_eagerloads(False)
.with_entities(
Account.id, Account.cookie, Account.ck_check_status, Account.status
)
.all()
)
row_by_id = {int(r[0]): r for r in rows}
invalid_ck_ids: list[int] = []
no_cookie_ids: list[int] = []
account_ids: list[int] = []
for aid in member_ids:
row = row_by_id.get(aid)
if row is None:
continue
_id, cookie, ck_check_status, status = row
if not cookie:
no_cookie_ids.append(aid)
account_ids.append(aid)
elif ck_check_status == "invalid" or status == "invalid":
invalid_ck_ids.append(aid)
account_ids.append(aid)
return {
"account_ids": account_ids,
"invalid_ck_ids": invalid_ck_ids,
"no_cookie_ids": no_cookie_ids,
"total_invalid": len(account_ids),
}
@router.get("/query-workbench/manual-budget")
def get_query_workbench_manual_budget(
db: Session = Depends(get_db),
current: User = Depends(require_permission("douyu:task")),
):
"""查询今日「人工登录」预算额度,供重新登录前展示。"""
return _manual_budget_summary(db)
@router.post("/query-workbench/relogin-invalid")
def relogin_query_workbench_invalid_accounts(
req: DouyuQueryWorkbenchReloginRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("douyu:task")),
):
"""从查询工作台发起失效/无 CK 账号重新登录,强制走「人工登录」预算(manual_login)。"""
if current.role != "super_admin" and not user_has_permission(current, "login:batch"):
raise HTTPException(
status_code=403, detail="无权限发起重登(需超级管理员或 login:batch 权限)"
)
target_ids = list(dict.fromkeys(int(item) for item in req.ids if int(item) > 0))
if not target_ids and req.select_all_invalid:
target_ids = _query_workbench_member_ids(db, current)
if not target_ids:
raise HTTPException(status_code=400, detail="请先勾选失效 CK 账号")
accounts = (
_visible_task_accounts_query(db, current, include_all=True)
.filter(Account.id.in_(target_ids))
.order_by(Account.id.asc())
.all()
)
if not accounts:
raise HTTPException(status_code=404, detail="没有找到可操作的账号")
in_flight_ids = _in_flight_login_account_ids(
db, [int(account.id) for account in accounts]
)
relogin_ids: list[int] = []
login_ids: list[int] = []
skipped_valid = 0
skipped_in_flight = 0
skipped_missing_credentials = 0
for acc in accounts:
if not _is_invalid_or_missing_ck(acc):
skipped_valid += 1
continue
if int(acc.id) in in_flight_ids:
skipped_in_flight += 1
continue
if not acc.password or not acc.email:
db.add(
LoginTask(
batch_id="relogin-precheck" if acc.cookie else "login-precheck",
account_id=acc.id,
status="failed",
attempt_status="failed",
attempt_message="重新登录失败: 账号缺少密码或邮箱,无法自动登录",
attempt_at=datetime.now(UTC),
created_by=current.id,
)
)
skipped_missing_credentials += 1
continue
if acc.cookie:
relogin_ids.append(int(acc.id))
else:
login_ids.append(int(acc.id))
if not relogin_ids and not login_ids:
db.commit()
reasons: list[str] = []
if skipped_valid:
reasons.append(f"{skipped_valid} 个 CK 仍有效")
if skipped_in_flight:
reasons.append(f"{skipped_in_flight} 个已在登录队列中")
if skipped_missing_credentials:
reasons.append(f"{skipped_missing_credentials} 个缺少密码或邮箱")
detail = "没有可重新登录的失效账号"
if reasons:
detail = f"{detail}({';'.join(reasons)})"
raise HTTPException(status_code=400, detail=detail)
max_login_retries, max_total_time = get_relogin_limits()
batch_ids: list[str] = []
for job_type, mode, batch_account_ids in (
(JOB_RELOGIN_BATCH, "relogin", relogin_ids),
(JOB_LOGIN_BATCH, "login", login_ids),
):
if not batch_account_ids:
continue
batch_id = uuid.uuid4().hex[:12]
enqueue_execution_job(
db,
job_type=job_type,
lane_scope=LANE_AUTH,
batch_id=batch_id,
payload={
"account_ids": batch_account_ids,
"max_login_retries": max_login_retries,
"max_total_time": max_total_time,
"concurrency": 3,
"api_strategy": "wgapi",
"mode": mode,
"trigger_source": "manual",
"category": CATEGORY_MANUAL,
},
created_by=int(current.id),
priority=15,
max_attempts=2,
)
batch_ids.append(batch_id)
total_queued = len(relogin_ids) + len(login_ids)
record_audit(
db,
current,
action="douyu:query_workbench:relogin_invalid",
target=f"人工预算重登 {total_queued} 个失效/无CK账号",
detail={
"category": CATEGORY_MANUAL,
"relogin_count": len(relogin_ids),
"login_count": len(login_ids),
"skipped_valid": skipped_valid,
"skipped_in_flight": skipped_in_flight,
"skipped_missing_credentials": skipped_missing_credentials,
"batch_ids": batch_ids,
},
)
db.commit()
return {
"batch_id": batch_ids[0],
"batch_ids": batch_ids,
"count": total_queued,
"relogin_count": len(relogin_ids),
"login_count": len(login_ids),
"skipped": skipped_valid + skipped_in_flight + skipped_missing_credentials,
"skipped_valid": skipped_valid,
"skipped_in_flight": skipped_in_flight,
"skipped_missing_credentials": skipped_missing_credentials,
"category": CATEGORY_MANUAL,
"manual_budget": _manual_budget_summary(db),
"success": True,
}
@router.post("/query-workbench/export")
def export_query_workbench_csv(
req: DouyuQueryWorkbenchExportRequest,
db: Session = Depends(get_db),
current: User = Depends(require_permission("douyu:task")),
):
"""导出查询工作台账号的鱼翅、积分、换绑时间等结果为 CSV(UTF-8 BOM)。"""
requested_ids = list(dict.fromkeys(int(item) for item in req.ids if int(item) > 0))
if not requested_ids:
requested_ids = _query_workbench_member_ids(db, current)
rows_by_id: dict[int, Account] = {}
if requested_ids:
visible_accounts = (
_visible_task_accounts_query(db, current, include_all=True)
.filter(Account.id.in_(requested_ids))
.all()
)
rows_by_id = {int(acc.id): acc for acc in visible_accounts}
ordered_accounts = [
rows_by_id[aid] for aid in requested_ids if aid in rows_by_id
]
now = datetime.now(UTC)
output = io.StringIO()
writer = csv.writer(output)
writer.writerow(
[
"账号",
"UID",
"昵称",
"标签",
"归属客服",
"账号状态",
"CK状态",
"CK检测时间",
"鱼翅余额",
"兑换余额",
"积分",
"积分到期时间",
"绑定状态",
"绑定角色",
"绑定渠道",
"换绑状态",
"可换绑时间",
"官方换绑时间",
"换绑冷却说明",
"最近更新时间",
]
)
for acc in ordered_accounts:
if not acc.cookie:
ck_label = "无CK"
elif acc.ck_check_status == "valid":
ck_label = "有效"
elif acc.ck_check_status == "invalid":
ck_label = "失效"
else:
ck_label = "未检测"
bind_info = bind_payload(acc)
bind_status = str(bind_info.get("role_bind_status") or acc.role_bind_status or "")
bind_label = str(bind_info.get("role_bind_label") or "")
change_status = "未知"
cooldown_note = ""
available_at = acc.role_change_available_at
if bind_status == "unbound":
change_status = "未绑定角色"
elif bind_status == "pending":
change_status = "待确认绑定"
elif bind_status == BIND_BOUND:
if available_at is not None:
aware = (
available_at
if available_at.tzinfo
else available_at.replace(tzinfo=UTC)
)
if aware > now:
change_status = "冷却中"
cooldown_note = (
f"剩余 {_format_cooldown_duration(int((aware - now).total_seconds()))}"
)
else:
change_status = "可换绑"
cooldown_note = "已过冷却"
elif (acc.change_role_wait_time or 0) > 0:
change_status = "冷却中"
cooldown_note = (
f"剩余 {_format_cooldown_duration(int(acc.change_role_wait_time or 0))}"
)
else:
change_status = "可换绑"
cooldown_note = "可直接换绑"
writer.writerow(
[
acc.username or "",
acc.uid or "",
acc.nickname or "",
acc.tag or "",
acc.assigned_user.username if acc.assigned_user else "未分配",
_ACCOUNT_STATUS_LABELS.get(acc.status or "", acc.status or ""),
ck_label,
_format_shanghai_dt(acc.ck_checked_at),
acc.gold_balance if acc.gold_balance is not None else "",
acc.exchange_balance if acc.exchange_balance is not None else "",
acc.points if acc.points is not None else "",
_format_shanghai_dt(acc.points_expire_at),
bind_label,
acc.game_name or "",
acc.game_channel or "",
change_status,
_format_shanghai_dt(acc.role_change_available_at),
_format_shanghai_dt(acc.role_change_official_at),
cooldown_note,
_format_shanghai_dt(acc.updated_at or acc.overview_queried_at),
]
)
filename = f"douyu_query_workbench_{datetime.now(_SHANGHAI_TZ).strftime('%Y%m%d_%H%M%S')}.csv"
csv_content = "\ufeff" + output.getvalue()
return Response(
content=csv_content,
media_type="text/csv; charset=utf-8",
headers={
"Content-Disposition": f'attachment; filename="{filename}"',
},
)
@router.get("/config", response_model=DouyuConfigOut)
def get_config(
db: Session = Depends(get_db),
@@ -1792,7 +2365,7 @@ async def create_task_batch(
@router.get("/tasks")
def list_tasks(
batch_id: str | None = None,
handbook_scope: str | None = Query(None, pattern="^(elite|esports|peace)$"),
handbook_scope: str | None = Query(None, pattern="^(elite|esports|peace|query)$"),
workbench_only: bool = False,
include_detail: bool = Query(
False, description="是否返回完整任务结果(默认否,轮询请保持 false)"