llmage/wwwroot/api/llmusage_accounting_failed_update.dspy

23 lines
969 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
# Mark as handled - set handled_time
if data.get('handled') == '1' and not data.get('handled_time'):
data['handled_time'] = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
await sor.U('llmusage_accounting_failed', 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