- Updated core.py, init.py, opportunity_core.py, mysql.ddl.sql - Updated UI: base.ui, opportunity_management.ui - Added: opportunity.json, opportunity_stage_history.json - Added API files: opportunities CRUD, sales_stages_list, check_tables - Added UI/DSPY: opportunity_edit, opportunity_list, sales_stages_list
19 lines
769 B
Python
19 lines
769 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
import json
|
|
result = {}
|
|
try:
|
|
dbname = get_module_dbname('opportunity_management')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
ns = {'page': 1, 'rows': 50, 'sort': 'COLUMN_NAME'}
|
|
for tbl in ['opportunities', 'sales_stages']:
|
|
sql = f"SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='crm_db' AND TABLE_NAME='{tbl}'"
|
|
rows = await sor.sqlExe(sql, ns)
|
|
if isinstance(rows, dict):
|
|
rows = rows.get('rows', [])
|
|
result[tbl] = [dict(r).get('column_name', '') for r in rows]
|
|
result['success'] = True
|
|
except Exception as e:
|
|
result['error'] = str(e)
|
|
return json.dumps(result, ensure_ascii=False, default=str)
|