fix: 多语言翻译值转化key进行查询

This commit is contained in:
TsMask
2024-03-25 12:01:11 +08:00
parent f22c4b876d
commit decab2d82f
7 changed files with 56 additions and 20 deletions

View File

@@ -35,12 +35,17 @@ type SysLogOperateController struct {
//
// GET /list
func (s *SysLogOperateController) List(c *gin.Context) {
querys := ctx.QueryMap(c)
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
rows := data["rows"].([]model.SysLogOperate)
// 闭包函数处理多语言
language := ctx.AcceptLanguage(c)
querys := ctx.QueryMap(c)
// 多语言值转key查询
if v, ok := querys["title"]; ok && v != "" {
querys["title"] = i18n.TFindKeyPrefix(language, "log.operate.title", v.(string))
}
data := s.SysLogOperateService.SelectSysLogOperatePage(querys)
rows := data["rows"].([]model.SysLogOperate)
// 闭包函数处理多语言
converI18n := func(language string, arr *[]model.SysLogOperate) {
for i := range *arr {
(*arr)[i].Title = i18n.TKey(language, (*arr)[i].Title)