fix: product_category create/update/delete去除json.dumps和import; create补充resource_module

This commit is contained in:
yumoqing 2026-06-29 14:34:31 +08:00
parent 7bdcb8cf5f
commit 5d77e6e20a
3 changed files with 8 additions and 11 deletions

View File

@ -34,7 +34,7 @@ try:
# Ensure all table fields have values, filter out unknown fields # Ensure all table fields have values, filter out unknown fields
all_fields = ['id', 'parent_id', 'name', 'description', 'has_product', all_fields = ['id', 'parent_id', 'name', 'description', 'has_product',
'product_type', 'product_type_title', 'sort_order', 'icon', 'product_type', 'product_type_title', 'resource_module', 'sort_order', 'icon',
'status', 'org_id', 'created_by', 'created_at', 'updated_at'] 'status', 'org_id', 'created_by', 'created_at', 'updated_at']
fields = {} fields = {}
for k in all_fields: for k in all_fields:
@ -53,4 +53,4 @@ try:
except Exception as e: except Exception as e:
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
return json.dumps(result, ensure_ascii=False) return result

View File

@ -1,6 +1,3 @@
#!/usr/bin/env python3
import json
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try: try:
@ -28,8 +25,8 @@ try:
{'id': record_id, 'org_id': org_id} {'id': record_id, 'org_id': org_id}
) )
if children and children[0]['cnt'] > 0: if children and children[0]['cnt'] > 0:
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': '该类别下有子类别,无法删除', 'type': 'error'}} result = {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '该类别下有子类别,无法删除', 'timeout': 3, 'cwidth': 16, 'cheight': 9}}
return json.dumps(result, ensure_ascii=False) return result
# Check products # Check products
products = await sor.sqlExe( products = await sor.sqlExe(
@ -37,8 +34,8 @@ try:
{'id': record_id, 'org_id': org_id} {'id': record_id, 'org_id': org_id}
) )
if products and products[0]['cnt'] > 0: if products and products[0]['cnt'] > 0:
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': '该类别下有产品,无法删除', 'type': 'error'}} result = {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '该类别下有产品,无法删除', 'timeout': 3, 'cwidth': 16, 'cheight': 9}}
return json.dumps(result, ensure_ascii=False) return result
await sor.D('product_category', {'id': record_id, 'org_id': org_id}) await sor.D('product_category', {'id': record_id, 'org_id': org_id})
@ -47,4 +44,4 @@ try:
except Exception as e: except Exception as e:
result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'}
return json.dumps(result, ensure_ascii=False) return result

View File

@ -40,4 +40,4 @@ try:
except Exception as e: except Exception as e:
result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'}
return json.dumps(result, ensure_ascii=False) return result