reallife_asset/wwwroot/api/submit_query_status.dspy
yumoqing daf82107fb feat: add status query flow after upload (frontend专用 dspy)
- submit_upload.dspy: frontend form handler returning bricks Message widget
  with asset_id, status, and '查询处理状态' button
- submit_query_status.dspy: frontend status query returning Message widget
  with current status, retry button when still processing
- upload_asset.ui: use submit_upload.dspy + submited bind (was missing)
- External APIs (rl_upload.dspy, rl_status.dspy) unchanged for downstream systems
2026-05-30 10:22:25 +08:00

69 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

asset_id = params_kw.get('asset_id', '')
if not asset_id:
return json.dumps({
"widgettype": "Error",
"options": {"title": "错误", "message": "缺少素材ID"}
})
org_id = (await get_userorgid()) or '0'
user_id = (await get_user()) or ''
result = await rl_sync_asset_status_user(org_id, asset_id, user_id)
if result.get('success'):
status = result.get('status', '')
url = result.get('url', '')
msg = f"素材状态:{status}"
if url:
msg += f"\n下载地址{url}"
subwidgets = [
{
"widgettype": "Text",
"options": {"text": msg}
}
]
# If still processing, show a retry button
if status and status.lower() in ('processing', 'pending', 'submitted'):
base_path = request.path.rsplit('/', 1)[0]
check_url = base_path + '/submit_query_status.dspy'
subwidgets.append({
"widgettype": "Button",
"options": {"label": "再次查询"},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "(async function(){"
"var url='" + check_url + "?_webbricks_=1&asset_id=" + asset_id + "';"
"var r=await fetch(url);"
"var j=await r.json();"
"await bricks.show_resp_message_or_error({json:async function(){return j}});"
"})()"
}
]
})
return json.dumps({
"widgettype": "Message",
"id": "status_result_popup",
"options": {"title": "素材状态", "message": ""},
"subwidgets": [
{
"widgettype": "VBox",
"options": {"padding": "8px", "gap": "12px"},
"subwidgets": subwidgets
}
]
})
else:
return json.dumps({
"widgettype": "Error",
"options": {"title": "查询失败", "message": result.get('message', '未知错误')}
})