diff --git a/json/llm.json b/json/llm.json index 732b444..d4f3ac0 100644 --- a/json/llm.json +++ b/json/llm.json @@ -97,7 +97,7 @@ "url":"{{entire_url('../api/llm_status_update.dspy')}}", "params":{ "id":"${id}", - "status":"published" + "action":"published" } } }, @@ -115,7 +115,7 @@ "url":"{{entire_url('../api/llm_status_update.dspy')}}", "params":{ "id":"${id}", - "status":"unpublished" + "action":"unpublished" } } } diff --git a/wwwroot/api/llm_status_update.dspy b/wwwroot/api/llm_status_update.dspy index 12e2e50..c3d342c 100644 --- a/wwwroot/api/llm_status_update.dspy +++ b/wwwroot/api/llm_status_update.dspy @@ -1,23 +1,25 @@ -#!/usr/bin/env python3 -import json - result = {'success': False, 'message': ''} - +action = params_kw.action try: dbname = get_module_dbname('llmage') record_id = params_kw.get('id') - status = params_kw.get('status') - + action = params_kw.get('status') if not record_id: result['message'] = '缺少id' - elif status not in ('published', 'unpublished'): + elif action not in ('published', 'unpublished'): result['message'] = '无效的状态值' else: async with DBPools().sqlorContext(dbname) as sor: - await sor.U('llm', {'id': record_id, 'status': status}) + await sor.U('llm', {'id': record_id, 'status': action}) result['success'] = True - result['message'] = '上架成功' if status == 'published' else '下架成功' + result['message'] = '上架成功' if action == 'published' else '下架成功' except Exception as e: result['message'] = str(e) -return json.dumps(result, ensure_ascii=False, default=str) +return { + "widgettype": "Text", + "options": { + "otext": result['message'], + "i18n": true + } +}