pbl_evidence/wwwroot/api/pbl_evidence_delete.dspy

27 lines
1.7 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_delete.dspy: START params_kw={dict(params_kw)}')
# 证据删除端点json/pbl_evidence.json -> delete_data_urlDataViewer editable 提交目标)。
# 薄包装:无 import、无业务逻辑直接委托 init.py 注册的 pbl_evidence_delete
# (支持单条 id 与批量 ids每条都按 tenant_id + id 双条件校验归属,防越权删除)。
#
# 返回形态(两处规范硬约束):
# 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_delete(**dict(params_kw))
_msg = (_data or {}).get('message') or '证据已删除'
_widget = {'widgettype': 'Message',
'options': {'title': '成功', 'message': _msg, 'type': 'success'}}
debug('pbl_evidence_delete.dspy: OK deleted=' + str((_data or {}).get('deleted')))
return json.dumps(_widget, ensure_ascii=False)
except Exception as e:
debug(f'pbl_evidence_delete.dspy: FAIL {e}')
debug(f'pbl_evidence_delete.dspy: TRACE {format_exc()}')
_widget = {'widgettype': 'Message',
'options': {'title': '失败',
'message': '证据删除失败:' + str(e),
'type': 'error'}}
return json.dumps(_widget, ensure_ascii=False)