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

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

No files matched your search

+7 -2
View File
@@ -42,13 +42,18 @@ type SysRoleController struct {
//
// GET /list
func (s *SysRoleController) List(c *gin.Context) {
language := ctx.AcceptLanguage(c)
querys := ctx.QueryMap(c)
// 多语言值转key查询
if v, ok := querys["roleName"]; ok && v != "" {
querys["roleName"] = i18n.TFindKeyPrefix(language, "role", v.(string))
}
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
rows := data["rows"].([]model.SysRole)
// 闭包函数处理多语言
language := ctx.AcceptLanguage(c)
converI18n := func(language string, arr *[]model.SysRole) {
for i := range *arr {
(*arr)[i].RoleName = i18n.TKey(language, (*arr)[i].RoleName)