- 表名统一 dda_ 前缀(dda_approvals/dda_approval_configs),跨应用复用防冲突 - 解耦关键改动:原回调硬编码 biz_type=='content_publish' + 写 cms_content 表, 改为 register_biz_handler(biz_type, handler) 钩子分派,模块内零业务表引用 - 含 models(四段式)/json(CRUD)/9个dspy端点/load_path(any回调+9 logined)/i18n四语言 - README 覆盖凭据配置、审批模板配置、回调地址、审批节点接法(产线步骤)
33 lines
1.4 KiB
Plaintext
33 lines
1.4 KiB
Plaintext
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
record_id = params_kw.get('id', '')
|
|
if not record_id:
|
|
result['options'] = {'title': 'Error', 'message': 'ID is required', 'type': 'error'}
|
|
else:
|
|
dbname = get_module_dbname('dingdingflow')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
update_fields = []
|
|
update_ns = {'id': record_id}
|
|
|
|
for field in ['biz_type', 'biz_type_title', 'process_code', 'agent_id', 'form_config', 'is_active']:
|
|
val = params_kw.get(field)
|
|
if val is not None:
|
|
update_fields.append(f"{field}=${field}$")
|
|
update_ns[field] = val
|
|
|
|
# Always update updated_at
|
|
now_str = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
update_fields.append("updated_at=${updated_at}$")
|
|
update_ns['updated_at'] = now_str
|
|
|
|
if update_fields:
|
|
set_clause = ", ".join(update_fields)
|
|
await sor.sqlExe(f"UPDATE dda_approval_configs SET {set_clause} WHERE id=${id}$", update_ns)
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '审批配置更新成功', 'type': 'success'}}
|
|
except Exception as e:
|
|
result['options'] = {'title': 'Error', 'message': f'更新失败: {str(e)}', 'type': 'error'}
|
|
|
|
return result
|