fix: 修复任务完工/结束 500 + 后端基因继承
- 移除 task.child_tasks 的 ORM 属性直接赋值(导致 SQLAlchemy 状态机崩溃) - complete_task 创建 next_task 时补上 task_type=task.task_type 基因继承
This commit is contained in:
@ -872,12 +872,6 @@ async def complete_task(
|
|||||||
"""
|
"""
|
||||||
task = await _get_task_or_404(db, task_id)
|
task = await _get_task_or_404(db, task_id)
|
||||||
|
|
||||||
# 注入子任务数据到当前对象以便后续检查
|
|
||||||
children_result = await db.execute(
|
|
||||||
select(Task).where(Task.parent_task_id == task_id)
|
|
||||||
)
|
|
||||||
task.child_tasks = children_result.scalars().all()
|
|
||||||
|
|
||||||
# --- 1. 幂等检查 ---
|
# --- 1. 幂等检查 ---
|
||||||
if task.status == TASK_STATUS_COMPLETED:
|
if task.status == TASK_STATUS_COMPLETED:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
@ -914,6 +908,7 @@ async def complete_task(
|
|||||||
task_name=request.next_task_name,
|
task_name=request.next_task_name,
|
||||||
assignee_id=request.next_assignee_id,
|
assignee_id=request.next_assignee_id,
|
||||||
status=TASK_STATUS_PENDING,
|
status=TASK_STATUS_PENDING,
|
||||||
|
task_type=task.task_type, # 🚀 继承父任务基因:主线→主线,协助→协助
|
||||||
notify_parent_on_complete=False,
|
notify_parent_on_complete=False,
|
||||||
)
|
)
|
||||||
db.add(next_task)
|
db.add(next_task)
|
||||||
|
|||||||
Reference in New Issue
Block a user