contract_management/wwwroot/api/check_contract.dspy
yumoqing a72637b2a3 sync: local modifications to contract_management
- Updated core modules: __init__, ai_config, ai_core, attachment, contract, enhanced_contract
- Updated mysql.ddl.sql
- Updated UI files: contract_detail, contract_edit, contract_list
- Added new files: api/*.dspy, contract_list.dspy
2026-04-28 18:49:46 +08:00

20 lines
801 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
result = {'keys': [], 'rows': []}
try:
dbname = get_module_dbname('contract_management')
async with DBPools().sqlorContext(dbname) as sor:
ns = {'page': 1, 'rows': 50, 'sort': 'COLUMN_NAME'}
sql = "SELECT COLUMN_NAME, COLUMN_TYPE FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='crm_db' AND TABLE_NAME='contract'"
rows = await sor.sqlExe(sql, ns)
if isinstance(rows, dict):
rows = rows.get('rows', [])
if rows:
result['keys'] = list(dict(rows[0]).keys())
result['rows'] = [list(dict(r).values()) for r in rows]
result['success'] = True
except Exception as e:
result['error'] = str(e)
return json.dumps(result, ensure_ascii=False, default=str)