llmage/wwwroot/api/llmusage_update.dspy

20 lines
742 B
Python

#!/usr/bin/env python3
result = {"widgettype":"Error","options":{"title":"操作失败","message":"Invalid request","cwidth":16,"cheight":9,"timeout":3}}
try:
dbname = get_module_dbname('llmage')
async with DBPools().sqlorContext(dbname) as sor:
data = params_kw
rid = data.pop('id', None)
if not rid:
result['message'] = '缺少id参数'
else:
data['id'] = rid
await sor.U('llmusage', data)
result = {"widgettype":"Message","options":{"title":"更新成功","message":"ok","cwidth":16,"cheight":9,"timeout":3}}
except Exception as e:
result["options"] = {"title":"操作失败","message":str(e),"cwidth":16,"cheight":9,"timeout":3}
return result