1
0

feat: 合并代码

This commit is contained in:
TsMask
2024-01-12 15:54:24 +08:00
parent 3cec6077d3
commit 94392e13fd
52 changed files with 1962 additions and 191 deletions

View File

@@ -165,6 +165,14 @@ func (s *SysJobController) Edit(c *gin.Context) {
}
}
// 检查是否存在
job := s.sysJobService.SelectJobById(body.JobID)
if job.JobID != body.JobID {
// 没有可访问调度任务数据!
c.JSON(200, result.ErrMsg(i18n.TKey(language, "job.noData")))
return
}
// 检查属性值唯一
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, body.JobID)
if !uniqueJob {
@@ -174,6 +182,19 @@ func (s *SysJobController) Edit(c *gin.Context) {
return
}
// 多语言非原始值
i18nValue := i18n.TKey(language, job.JobName)
if i18nValue != job.JobName {
i18n.UpdateKeyValue(language, job.JobName, body.JobName)
body.JobName = job.JobName
}
// 多语言非原始值
i18nValue2 := i18n.TKey(language, job.Remark)
if i18nValue2 != job.Remark {
i18n.UpdateKeyValue(language, job.Remark, body.Remark)
body.Remark = job.Remark
}
body.UpdateBy = ctx.LoginUserToUserName(c)
rows := s.sysJobService.UpdateJob(body)
if rows > 0 {
@@ -244,8 +265,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
}

View File

@@ -41,6 +41,12 @@ type SysJobLogController struct {
func (s *SysJobLogController) List(c *gin.Context) {
// 查询参数转换map
querys := ctx.QueryMap(c)
// 任务ID优先级更高
if v, ok := querys["jobId"]; ok && v != nil {
jobInfo := service.NewSysJobImpl.SelectJobById(v.(string))
querys["jobName"] = jobInfo.JobName
querys["jobGroup"] = jobInfo.JobGroup
}
data := s.sysJobLogService.SelectJobLogPage(querys)
rows := data["rows"].([]model.SysJobLog)

View File

@@ -59,7 +59,7 @@ func (r *SysJobLogImpl) SelectJobLogPage(query map[string]any) map[string]any {
var conditions []string
var params []any
if v, ok := query["jobName"]; ok && v != "" {
conditions = append(conditions, "job_name like concat(?, '%')")
conditions = append(conditions, "job_name = ?")
params = append(params, v)
}
if v, ok := query["jobGroup"]; ok && v != "" {

View File

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

View File

@@ -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 重置初始调度任务