product_management/wwwroot/api/product_resource_supplier_create.dspy

28 lines
1008 B
Plaintext

result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
try:
dbname = get_module_dbname('product_management')
data = dict(params_kw)
data['id'] = getID()
data['created_at'] = timestampstr()
if 'status' not in data:
data['status'] = '1'
if 'priority' not in data:
data['priority'] = '1'
if 'weight' not in data:
data['weight'] = '100'
if not data.get('product_resource_id'):
raise ValueError('资源绑定ID不能为空')
if not data.get('supplier_org_id'):
raise ValueError('供应商ID不能为空')
async with DBPools().sqlorContext(dbname) as sor:
await sor.C('product_resource_supplier', data)
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '供应商关联创建成功', 'type': 'success'}}
except Exception as e:
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
return result