cms/wwwroot/api/submit_content_approval.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

26 lines
1.2 KiB
Plaintext

config = getConfig('.')
DBPools(config.databases)
dbname = get_module_dbname('cms')
async with db.sqlorContext(dbname) as sor:
content_id = params_kw.get('content_id', '')
if not content_id:
return {'widgettype': 'Message', 'options': {'text': '缺少内容ID', 'messagetype': 'error'}}
else:
# Update status to pending
await sor.U('cms_content', {'id': content_id, 'status': 'pending'})
# Call submit_approval from cms module
try:
user_id = await get_user()
ns_detail = {'id': content_id}
rows = await sor.R('cms_content', ns_detail)
title = rows[0].get('title', '内容审批') if rows else '内容审批'
result = await submit_approval('content_publish', content_id, title, user_id)
if result and result.get('approval_id'):
await sor.U('cms_content', {'id': content_id, 'approval_id': result['approval_id']})
return {'widgettype': 'Message', 'options': {'text': '已提交审批', 'messagetype': 'success'}}
except Exception as e:
return {'widgettype': 'Message', 'options': {'text': f'审批提交失败: {str(e)},状态已改为待审批', 'messagetype': 'warning'}}