fix: 调度任务更新状态导致数据值丢失
This commit is contained in:
@@ -244,8 +244,8 @@ func (s *SysJobController) Status(c *gin.Context) {
|
||||
// 更新状态
|
||||
job.Status = body.Status
|
||||
job.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
ok := s.sysJobService.ChangeStatus(job)
|
||||
if ok {
|
||||
rows := s.sysJobService.UpdateJob(job)
|
||||
if rows > 0 {
|
||||
c.JSON(200, result.Ok(nil))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -27,9 +27,6 @@ type ISysJob interface {
|
||||
// DeleteJobByIds 批量删除调度任务信息
|
||||
DeleteJobByIds(jobIds []string) (int64, error)
|
||||
|
||||
// ChangeStatus 任务调度状态修改
|
||||
ChangeStatus(sysJob model.SysJob) bool
|
||||
|
||||
// RunQueueJob 立即运行一次调度任务
|
||||
RunQueueJob(sysJob model.SysJob) bool
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
|
||||
jobs := r.sysJobRepository.SelectJobByIds(jobIds)
|
||||
if len(jobs) <= 0 {
|
||||
// 没有可访问调度任务数据!
|
||||
return 0, fmt.Errorf("There is no accessible scheduling task data!")
|
||||
return 0, fmt.Errorf("there is no accessible scheduling task data")
|
||||
}
|
||||
if len(jobs) == len(jobIds) {
|
||||
// 清除任务
|
||||
@@ -97,30 +97,7 @@ func (r *SysJobImpl) DeleteJobByIds(jobIds []string) (int64, error) {
|
||||
return rows, nil
|
||||
}
|
||||
// 删除调度任务信息失败!
|
||||
return 0, fmt.Errorf("Failed to delete scheduling task information!")
|
||||
}
|
||||
|
||||
// ChangeStatus 任务调度状态修改
|
||||
func (r *SysJobImpl) ChangeStatus(sysJob model.SysJob) bool {
|
||||
// 更新状态
|
||||
newSysJob := model.SysJob{
|
||||
JobID: sysJob.JobID,
|
||||
Status: sysJob.Status,
|
||||
UpdateBy: sysJob.UpdateBy,
|
||||
}
|
||||
rows := r.sysJobRepository.UpdateJob(newSysJob)
|
||||
if rows > 0 {
|
||||
//状态正常添加队列任务
|
||||
if sysJob.Status == common.STATUS_YES {
|
||||
r.insertQueueJob(sysJob, true)
|
||||
}
|
||||
// 状态禁用删除队列任务
|
||||
if sysJob.Status == common.STATUS_NO {
|
||||
r.deleteQueueJob(sysJob)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
return 0, fmt.Errorf("failed to delete scheduling task information")
|
||||
}
|
||||
|
||||
// ResetQueueJob 重置初始调度任务
|
||||
|
||||
Reference in New Issue
Block a user