marge: 合并代码
This commit is contained in:
@@ -50,7 +50,7 @@ func (s *SysJobController) List(c *gin.Context) {
|
||||
func (s *SysJobController) Info(c *gin.Context) {
|
||||
jobId := c.Param("jobId")
|
||||
if jobId == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -69,20 +69,22 @@ func (s *SysJobController) Add(c *gin.Context) {
|
||||
var body model.SysJob
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.JobID != "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查cron表达式格式
|
||||
if parse.CronExpression(body.CronExpression) == 0 {
|
||||
msg := fmt.Sprintf("调度任务新增【%s】失败,Cron表达式不正确", body.JobName)
|
||||
// 调度任务新增【%s】失败,Cron表达式不正确
|
||||
msg := fmt.Sprintf("Scheduling task add [%s] fails with incorrect Cron expression", body.JobName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查任务调用传入参数是否json格式
|
||||
if body.TargetParams != "" {
|
||||
msg := fmt.Sprintf("调度任务新增【%s】失败,任务传入参数json字符串不正确", body.JobName)
|
||||
// 调度任务新增【%s】失败,任务传入参数json字符串不正确
|
||||
msg := fmt.Sprintf("Scheduling task add [%s] failed, task incoming parameter json string is incorrect", body.JobName)
|
||||
if len(body.TargetParams) < 7 {
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
@@ -96,7 +98,8 @@ func (s *SysJobController) Add(c *gin.Context) {
|
||||
// 检查属性值唯一
|
||||
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, "")
|
||||
if !uniqueJob {
|
||||
msg := fmt.Sprintf("调度任务新增【%s】失败,同任务组内有相同任务名称", body.JobName)
|
||||
// 调度任务新增【%s】失败,同任务组内有相同任务名称
|
||||
msg := fmt.Sprintf("Scheduling tasks with new [%s] failures, with the same task name in the same task group", body.JobName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -117,20 +120,22 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
||||
var body model.SysJob
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil || body.JobID == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查cron表达式格式
|
||||
if parse.CronExpression(body.CronExpression) == 0 {
|
||||
msg := fmt.Sprintf("调度任务修改【%s】失败,Cron表达式不正确", body.JobName)
|
||||
// 调度任务修改【%s】失败,Cron表达式不正确
|
||||
msg := fmt.Sprintf("Scheduling task modification [%s] fails with incorrect Cron expression", body.JobName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查任务调用传入参数是否json格式
|
||||
if body.TargetParams != "" {
|
||||
msg := fmt.Sprintf("调度任务修改【%s】失败,任务传入参数json字符串不正确", body.JobName)
|
||||
// 调度任务修改【%s】失败,任务传入参数json字符串不正确
|
||||
msg := fmt.Sprintf("Scheduling task modification [%s] failed, task incoming parameter json string is not correct", body.JobName)
|
||||
if len(body.TargetParams) < 7 {
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
@@ -144,7 +149,8 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
||||
// 检查属性值唯一
|
||||
uniqueJob := s.sysJobService.CheckUniqueJobName(body.JobName, body.JobGroup, body.JobID)
|
||||
if !uniqueJob {
|
||||
msg := fmt.Sprintf("调度任务修改【%s】失败,同任务组内有相同任务名称", body.JobName)
|
||||
// 调度任务修改【%s】失败,同任务组内有相同任务名称
|
||||
msg := fmt.Sprintf("Scheduling task modification [%s] failed with the same task name in the same task group", body.JobName)
|
||||
c.JSON(200, result.ErrMsg(msg))
|
||||
return
|
||||
}
|
||||
@@ -164,7 +170,7 @@ func (s *SysJobController) Edit(c *gin.Context) {
|
||||
func (s *SysJobController) Remove(c *gin.Context) {
|
||||
jobIds := c.Param("jobIds")
|
||||
if jobIds == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
// 处理字符转id数组后去重
|
||||
@@ -179,7 +185,7 @@ func (s *SysJobController) Remove(c *gin.Context) {
|
||||
c.JSON(200, result.ErrMsg(err.Error()))
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("删除成功:%d", rows)
|
||||
msg := fmt.Sprintf("Deleted successfully: %d", rows)
|
||||
c.JSON(200, result.OkMsg(msg))
|
||||
}
|
||||
|
||||
@@ -195,20 +201,22 @@ func (s *SysJobController) Status(c *gin.Context) {
|
||||
}
|
||||
err := c.ShouldBindBodyWith(&body, binding.JSON)
|
||||
if err != nil {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
job := s.sysJobService.SelectJobById(body.JobId)
|
||||
if job.JobID != body.JobId {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
|
||||
// 没有可访问调度任务数据!
|
||||
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if job.Status == body.Status {
|
||||
c.JSON(200, result.ErrMsg("变更状态与旧值相等!"))
|
||||
// 变更状态与旧值相等!
|
||||
c.JSON(200, result.ErrMsg("Change status equals old value!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -229,14 +237,15 @@ func (s *SysJobController) Status(c *gin.Context) {
|
||||
func (s *SysJobController) Run(c *gin.Context) {
|
||||
jobId := c.Param("jobId")
|
||||
if jobId == "" {
|
||||
c.JSON(400, result.CodeMsg(400, "参数错误"))
|
||||
c.JSON(400, result.CodeMsg(400, "parameter error"))
|
||||
return
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
job := s.sysJobService.SelectJobById(jobId)
|
||||
if job.JobID != jobId {
|
||||
c.JSON(200, result.ErrMsg("没有权限访问调度任务数据!"))
|
||||
// 没有可访问调度任务数据!
|
||||
c.JSON(200, result.ErrMsg("No accessible scheduling task data!"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -264,7 +273,8 @@ func (s *SysJobController) Export(c *gin.Context) {
|
||||
querys := ctx.BodyJSONMap(c)
|
||||
data := s.sysJobService.SelectJobPage(querys)
|
||||
if data["total"].(int64) == 0 {
|
||||
c.JSON(200, result.ErrMsg("导出数据记录为空"))
|
||||
// 导出数据记录为空
|
||||
c.JSON(200, result.ErrMsg("Export data record is empty"))
|
||||
return
|
||||
}
|
||||
rows := data["rows"].([]model.SysJob)
|
||||
@@ -273,16 +283,16 @@ func (s *SysJobController) Export(c *gin.Context) {
|
||||
fileName := fmt.Sprintf("job_export_%d_%d.xlsx", len(rows), time.Now().UnixMilli())
|
||||
// 第一行表头标题
|
||||
headerCells := map[string]string{
|
||||
"A1": "任务编号",
|
||||
"B1": "任务名称",
|
||||
"C1": "任务组名",
|
||||
"D1": "调用目标",
|
||||
"E1": "传入参数",
|
||||
"F1": "执行表达式",
|
||||
"G1": "出错策略",
|
||||
"H1": "并发执行",
|
||||
"I1": "任务状态",
|
||||
"J1": "备注说明",
|
||||
"A1": "JobID",
|
||||
"B1": "JobName",
|
||||
"C1": "JobGroupName",
|
||||
"D1": "InvokeTarget",
|
||||
"E1": "TargetParams",
|
||||
"F1": "CronExpression",
|
||||
"G1": "MisfirePolicy",
|
||||
"H1": "Concurrent",
|
||||
"I1": "Status",
|
||||
"J1": "Remark",
|
||||
}
|
||||
// 读取任务组名字典数据
|
||||
dictSysJobGroup := s.sysDictDataService.SelectDictDataByType("sys_job_group")
|
||||
@@ -298,20 +308,20 @@ func (s *SysJobController) Export(c *gin.Context) {
|
||||
break
|
||||
}
|
||||
}
|
||||
misfirePolicy := "放弃执行"
|
||||
misfirePolicy := "Abandon execution"
|
||||
if row.MisfirePolicy == "1" {
|
||||
misfirePolicy = "立即执行"
|
||||
misfirePolicy = "Execute immediately"
|
||||
} else if row.MisfirePolicy == "2" {
|
||||
misfirePolicy = "执行一次"
|
||||
misfirePolicy = "Execute once"
|
||||
}
|
||||
concurrent := "禁止"
|
||||
concurrent := "prohibit"
|
||||
if row.Concurrent == "1" {
|
||||
concurrent = "允许"
|
||||
concurrent = "allow"
|
||||
}
|
||||
// 状态
|
||||
statusValue := "失败"
|
||||
statusValue := "fail"
|
||||
if row.Status == "1" {
|
||||
statusValue = "成功"
|
||||
statusValue = "successes"
|
||||
}
|
||||
dataCells = append(dataCells, map[string]any{
|
||||
"A" + idx: row.JobID,
|
||||
|
||||
Reference in New Issue
Block a user