fix: 多语言翻译前缀匹配查询
This commit is contained in:
@@ -35,12 +35,17 @@ type SysConfigController struct {
|
|||||||
//
|
//
|
||||||
// GET /list
|
// GET /list
|
||||||
func (s *SysConfigController) List(c *gin.Context) {
|
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)
|
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) {
|
converI18n := func(language string, arr *[]model.SysConfig) {
|
||||||
for i := range *arr {
|
for i := range *arr {
|
||||||
(*arr)[i].ConfigName = i18n.TKey(language, (*arr)[i].ConfigName)
|
(*arr)[i].ConfigName = i18n.TKey(language, (*arr)[i].ConfigName)
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ func (s *SysDeptController) List(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 多语言值转key查询
|
||||||
|
if querys.DeptName != "" {
|
||||||
|
querys.DeptName = i18n.TFindKeyPrefix(language, "dept", querys.DeptName)
|
||||||
|
}
|
||||||
|
|
||||||
SysDeptController := model.SysDept{
|
SysDeptController := model.SysDept{
|
||||||
DeptID: querys.DeptID,
|
DeptID: querys.DeptID,
|
||||||
ParentID: querys.ParentID,
|
ParentID: querys.ParentID,
|
||||||
|
|||||||
@@ -35,12 +35,17 @@ type SysPostController struct {
|
|||||||
//
|
//
|
||||||
// GET /list
|
// GET /list
|
||||||
func (s *SysPostController) List(c *gin.Context) {
|
func (s *SysPostController) List(c *gin.Context) {
|
||||||
querys := ctx.QueryMap(c)
|
|
||||||
data := s.sysPostService.SelectPostPage(querys)
|
|
||||||
|
|
||||||
rows := data["rows"].([]model.SysPost)
|
|
||||||
// 闭包函数处理多语言
|
|
||||||
language := ctx.AcceptLanguage(c)
|
language := ctx.AcceptLanguage(c)
|
||||||
|
querys := ctx.QueryMap(c)
|
||||||
|
// 多语言值转key查询
|
||||||
|
if v, ok := querys["postName"]; ok && v != "" {
|
||||||
|
querys["postName"] = i18n.TFindKeyPrefix(language, "post", v.(string))
|
||||||
|
}
|
||||||
|
|
||||||
|
data := s.sysPostService.SelectPostPage(querys)
|
||||||
|
rows := data["rows"].([]model.SysPost)
|
||||||
|
|
||||||
|
// 闭包函数处理多语言
|
||||||
converI18n := func(language string, arr *[]model.SysPost) {
|
converI18n := func(language string, arr *[]model.SysPost) {
|
||||||
for i := range *arr {
|
for i := range *arr {
|
||||||
(*arr)[i].PostName = i18n.TKey(language, (*arr)[i].PostName)
|
(*arr)[i].PostName = i18n.TKey(language, (*arr)[i].PostName)
|
||||||
|
|||||||
@@ -42,13 +42,18 @@ type SysRoleController struct {
|
|||||||
//
|
//
|
||||||
// GET /list
|
// GET /list
|
||||||
func (s *SysRoleController) List(c *gin.Context) {
|
func (s *SysRoleController) List(c *gin.Context) {
|
||||||
|
language := ctx.AcceptLanguage(c)
|
||||||
querys := ctx.QueryMap(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", "")
|
dataScopeSQL := ctx.LoginUserToDataScopeSQL(c, "d", "")
|
||||||
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
|
data := s.sysRoleService.SelectRolePage(querys, dataScopeSQL)
|
||||||
|
|
||||||
rows := data["rows"].([]model.SysRole)
|
rows := data["rows"].([]model.SysRole)
|
||||||
|
|
||||||
// 闭包函数处理多语言
|
// 闭包函数处理多语言
|
||||||
language := ctx.AcceptLanguage(c)
|
|
||||||
converI18n := func(language string, arr *[]model.SysRole) {
|
converI18n := func(language string, arr *[]model.SysRole) {
|
||||||
for i := range *arr {
|
for i := range *arr {
|
||||||
(*arr)[i].RoleName = i18n.TKey(language, (*arr)[i].RoleName)
|
(*arr)[i].RoleName = i18n.TKey(language, (*arr)[i].RoleName)
|
||||||
|
|||||||
Reference in New Issue
Block a user