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()
This commit is contained in:
Hermes Agent 2026-06-17 17:49:47 +08:00
parent 1bb7c948d6
commit 6bf45a2dfc
3 changed files with 7 additions and 24 deletions

View File

@ -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'}} result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try: try:
user_id = await get_user() user_id = await get_user()
org_id = (await get_userorgid()) or '0' org_id = (await get_userorgid()) or '0'
now = time.strftime('%Y-%m-%d %H:%M:%S')
dbname = get_module_dbname('product_management') dbname = get_module_dbname('product_management')
data = dict(params_kw) data = dict(params_kw)
data['id'] = getID() data['id'] = getID()
data['org_id'] = org_id data['org_id'] = org_id
data['created_by'] = user_id data['created_by'] = user_id
data['created_at'] = now data['created_at'] = timestampstr()
data['updated_at'] = now data['updated_at'] = timestampstr()
if 'parent_id' not in data or not data['parent_id']: if 'parent_id' not in data or not data['parent_id']:
data['parent_id'] = '0' data['parent_id'] = '0'
if 'has_product' not in data: if 'has_product' not in data:
@ -37,10 +32,8 @@ try:
data['product_type'] = '' data['product_type'] = ''
data['product_type_title'] = '' 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: 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'}} result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '类别创建成功', 'type': 'success'}}

View File

@ -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'}} result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try: try:
user_id = await get_user() user_id = await get_user()
org_id = (await get_userorgid()) or '0' org_id = (await get_userorgid()) or '0'
now = time.strftime('%Y-%m-%d %H:%M:%S')
dbname = get_module_dbname('product_management') dbname = get_module_dbname('product_management')
data = dict(params_kw) data = dict(params_kw)
data['id'] = getID() data['id'] = getID()
data['org_id'] = org_id data['org_id'] = org_id
data['created_by'] = user_id data['created_by'] = user_id
data['created_at'] = now data['created_at'] = timestampstr()
data['updated_at'] = now data['updated_at'] = timestampstr()
if 'status' not in data: if 'status' not in data:
data['status'] = '1' data['status'] = '1'
if 'sort_order' not in data: if 'sort_order' not in data:

View File

@ -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'}} result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try: try:
user_id = await get_user() user_id = await get_user()
org_id = (await get_userorgid()) or '0' org_id = (await get_userorgid()) or '0'
now = time.strftime('%Y-%m-%d %H:%M:%S')
dbname = get_module_dbname('product_management') dbname = get_module_dbname('product_management')
data = dict(params_kw) data = dict(params_kw)
@ -15,8 +10,8 @@ try:
data['operator_id'] = user_id data['operator_id'] = user_id
data['org_id'] = org_id data['org_id'] = org_id
data['created_by'] = user_id data['created_by'] = user_id
data['created_at'] = now data['created_at'] = timestampstr()
data['updated_at'] = now data['updated_at'] = timestampstr()
if 'enabled_flg' not in data: if 'enabled_flg' not in data:
data['enabled_flg'] = '1' data['enabled_flg'] = '1'