cms/wwwroot/api/cms_sections_create.dspy
yumoqing f70e8e4d26 fix: 全面修复所有dspy文件和数据库访问模式
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: 正确模式
2026-06-03 18:04:53 +08:00

43 lines
1.3 KiB
Plaintext

config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('entcms')
async with db.sqlorContext(dbname) as sor:
data = {'id': getID()}
v = params_kw.get('org_id', None)
if v is not None:
data['org_id'] = v
v = params_kw.get('section_key', None)
if v is not None:
data['section_key'] = v
v = params_kw.get('title', None)
if v is not None:
data['title'] = v
v = params_kw.get('subtitle', None)
if v is not None:
data['subtitle'] = v
v = params_kw.get('section_type', None)
if v is not None:
data['section_type'] = v
v = params_kw.get('content_type', None)
if v is not None:
data['content_type'] = v
v = params_kw.get('sort_order', None)
if v is not None:
data['sort_order'] = v
v = params_kw.get('is_visible', None)
if v is not None:
data['is_visible'] = v
v = params_kw.get('display_config', None)
if v is not None:
data['display_config'] = v
v = params_kw.get('style_config', None)
if v is not None:
data['style_config'] = v
v = params_kw.get('static_content', None)
if v is not None:
data['static_content'] = v
await sor.C('cms_sections', data)
return {'widgettype': 'Message', 'options': {'text': '创建成功', 'messagetype': 'success'}}