- 5个CRUD JSON从自定义格式重写为规范格式(tblname/alias/params) - 13个新CRUD dspy文件(create/update/delete + noop) - product_resource_delete含级联删除product_resource_supplier - product_subscription CRUD含完整校验 - product_usage_log只读(noop dspy) - load_path.py注册所有新增API和CRUD路径
31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
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()
|
|
data['updated_at'] = timestampstr()
|
|
if 'status' not in data:
|
|
data['status'] = '1'
|
|
if 'priority' not in data:
|
|
data['priority'] = '1'
|
|
if 'quota' not in data:
|
|
data['quota'] = '0'
|
|
|
|
if not data.get('product_id'):
|
|
raise ValueError('产品ID不能为空')
|
|
if not data.get('resource_type'):
|
|
raise ValueError('资源类型不能为空')
|
|
if not data.get('resource_ref_id'):
|
|
raise ValueError('资源引用ID不能为空')
|
|
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
await sor.C('product_resource', data)
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '资源绑定创建成功', 'type': 'success'}}
|
|
except Exception as e:
|
|
result['options'] = {'title': 'Error', 'message': '创建失败: ' + str(e), 'type': 'error'}
|
|
|
|
return json.dumps(result, ensure_ascii=False)
|