25 lines
993 B
Python
25 lines
993 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Task delete API"""
|
|
import json
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
dbname = get_module_dbname('harnessed_agent')
|
|
user_id = await get_user()
|
|
record_id = params_kw.get('id', '').strip()
|
|
if not record_id:
|
|
result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'}
|
|
else:
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
await sor.sqlExe("""DELETE FROM hermes_tasks_workflow WHERE id = ${id}$ AND user_id = ${user_id}$""", {
|
|
'id': record_id, 'user_id': user_id
|
|
})
|
|
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)
|