From 5d77e6e20a4095d5cb8dcc4373ffd811c1300486 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 29 Jun 2026 14:34:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20product=5Fcategory=20create/update/delet?= =?UTF-8?q?e=E5=8E=BB=E9=99=A4json.dumps=E5=92=8Cimport;=20create=E8=A1=A5?= =?UTF-8?q?=E5=85=85resource=5Fmodule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wwwroot/api/product_category_create.dspy | 4 ++-- wwwroot/api/product_category_delete.dspy | 13 +++++-------- wwwroot/api/product_category_update.dspy | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/wwwroot/api/product_category_create.dspy b/wwwroot/api/product_category_create.dspy index b7806d3..65561ca 100644 --- a/wwwroot/api/product_category_create.dspy +++ b/wwwroot/api/product_category_create.dspy @@ -34,7 +34,7 @@ try: # Ensure all table fields have values, filter out unknown fields 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'] fields = {} for k in all_fields: @@ -53,4 +53,4 @@ try: except Exception as e: result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'} -return json.dumps(result, ensure_ascii=False) +return result diff --git a/wwwroot/api/product_category_delete.dspy b/wwwroot/api/product_category_delete.dspy index 993dd72..bf1253e 100644 --- a/wwwroot/api/product_category_delete.dspy +++ b/wwwroot/api/product_category_delete.dspy @@ -1,6 +1,3 @@ -#!/usr/bin/env python3 -import json - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} try: @@ -28,8 +25,8 @@ try: {'id': record_id, 'org_id': org_id} ) if children and children[0]['cnt'] > 0: - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': '该类别下有子类别,无法删除', 'type': 'error'}} - return json.dumps(result, ensure_ascii=False) + result = {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '该类别下有子类别,无法删除', 'timeout': 3, 'cwidth': 16, 'cheight': 9}} + return result # Check products products = await sor.sqlExe( @@ -37,8 +34,8 @@ try: {'id': record_id, 'org_id': org_id} ) if products and products[0]['cnt'] > 0: - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': '该类别下有产品,无法删除', 'type': 'error'}} - return json.dumps(result, ensure_ascii=False) + result = {'widgettype': 'Error', 'options': {'title': 'Error', 'message': '该类别下有产品,无法删除', 'timeout': 3, 'cwidth': 16, 'cheight': 9}} + return result await sor.D('product_category', {'id': record_id, 'org_id': org_id}) @@ -47,4 +44,4 @@ try: except Exception as e: result['options'] = {'title': 'Error', 'message': '删除失败: ' + str(e), 'type': 'error'} -return json.dumps(result, ensure_ascii=False) +return result diff --git a/wwwroot/api/product_category_update.dspy b/wwwroot/api/product_category_update.dspy index 1402547..20258d1 100644 --- a/wwwroot/api/product_category_update.dspy +++ b/wwwroot/api/product_category_update.dspy @@ -40,4 +40,4 @@ try: except Exception as e: result['options'] = {'title': 'Error', 'message': '更新失败: ' + str(e), 'type': 'error'} -return json.dumps(result, ensure_ascii=False) +return result