fix: 多语言字典数据源同步更新
This commit is contained in:
@@ -262,7 +262,7 @@ func (s *SysConfigController) Export(c *gin.Context) {
|
||||
|
||||
// 参数配置修改配置参数
|
||||
//
|
||||
// PUT /changeConfigValue
|
||||
// PUT /changeValue
|
||||
func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
||||
language := ctx.AcceptLanguage(c)
|
||||
var body struct {
|
||||
@@ -282,13 +282,21 @@ func (s *SysConfigController) ConfigValue(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 与旧值相等不变更
|
||||
if info.ConfigValue == body.Value {
|
||||
// 与旧值相等 不变更
|
||||
i18nValue := i18n.TKey(language, info.ConfigValue)
|
||||
if i18nValue == body.Value {
|
||||
// 变更状态与旧值相等!
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "config.errValueEq")))
|
||||
return
|
||||
}
|
||||
info.ConfigValue = body.Value
|
||||
|
||||
// 多语言非原始值
|
||||
if i18nValue != info.ConfigValue {
|
||||
i18n.UpdateKeyValue(language, info.ConfigValue, body.Value)
|
||||
} else {
|
||||
info.ConfigValue = body.Value
|
||||
}
|
||||
|
||||
info.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysConfigService.UpdateConfig(info)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -201,6 +201,13 @@ func (s *SysDeptController) Edit(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, deptInfo.DeptName)
|
||||
if i18nValue != deptInfo.DeptName {
|
||||
i18n.UpdateKeyValue(language, deptInfo.DeptName, body.DeptName)
|
||||
body.DeptName = deptInfo.DeptName
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysDeptService.UpdateDept(body)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -140,8 +140,8 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 检查字典编码是否存在
|
||||
SysDictDataController := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
||||
if SysDictDataController.DictCode != body.DictCode {
|
||||
sysDictData := s.sysDictDataService.SelectDictDataByCode(body.DictCode)
|
||||
if sysDictData.DictCode != body.DictCode {
|
||||
// 没有可访问字典编码数据!
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "dictData.noData")))
|
||||
return
|
||||
@@ -156,6 +156,19 @@ func (s *SysDictDataController) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, sysDictData.DictLabel)
|
||||
if i18nValue != sysDictData.DictLabel {
|
||||
i18n.UpdateKeyValue(language, sysDictData.DictLabel, body.DictLabel)
|
||||
body.DictLabel = sysDictData.DictLabel
|
||||
}
|
||||
// 多语言非原始值
|
||||
i18nValue2 := i18n.TKey(language, sysDictData.Remark)
|
||||
if i18nValue2 != sysDictData.Remark {
|
||||
i18n.UpdateKeyValue(language, sysDictData.Remark, body.Remark)
|
||||
body.Remark = sysDictData.Remark
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysDictDataService.UpdateDictData(body)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -151,6 +151,19 @@ func (s *SysDictTypeController) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, dictInfo.DictName)
|
||||
if i18nValue != dictInfo.DictName {
|
||||
i18n.UpdateKeyValue(language, dictInfo.DictName, body.DictName)
|
||||
body.DictName = dictInfo.DictName
|
||||
}
|
||||
// 多语言非原始值
|
||||
i18nValue2 := i18n.TKey(language, dictInfo.Remark)
|
||||
if i18nValue2 != dictInfo.Remark {
|
||||
i18n.UpdateKeyValue(language, dictInfo.Remark, body.Remark)
|
||||
body.Remark = dictInfo.Remark
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysDictTypeService.UpdateDictType(body)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -216,6 +216,19 @@ func (s *SysMenuController) Edit(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, menuInfo.MenuName)
|
||||
if i18nValue != menuInfo.MenuName {
|
||||
i18n.UpdateKeyValue(language, menuInfo.MenuName, body.MenuName)
|
||||
body.MenuName = menuInfo.MenuName
|
||||
}
|
||||
// 多语言非原始值
|
||||
i18nValue2 := i18n.TKey(language, menuInfo.Remark)
|
||||
if i18nValue2 != menuInfo.Remark {
|
||||
i18n.UpdateKeyValue(language, menuInfo.Remark, body.Remark)
|
||||
body.Remark = menuInfo.Remark
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysMenuService.UpdateMenu(body)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -125,8 +125,8 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
post := s.sysPostService.SelectPostById(body.PostID)
|
||||
if post.PostID != body.PostID {
|
||||
postInfo := s.sysPostService.SelectPostById(body.PostID)
|
||||
if postInfo.PostID != body.PostID {
|
||||
// 没有可访问岗位数据!
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "post.noData")))
|
||||
return
|
||||
@@ -150,6 +150,19 @@ func (s *SysPostController) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, postInfo.PostName)
|
||||
if i18nValue != postInfo.PostName {
|
||||
i18n.UpdateKeyValue(language, postInfo.PostName, body.PostName)
|
||||
body.PostName = postInfo.PostName
|
||||
}
|
||||
// 多语言非原始值
|
||||
i18nValue2 := i18n.TKey(language, postInfo.Remark)
|
||||
if i18nValue2 != postInfo.Remark {
|
||||
i18n.UpdateKeyValue(language, postInfo.Remark, body.Remark)
|
||||
body.Remark = postInfo.Remark
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysPostService.UpdatePost(body)
|
||||
if rows > 0 {
|
||||
|
||||
@@ -139,8 +139,8 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 检查是否存在
|
||||
role := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||
if role.RoleID != body.RoleID {
|
||||
roleInfo := s.sysRoleService.SelectRoleById(body.RoleID)
|
||||
if roleInfo.RoleID != body.RoleID {
|
||||
// 没有可访问角色数据!
|
||||
c.JSON(200, result.ErrMsg(i18n.TKey(language, "role.noData")))
|
||||
return
|
||||
@@ -166,6 +166,19 @@ func (s *SysRoleController) Edit(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 多语言非原始值
|
||||
i18nValue := i18n.TKey(language, roleInfo.RoleName)
|
||||
if i18nValue != roleInfo.RoleName {
|
||||
i18n.UpdateKeyValue(language, roleInfo.RoleName, body.RoleName)
|
||||
body.RoleName = roleInfo.RoleName
|
||||
}
|
||||
// 多语言非原始值
|
||||
i18nValue2 := i18n.TKey(language, roleInfo.Remark)
|
||||
if i18nValue2 != roleInfo.Remark {
|
||||
i18n.UpdateKeyValue(language, roleInfo.Remark, body.Remark)
|
||||
body.Remark = roleInfo.Remark
|
||||
}
|
||||
|
||||
body.UpdateBy = ctx.LoginUserToUserName(c)
|
||||
rows := s.sysRoleService.UpdateRole(body)
|
||||
if rows > 0 {
|
||||
|
||||
Reference in New Issue
Block a user