- 将 entcms/wwwroot/* 移到 wwwroot/ - 将 dingdingflow/wwwroot/* 移到 wwwroot/dingdingflow/ - 更新 config.json 使用单一 wwwroot 映射 - 更新 init_any_permissions.py 扫描新路径 - 更新 init_superuser_permissions.py 用法说明 - 废弃 entcms/scripts/load_path.py 和 dingdingflow/scripts/load_path.py - 更新 build.sh 构建步骤 - 更新 README.md 和 docs/architecture.md 目录说明
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""dd_approvals update API"""
|
|
|
|
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_id', 'title', 'applicant_id', 'approver_id', 'dingtalk_instance_id', 'status', 'comment']:
|
|
val = params_kw.get(field)
|
|
if val is not None:
|
|
update_fields.append(f"{field}=${field}$")
|
|
update_ns[field] = val
|
|
|
|
completed_at = params_kw.get('completed_at')
|
|
if completed_at:
|
|
update_fields.append("completed_at=${completed_at}$")
|
|
update_ns['completed_at'] = completed_at
|
|
|
|
if update_fields:
|
|
set_clause = ", ".join(update_fields)
|
|
await sor.sqlExe(f"UPDATE dd_approvals 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 json.dumps(result, ensure_ascii=False)
|