From 6bf45a2dfcdbb44208058d5c90d4464a7b9f753a Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 17 Jun 2026 17:49:47 +0800 Subject: [PATCH] fix: remove imports and use pre-loaded timestampstr/getID in create dspy files - product_category_create.dspy: removed import json/time/getID, replaced time.strftime with timestampstr(), removed field filter, pass data directly to sor.C() - product_create.dspy: removed imports, replaced time.strftime with timestampstr() - product_type_config_create.dspy: removed imports, replaced time.strftime with timestampstr() --- wwwroot/api/product_category_create.dspy | 13 +++---------- wwwroot/api/product_create.dspy | 9 ++------- wwwroot/api/product_type_config_create.dspy | 9 ++------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/wwwroot/api/product_category_create.dspy b/wwwroot/api/product_category_create.dspy index f952d71..0fe2697 100644 --- a/wwwroot/api/product_category_create.dspy +++ b/wwwroot/api/product_category_create.dspy @@ -1,21 +1,16 @@ -#!/usr/bin/env python3 -import json, time -from appPublic.uniqueID import getID - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} try: user_id = await get_user() org_id = (await get_userorgid()) or '0' - now = time.strftime('%Y-%m-%d %H:%M:%S') dbname = get_module_dbname('product_management') data = dict(params_kw) data['id'] = getID() data['org_id'] = org_id data['created_by'] = user_id - data['created_at'] = now - data['updated_at'] = now + data['created_at'] = timestampstr() + data['updated_at'] = timestampstr() if 'parent_id' not in data or not data['parent_id']: data['parent_id'] = '0' if 'has_product' not in data: @@ -37,10 +32,8 @@ try: data['product_type'] = '' data['product_type_title'] = '' - fields = {k: v for k, v in data.items() if v is not None and v != '' or k in ('product_type', 'product_type_title', 'parent_id')} - async with DBPools().sqlorContext(dbname) as sor: - await sor.C('product_category', fields) + await sor.C('product_category', data) result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '类别创建成功', 'type': 'success'}} diff --git a/wwwroot/api/product_create.dspy b/wwwroot/api/product_create.dspy index dc06ee3..8ea8bb4 100644 --- a/wwwroot/api/product_create.dspy +++ b/wwwroot/api/product_create.dspy @@ -1,21 +1,16 @@ -#!/usr/bin/env python3 -import json, time -from appPublic.uniqueID import getID - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} try: user_id = await get_user() org_id = (await get_userorgid()) or '0' - now = time.strftime('%Y-%m-%d %H:%M:%S') dbname = get_module_dbname('product_management') data = dict(params_kw) data['id'] = getID() data['org_id'] = org_id data['created_by'] = user_id - data['created_at'] = now - data['updated_at'] = now + data['created_at'] = timestampstr() + data['updated_at'] = timestampstr() if 'status' not in data: data['status'] = '1' if 'sort_order' not in data: diff --git a/wwwroot/api/product_type_config_create.dspy b/wwwroot/api/product_type_config_create.dspy index 66f5037..59c91c9 100644 --- a/wwwroot/api/product_type_config_create.dspy +++ b/wwwroot/api/product_type_config_create.dspy @@ -1,13 +1,8 @@ -#!/usr/bin/env python3 -import json, time -from appPublic.uniqueID import getID - result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}} try: user_id = await get_user() org_id = (await get_userorgid()) or '0' - now = time.strftime('%Y-%m-%d %H:%M:%S') dbname = get_module_dbname('product_management') data = dict(params_kw) @@ -15,8 +10,8 @@ try: data['operator_id'] = user_id data['org_id'] = org_id data['created_by'] = user_id - data['created_at'] = now - data['updated_at'] = now + data['created_at'] = timestampstr() + data['updated_at'] = timestampstr() if 'enabled_flg' not in data: data['enabled_flg'] = '1'