fix: 调度任务名称搜索多语言反查

This commit is contained in:
TsMask
2024-04-15 14:49:17 +08:00
parent efa8397b41
commit 8b01661392
2 changed files with 17 additions and 7 deletions

View File

@@ -40,12 +40,17 @@ type SysJobController struct {
//
// GET /list
func (s *SysJobController) List(c *gin.Context) {
querys := ctx.QueryMap(c)
data := s.sysJobService.SelectJobPage(querys)
rows := data["rows"].([]model.SysJob)
// 闭包函数处理多语言
language := ctx.AcceptLanguage(c)
querys := ctx.QueryMap(c)
// 多语言值转key查询
if v, ok := querys["jobName"]; ok && v != "" {
querys["jobName"] = i18n.TFindKeyPrefix(language, "job", v.(string))
}
data := s.sysJobService.SelectJobPage(querys)
rows := data["rows"].([]model.SysJob)
// 闭包函数处理多语言
converI18n := func(language string, arr *[]model.SysJob) {
for i := range *arr {
(*arr)[i].JobName = i18n.TKey(language, (*arr)[i].JobName)

View File

@@ -39,6 +39,7 @@ type SysJobLogController struct {
//
// GET /list
func (s *SysJobLogController) List(c *gin.Context) {
language := ctx.AcceptLanguage(c)
// 查询参数转换map
querys := ctx.QueryMap(c)
// 任务ID优先级更高
@@ -47,11 +48,15 @@ func (s *SysJobLogController) List(c *gin.Context) {
querys["jobName"] = jobInfo.JobName
querys["jobGroup"] = jobInfo.JobGroup
}
data := s.sysJobLogService.SelectJobLogPage(querys)
// 多语言值转key查询
if v, ok := querys["jobName"]; ok && v != "" {
querys["jobName"] = i18n.TFindKeyPrefix(language, "job", v.(string))
}
data := s.sysJobLogService.SelectJobLogPage(querys)
rows := data["rows"].([]model.SysJobLog)
// 闭包函数处理多语言
language := ctx.AcceptLanguage(c)
converI18n := func(language string, arr *[]model.SysJobLog) {
for i := range *arr {
(*arr)[i].JobName = i18n.TKey(language, (*arr)[i].JobName)