fix: 多语言翻译前缀匹配查询

This commit is contained in:
TsMask
2024-04-08 15:08:38 +08:00
parent 996b764d13
commit 8b3ab9d4e8
4 changed files with 32 additions and 12 deletions

View File

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