customer_management/wwwroot/api/customer_pool_list.dspy
yumoqing 469255afe7 sync: local modifications to customer_management
- Updated core.py
- Updated base.ui
- Added new API files: check_tables, customer_pool_list, customers CRUD, handover_list
- Added new UI/DSPY files: customer_edit, customer_list, customer_pool, handover_list
2026-04-28 18:51:23 +08:00

31 lines
1011 B
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Customer pool list API"""
import json
result = {'success': False, 'rows': [], 'total': 0}
try:
dbname = get_module_dbname('customer_management')
ns = {
'page': int(params_kw.get('page', 1)),
'rows': int(params_kw.get('rows', 20)),
'sort': 'created_at desc'
}
sql = "SELECT id, customer_id, original_owner_id, recycle_reason, inactive_days, recycled_at, pool_status, created_at FROM customer_pool"
async with DBPools().sqlorContext(dbname) as sor:
data = await sor.sqlExe(sql, ns)
if isinstance(data, dict):
result['total'] = data.get('total', 0)
result['rows'] = [dict(r) for r in data.get('rows', [])]
else:
result['rows'] = [dict(r) for r in (data or [])]
result['total'] = len(result['rows'])
result['success'] = True
except Exception as e:
result['error'] = str(e)
return json.dumps(result, ensure_ascii=False, default=str)