启动计划时清零计数器

This commit is contained in:
2025-09-23 22:18:59 +08:00
parent 9594d08e40
commit 1764ff5598
2 changed files with 38 additions and 5 deletions

View File

@@ -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
}