fix: 导入接受id参数(fallback),错误消息显示category_id
This commit is contained in:
parent
876e4581b7
commit
9ea13564ef
@ -1,17 +1,10 @@
|
||||
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid', 'type': 'error'}}
|
||||
|
||||
try:
|
||||
category_id = params_kw.get('category_id', '')
|
||||
# Debug: log incoming params to help diagnose tree selection issue
|
||||
from appPublic.log import debug
|
||||
body_preview = 'none'
|
||||
raw_body = getattr(request, 'body', b'')
|
||||
if raw_body:
|
||||
body_preview = str(raw_body[:200])
|
||||
debug('[import_category] params_kw=%s, category_id=%s, body=%s' % (dict(params_kw), category_id, body_preview))
|
||||
|
||||
# Accept both 'category_id' and 'id' as param name (tree may send either)
|
||||
category_id = params_kw.get('category_id', '') or params_kw.get('id', '')
|
||||
if not category_id:
|
||||
raise ValueError('请先选择一个产品类别')
|
||||
raise ValueError('请先选择一个产品类别 (未收到类别ID)')
|
||||
|
||||
org_id = (await get_userorgid()) or '0'
|
||||
user_id = await get_user()
|
||||
@ -24,7 +17,7 @@ try:
|
||||
{'id': category_id}
|
||||
)
|
||||
if not rows:
|
||||
raise ValueError('类别不存在或无权操作')
|
||||
raise ValueError('类别不存在: id=%s' % category_id)
|
||||
cat = rows[0]
|
||||
|
||||
resource_module = cat.resource_module
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user