haha
This commit is contained in:
@@ -295,6 +295,23 @@ def task_list(request):
|
|||||||
return api_success(_task_to_dict(task), http_status=http_status.HTTP_201_CREATED)
|
return api_success(_task_to_dict(task), http_status=http_status.HTTP_201_CREATED)
|
||||||
|
|
||||||
|
|
||||||
|
@api_view(["GET"])
|
||||||
|
def task_detail(request, task_id: str):
|
||||||
|
"""
|
||||||
|
按 task_id 查询单个任务详情。
|
||||||
|
优先查 Task 表(活跃任务),再查 TaskLog 表(历史记录)。
|
||||||
|
"""
|
||||||
|
task = Task.objects.filter(task_id=task_id).first()
|
||||||
|
if task:
|
||||||
|
return api_success(_task_to_dict(task))
|
||||||
|
|
||||||
|
task_log = TaskLog.objects.filter(task_id=task_id).first()
|
||||||
|
if task_log:
|
||||||
|
return api_success(_task_log_to_dict(task_log))
|
||||||
|
|
||||||
|
return api_error(http_status.HTTP_404_NOT_FOUND, f"任务 {task_id} 不存在")
|
||||||
|
|
||||||
|
|
||||||
@api_view(["POST"])
|
@api_view(["POST"])
|
||||||
def task_cancel(request, task_id: str):
|
def task_cancel(request, task_id: str):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ urlpatterns = [
|
|||||||
|
|
||||||
# ─── 任务 ───
|
# ─── 任务 ───
|
||||||
path("api/tasks", tasks.task_list),
|
path("api/tasks", tasks.task_list),
|
||||||
|
path("api/tasks/detail/<str:task_id>", tasks.task_detail),
|
||||||
path("api/tasks/<str:task_id>/cancel", tasks.task_cancel),
|
path("api/tasks/<str:task_id>/cancel", tasks.task_cancel),
|
||||||
path("api/tasks/<int:account_id>", tasks.task_list_by_account),
|
path("api/tasks/<int:account_id>", tasks.task_list_by_account),
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user