实现启动计划

This commit is contained in:
2025-09-22 14:21:08 +08:00
parent 0a8e6793ef
commit bd2d1c6b63
3 changed files with 59 additions and 5 deletions

View File

@@ -34,6 +34,8 @@ type PlanRepository interface {
CreatePlan(plan *models.Plan) error
// UpdatePlan 更新计划,包括子计划和任务
UpdatePlan(plan *models.Plan) error
// UpdatePlanStatus 更新指定计划的状态
UpdatePlanStatus(id uint, status models.PlanStatus) error
// DeletePlan 根据ID删除计划同时删除其关联的任务非子任务或子计划关联
DeletePlan(id uint) error
// FlattenPlanTasks 递归展开计划,返回按执行顺序排列的所有任务列表
@@ -643,3 +645,15 @@ func (r *gormPlanRepository) FindPlansWithPendingTasks() ([]*models.Plan, error)
return plans, err
}
// UpdatePlanStatus 更新指定计划的状态
func (r *gormPlanRepository) UpdatePlanStatus(id uint, status models.PlanStatus) error {
result := r.db.Model(&models.Plan{}).Where("id = ?", id).Update("status", status)
if result.Error != nil {
return result.Error
}
if result.RowsAffected == 0 {
return gorm.ErrRecordNotFound
}
return nil
}