cms/wwwroot/api/dd_approval_configs_create.dspy
Hermes Agent 4495e9589b refactor: 从独立webapp重构为纯Sage模块
- cms/: Python包(合并原entcms+dingdingflow)
  - init.py: 791行,load_cms()注册所有CRUD+审批函数
  - dingtalk_client.py: 钉钉API客户端
- models/: 7个表定义JSON(5个CMS+2个DD)
- json/: 7个CRUD定义JSON
- wwwroot/: 管理后台CRUD页面和API(37个dspy)
- init/data.yaml: 模块初始数据(appcodes/appcodes_kv/分类/栏目/配置)
- scripts/load_path.py: RBAC权限配置
- pyproject.toml: pip-installable包定义
- 删除: app/, conf/, build.sh, entcms/, dingdingflow/等webapp文件
- 数据库访问统一为DBPools()+_get_dbname()动态模式
2026-06-15 11:06:11 +08:00

38 lines
1.8 KiB
Plaintext

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 = getID()
org_id = (await get_userorgid()) or '0'
now_str = 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 result