From f439d6b708f2634a4d4924ba97e367136485dea9 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 9 Jan 2024 16:37:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E5=BA=A6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81=E5=AF=BC=E8=87=B4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=80=BC=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/monitor/controller/sys_job.go | 4 +-- src/modules/monitor/service/sys_job.go | 3 --- src/modules/monitor/service/sys_job.impl.go | 27 ++------------------- 3 files changed, 4 insertions(+), 30 deletions(-) diff --git a/src/modules/monitor/controller/sys_job.go b/src/modules/monitor/controller/sys_job.go index 7927c482..f09d9a3f 100644 --- a/src/modules/monitor/controller/sys_job.go +++ b/src/modules/monitor/controller/sys_job.go @@ -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 } diff --git a/src/modules/monitor/service/sys_job.go b/src/modules/monitor/service/sys_job.go index 9e9a5ca8..6bb1d9e7 100644 --- a/src/modules/monitor/service/sys_job.go +++ b/src/modules/monitor/service/sys_job.go @@ -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 diff --git a/src/modules/monitor/service/sys_job.impl.go b/src/modules/monitor/service/sys_job.impl.go index 0fcd7497..dc547265 100644 --- a/src/modules/monitor/service/sys_job.impl.go +++ b/src/modules/monitor/service/sys_job.impl.go @@ -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 重置初始调度任务