entcms模块: - 4个数据表(cms_content/cms_categories/cms_leads/cms_site_config) - 22个.dspy API(含公开API和data_filter) - 4个公开页面(首页/新闻/案例)+管理后台 - 完整营销站点CSS/JS(暗色主题/渐变/动画/响应式) - 云宝SVG线稿占位符 - RBAC权限配置 dingdingflow模块: - 2个数据表(dd_approvals/dd_approval_configs) - 10个.dspy API(含钉钉回调endpoint) - 钉钉API客户端(环境变量配置,开发模式mock) - 管理UI 文档: 架构设计/53条测试用例/开发日志
44 lines
2.0 KiB
Python
44 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""dd_approvals create API"""
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
biz_type = params_kw.get('biz_type', '')
|
|
biz_id = params_kw.get('biz_id', '')
|
|
title = params_kw.get('title', '')
|
|
applicant_id = params_kw.get('applicant_id', '')
|
|
|
|
if not biz_type or not title:
|
|
result['options'] = {'title': 'Error', 'message': 'biz_type and title are 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_approvals (id, org_id, biz_type, biz_id, title, applicant_id, approver_id, dingtalk_instance_id, status, comment, created_at) VALUES (${id}$, ${org_id}$, ${biz_type}$, ${biz_id}$, ${title}$, ${applicant_id}$, ${approver_id}$, ${dingtalk_instance_id}$, ${status}$, ${comment}$, ${created_at}$)",
|
|
{
|
|
'id': new_id,
|
|
'org_id': org_id,
|
|
'biz_type': biz_type,
|
|
'biz_id': biz_id,
|
|
'title': title,
|
|
'applicant_id': applicant_id,
|
|
'approver_id': params_kw.get('approver_id', ''),
|
|
'dingtalk_instance_id': params_kw.get('dingtalk_instance_id', ''),
|
|
'status': params_kw.get('status', 'pending'),
|
|
'comment': params_kw.get('comment', ''),
|
|
'created_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)
|