pbl_evidence/wwwroot/api/pbl_evidence_update.dspy

27 lines
1.6 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.

debug(f'pbl_evidence_update.dspy: START params_kw={dict(params_kw)}')
# 证据人工修订端点json/pbl_evidence.json -> update_data_urlDataViewer editable 提交目标)。
# 薄包装:无 import、无业务逻辑直接委托 init.py 注册的 pbl_evidence_update
# (强制 tenant_id 打头校验归属;改唯一索引三元组时同步重算 dedup_key
#
# 返回形态(两处规范硬约束):
# 1) dspy-file-implementation-spec「DataViewer CRUD endpoints 必须返回 Message widget
# JSON 字符串」——本端点是 editable 提交端点,故返回 bricks Message widget
# 表单提交后能正确渲染成功/失败提示;不得返回裸数据 dict。
# 2) 禁项 f-string 出现在 dict 字面量内会被 ahserver exec() 误判提前闭合外层 dict
# SyntaxError: '{' was never closed整文件编译失败异常分支一律用字符串拼接。
try:
_data = await pbl_evidence_update(**dict(params_kw))
_msg = (_data or {}).get('message') or '证据已更新'
_widget = {'widgettype': 'Message',
'options': {'title': '成功', 'message': _msg, 'type': 'success'}}
debug('pbl_evidence_update.dspy: OK')
return json.dumps(_widget, ensure_ascii=False)
except Exception as e:
debug(f'pbl_evidence_update.dspy: FAIL {e}')
debug(f'pbl_evidence_update.dspy: TRACE {format_exc()}')
_widget = {'widgettype': 'Message',
'options': {'title': '失败',
'message': '证据更新失败:' + str(e),
'type': 'error'}}
return json.dumps(_widget, ensure_ascii=False)