24 lines
911 B
Python
24 lines
911 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Opportunity predictions delete API"""
|
|
import json
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
row_id = params_kw.get('id', '').strip()
|
|
|
|
if not row_id:
|
|
result['options'] = {'title': 'Error', 'message': '缺少记录ID', 'type': 'error'}
|
|
else:
|
|
dbname = get_module_dbname('opportunity_management')
|
|
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
await sor.sqlExe("DELETE FROM opportunity_predictions WHERE id=${id}$", {'id': row_id})
|
|
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)
|