实现启动计划
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user