cms/wwwroot/dingdingflow/api/dd_approval_configs_create.dspy
yumoqing 208625415a refactor: 统一wwwroot目录结构
- 将 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 目录说明
2026-06-03 16:34:00 +08:00

42 lines
1.9 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""dd_approval_configs create API"""
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
try:
biz_type = params_kw.get('biz_type', '')
biz_type_title = params_kw.get('biz_type_title', '')
process_code = params_kw.get('process_code', '')
if not biz_type:
result['options'] = {'title': 'Error', 'message': 'biz_type is required', 'type': 'error'}
else:
new_id = uuid()
org_id = (await get_userorgid()) or '0'
now_str = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
dbname = get_module_dbname('dingdingflow')
async with DBPools().sqlorContext(dbname) as sor:
await sor.sqlExe(
"INSERT INTO dd_approval_configs (id, org_id, biz_type, biz_type_title, process_code, agent_id, form_config, is_active, created_at, updated_at) VALUES (${id}$, ${org_id}$, ${biz_type}$, ${biz_type_title}$, ${process_code}$, ${agent_id}$, ${form_config}$, ${is_active}$, ${created_at}$, ${updated_at}$)",
{
'id': new_id,
'org_id': org_id,
'biz_type': biz_type,
'biz_type_title': biz_type_title,
'process_code': process_code,
'agent_id': params_kw.get('agent_id', ''),
'form_config': params_kw.get('form_config', ''),
'is_active': params_kw.get('is_active', '1'),
'created_at': now_str,
'updated_at': now_str
}
)
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)