启动计划时清零计数器
This commit is contained in:
@@ -36,6 +36,8 @@ type PlanRepository interface {
|
||||
UpdatePlan(plan *models.Plan) error
|
||||
// UpdatePlanStatus 更新指定计划的状态
|
||||
UpdatePlanStatus(id uint, status models.PlanStatus) error
|
||||
// UpdateExecuteCount 更新指定计划的执行计数
|
||||
UpdateExecuteCount(id uint, count uint) error
|
||||
// DeletePlan 根据ID删除计划,同时删除其关联的任务(非子任务)或子计划关联
|
||||
DeletePlan(id uint) error
|
||||
// FlattenPlanTasks 递归展开计划,返回按执行顺序排列的所有任务列表
|
||||
@@ -745,3 +747,15 @@ func (r *gormPlanRepository) UpdatePlanStateAfterExecution(planID uint, newCount
|
||||
"status": newStatus,
|
||||
}).Error
|
||||
}
|
||||
|
||||
// UpdateExecuteCount 更新指定计划的执行计数
|
||||
func (r *gormPlanRepository) UpdateExecuteCount(id uint, count uint) error {
|
||||
result := r.db.Model(&models.Plan{}).Where("id = ?", id).Update("execute_count", count)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
if result.RowsAffected == 0 {
|
||||
return gorm.ErrRecordNotFound
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user