dspy文件修复(27个entcms + 10个dingdingflow): - 删除所有import语句(dspy环境已预加载) - 替换 sor = DBPools().sqlorContext() 为 async with db.sqlorContext() as sor: - 替换 print(json.dumps()) 为 return - 替换 uuid() 为 getID() - 替换 datetime.datetime.now() 为 datetime.now() - 修复 get_user() 缺少 await - 删除shebang/docstrings等无关内容 - 修正缩进 Python模块修复: - entcms/init.py: DBNAME从'entcms'改为'ocai_cms' - app/global_func.py: get_module_dbname返回'ocai_cms'而非'sage' - 所有函数使用 async with db.sqlorContext() as sor: 正确模式
38 lines
1.8 KiB
Plaintext
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
|