fix: CRUD endpoint return format - remove json.dumps
This commit is contained in:
parent
2828426f76
commit
f325ad0c93
@ -20,4 +20,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
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
delete_func = delete_platform_supply_products
|
delete_func = delete_platform_supply_products
|
||||||
if delete_func is None:
|
if delete_func is None:
|
||||||
return json.dumps({"status": "error", "message": "delete_platform_supply_products not registered"})
|
return {"status": "error", "message": "delete_platform_supply_products not registered"}
|
||||||
result = await delete_func(request, params_kw)
|
result = await delete_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
update_func = update_platform_supply_products
|
update_func = update_platform_supply_products
|
||||||
if update_func is None:
|
if update_func is None:
|
||||||
return json.dumps({"status": "error", "message": "update_platform_supply_products not registered"})
|
return {"status": "error", "message": "update_platform_supply_products not registered"}
|
||||||
result = await update_func(request, params_kw)
|
result = await update_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
delete_func = delete_platform_supply_relations
|
delete_func = delete_platform_supply_relations
|
||||||
if delete_func is None:
|
if delete_func is None:
|
||||||
return json.dumps({"status": "error", "message": "delete_platform_supply_relations not registered"})
|
return {"status": "error", "message": "delete_platform_supply_relations not registered"}
|
||||||
result = await delete_func(request, params_kw)
|
result = await delete_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
update_func = update_platform_supply_relations
|
update_func = update_platform_supply_relations
|
||||||
if update_func is None:
|
if update_func is None:
|
||||||
return json.dumps({"status": "error", "message": "update_platform_supply_relations not registered"})
|
return {"status": "error", "message": "update_platform_supply_relations not registered"}
|
||||||
result = await update_func(request, params_kw)
|
result = await update_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
delete_func = delete_product_supplier_mapping
|
delete_func = delete_product_supplier_mapping
|
||||||
if delete_func is None:
|
if delete_func is None:
|
||||||
return json.dumps({"status": "error", "message": "delete_product_supplier_mapping not registered"})
|
return {"status": "error", "message": "delete_product_supplier_mapping not registered"}
|
||||||
result = await delete_func(request, params_kw)
|
result = await delete_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
update_func = update_product_supplier_mapping
|
update_func = update_product_supplier_mapping
|
||||||
if update_func is None:
|
if update_func is None:
|
||||||
return json.dumps({"status": "error", "message": "update_product_supplier_mapping not registered"})
|
return {"status": "error", "message": "update_product_supplier_mapping not registered"}
|
||||||
result = await update_func(request, params_kw)
|
result = await update_func(request, params_kw)
|
||||||
return result
|
return result
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -7,13 +7,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.D('sales_ledger', data)
|
await sor.D('sales_ledger', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}
|
||||||
|
|||||||
@ -7,13 +7,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.U('sales_ledger', data)
|
await sor.U('sales_ledger', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -7,13 +7,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.D('sub_resellers', data)
|
await sor.D('sub_resellers', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}
|
||||||
|
|||||||
@ -7,13 +7,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.U('sub_resellers', data)
|
await sor.U('sub_resellers', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}
|
||||||
|
|||||||
@ -31,4 +31,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
|
||||||
|
|||||||
@ -13,4 +13,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
|
||||||
|
|||||||
@ -15,4 +15,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
|
||||||
|
|||||||
@ -6,13 +6,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.D('suppliers', data)
|
await sor.D('suppliers', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Delete Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Delete Error','message':str(e)}}
|
||||||
|
|||||||
@ -7,13 +7,13 @@ data.pop('rows', None)
|
|||||||
data.pop('data_filter', None)
|
data.pop('data_filter', None)
|
||||||
|
|
||||||
if not data.get('id'):
|
if not data.get('id'):
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':'缺少id'}}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
dbname = get_module_dbname('supplychain')
|
dbname = get_module_dbname('supplychain')
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.U('suppliers', data)
|
await sor.U('suppliers', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Update Success','message':'ok'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Update Error','message':str(e)}}
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -27,6 +27,6 @@ try:
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.C('supply_contracts', data)
|
await sor.C('supply_contracts', data)
|
||||||
return json.dumps({'widgettype':'Message','options':{'title':'Success','message':'供应合同创建成功'}}, ensure_ascii=False)
|
return {'widgettype':'Message','options':{'title':'Success','message':'供应合同创建成功'}}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return json.dumps({'widgettype':'Error','options':{'title':'Error','message':f'创建失败: {e}'}}, ensure_ascii=False)
|
return {'widgettype':'Error','options':{'title':'Error','message':f'创建失败: {e}'}}
|
||||||
|
|||||||
@ -20,4 +20,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
|
||||||
|
|||||||
@ -7,9 +7,9 @@ if isinstance(data, str):
|
|||||||
|
|
||||||
record_id = data.get("id")
|
record_id = data.get("id")
|
||||||
if not record_id:
|
if not record_id:
|
||||||
return json.dumps({"status": "error", "message": "Missing record id"})
|
return {"status": "error", "message": "Missing record id"}
|
||||||
|
|
||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.D("supplychain_accounting", {"id": record_id})
|
await sor.D("supplychain_accounting", {"id": record_id})
|
||||||
return json.dumps({"status": "ok", "message": "Deleted successfully"})
|
return {"status": "ok", "message": "Deleted successfully"}
|
||||||
|
|||||||
@ -8,7 +8,7 @@ if isinstance(data, str):
|
|||||||
|
|
||||||
record_id = data.get("id")
|
record_id = data.get("id")
|
||||||
if not record_id:
|
if not record_id:
|
||||||
return json.dumps({"status": "error", "message": "Missing record id"})
|
return {"status": "error", "message": "Missing record id"}
|
||||||
|
|
||||||
data["updated_at"] = timestampstr()
|
data["updated_at"] = timestampstr()
|
||||||
|
|
||||||
@ -18,4 +18,4 @@ for key in ["id", "resellerid", "created_by", "created_at"]:
|
|||||||
db = DBPools()
|
db = DBPools()
|
||||||
async with db.sqlorContext(dbname) as sor:
|
async with db.sqlorContext(dbname) as sor:
|
||||||
await sor.U("supplychain_accounting", data)
|
await sor.U("supplychain_accounting", data)
|
||||||
return json.dumps({"status": "ok", "data": data})
|
return {"status": "ok", "data": data}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user