product_management/wwwroot/api/product_delete.dspy

22 lines
726 B
Python

#!/usr/bin/env python3
import json
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try:
dbname = get_module_dbname('product_management')
data = dict(params_kw)
record_id = data.get('id')
if not record_id:
raise ValueError('Missing id')
async with DBPools().sqlorContext(dbname) as sor:
await sor.D('product', {'id': record_id})
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '产品删除成功', 'type': 'success'}}
except Exception as e:
result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'}
return json.dumps(result, ensure_ascii=False)