diff --git a/.gitignore b/.gitignore index c733c37..d5c080a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ product_management.egg-info/ __pycache__/ +*.pyc +*.pyo +*.egg-info/ +.DS_Store diff --git a/models/product_category.json b/models/product_category.json index da3115e..66b39f6 100644 --- a/models/product_category.json +++ b/models/product_category.json @@ -21,7 +21,8 @@ "name": "parent_id", "title": "父类别ID", "type": "str", - "length": 32 + "length": 32, + "nullable": "yes" }, { "name": "name", diff --git a/product_management.egg-info/PKG-INFO b/product_management.egg-info/PKG-INFO deleted file mode 100644 index c1d3aec..0000000 --- a/product_management.egg-info/PKG-INFO +++ /dev/null @@ -1,7 +0,0 @@ -Metadata-Version: 2.4 -Name: product_management -Version: 1.0.0 -Summary: Sage product management module - dynamic category tree, product registry, operator config, standardized API -Requires-Python: >=3.8 -Requires-Dist: sqlor -Requires-Dist: bricks_for_python diff --git a/product_management.egg-info/SOURCES.txt b/product_management.egg-info/SOURCES.txt deleted file mode 100644 index d52c828..0000000 --- a/product_management.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -README.md -pyproject.toml -product_management/__init__.py -product_management/core.py -product_management/init.py -product_management.egg-info/PKG-INFO -product_management.egg-info/SOURCES.txt -product_management.egg-info/dependency_links.txt -product_management.egg-info/requires.txt -product_management.egg-info/top_level.txt \ No newline at end of file diff --git a/product_management.egg-info/dependency_links.txt b/product_management.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/product_management.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/product_management.egg-info/requires.txt b/product_management.egg-info/requires.txt deleted file mode 100644 index 3f3a3f3..0000000 --- a/product_management.egg-info/requires.txt +++ /dev/null @@ -1,2 +0,0 @@ -sqlor -bricks_for_python diff --git a/product_management.egg-info/top_level.txt b/product_management.egg-info/top_level.txt deleted file mode 100644 index 5461594..0000000 --- a/product_management.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -product_management diff --git a/wwwroot/api/product_category_create.dspy b/wwwroot/api/product_category_create.dspy index 0fe2697..b83071d 100644 --- a/wwwroot/api/product_category_create.dspy +++ b/wwwroot/api/product_category_create.dspy @@ -12,7 +12,7 @@ try: data['created_at'] = timestampstr() data['updated_at'] = timestampstr() if 'parent_id' not in data or not data['parent_id']: - data['parent_id'] = '0' + data['parent_id'] = None if 'has_product' not in data: data['has_product'] = '0' if 'status' not in data: @@ -21,7 +21,7 @@ try: data['sort_order'] = '0' # Validate parent belongs to same org - if data['parent_id'] != '0': + if data['parent_id'] is not None: check_sql = "SELECT id FROM product_category WHERE id = ${parent_id}$ AND org_id = ${org_id}$" async with DBPools().sqlorContext(dbname) as sor: rows = await sor.sqlExe(check_sql, {'parent_id': data['parent_id'], 'org_id': org_id}) diff --git a/wwwroot/api/product_category_update.dspy b/wwwroot/api/product_category_update.dspy index 19d84ea..1402547 100644 --- a/wwwroot/api/product_category_update.dspy +++ b/wwwroot/api/product_category_update.dspy @@ -21,6 +21,11 @@ try: data['updated_at'] = timestampstr() data['id'] = record_id + + # Convert empty parent_id to NULL for tree root nodes + if 'parent_id' in data and not data['parent_id']: + data['parent_id'] = None + if data.get('has_product') == '0': data['product_type'] = '' data['product_type_title'] = ''