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: 正确模式
55 lines
1.9 KiB
Plaintext
55 lines
1.9 KiB
Plaintext
result = {'success': False, 'rows': [], 'total': 0}
|
|
|
|
try:
|
|
dbname = get_module_dbname('dingdingflow')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
where_clauses = []
|
|
where_ns = {}
|
|
|
|
# Optional filtering
|
|
is_active = params_kw.get('is_active', '')
|
|
if is_active:
|
|
where_clauses.append("is_active=${is_active}$")
|
|
where_ns['is_active'] = is_active
|
|
|
|
biz_type = params_kw.get('biz_type', '')
|
|
if biz_type:
|
|
where_clauses.append("biz_type=${biz_type}$")
|
|
where_ns['biz_type'] = biz_type
|
|
|
|
where_sql = " AND ".join(where_clauses)
|
|
where_prefix = " WHERE " if where_clauses else ""
|
|
|
|
# Count query
|
|
count_sql = "SELECT count(*) rcnt FROM dd_approval_configs" + where_prefix + where_sql
|
|
count_rows = await sor.sqlExe(count_sql, where_ns)
|
|
total = 0
|
|
if count_rows and len(count_rows) > 0:
|
|
r = count_rows[0]
|
|
total = getattr(r, 'rcnt', 0)
|
|
|
|
if total > 0:
|
|
ns = {
|
|
'page': int(params_kw.get('page', 1)),
|
|
'rows': int(params_kw.get('rows', 20)),
|
|
'sort': params_kw.get('sort', 'biz_type')
|
|
}
|
|
sql = "SELECT id, org_id, biz_type, biz_type_title, process_code, agent_id, form_config, is_active, created_at, updated_at FROM dd_approval_configs" + where_prefix + where_sql
|
|
query_ns = dict(list(ns.items()) + list(where_ns.items()))
|
|
rows = await sor.sqlExe(sql, query_ns)
|
|
|
|
if isinstance(rows, dict):
|
|
result['rows'] = rows.get('rows', [])
|
|
result['total'] = rows.get('total', total)
|
|
elif rows:
|
|
result['rows'] = [dict(r) if hasattr(r, 'keys') else r for r in rows]
|
|
result['total'] = total
|
|
else:
|
|
result['total'] = 0
|
|
|
|
result['success'] = True
|
|
except Exception as e:
|
|
result['error'] = str(e)
|
|
|
|
return result
|