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)