Commit 1758d95f5504267ddfb79bcc843b78e57e346598

Authored by xp.Huang
2 parents c7b45e61 b7c6fef0

Merge branch '20220519' into 'master'

fix(DEFECT-407): 菜单权限修改后未刷新缓存问题

See merge request huang/thingsboard3.3.2!102
@@ -105,6 +105,7 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple @@ -105,6 +105,7 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
105 Menu menu = menuDTO.getEntity(Menu.class); 105 Menu menu = menuDTO.getEntity(Menu.class);
106 int insertCount = baseMapper.insert(menu); 106 int insertCount = baseMapper.insert(menu);
107 if (insertCount > 0) { 107 if (insertCount > 0) {
  108 + cacheUtils.invalidateCacheName(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY);
108 menu.copyToDTO(menuDTO); 109 menu.copyToDTO(menuDTO);
109 return menuDTO; 110 return menuDTO;
110 } 111 }
@@ -119,8 +120,8 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple @@ -119,8 +120,8 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
119 @Override 120 @Override
120 @Transactional 121 @Transactional
121 public MenuDTO updateMenu(String tenantId, boolean isSysAdmin, MenuDTO menuDTO) { 122 public MenuDTO updateMenu(String tenantId, boolean isSysAdmin, MenuDTO menuDTO) {
122 - Menu menu = baseMapper.selectById(menuDTO.getId());  
123 - if (menu == null) { 123 + Menu oldMenu = baseMapper.selectById(menuDTO.getId());
  124 + if (oldMenu == null) {
124 throw new YtDataValidationException("cannot find menu to update"); 125 throw new YtDataValidationException("cannot find menu to update");
125 } else { 126 } else {
126 if (!isSysAdmin) { 127 if (!isSysAdmin) {
@@ -128,12 +129,12 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple @@ -128,12 +129,12 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
128 throw new AccessDeniedException("You don't have permission to update this menu"); 129 throw new AccessDeniedException("You don't have permission to update this menu");
129 } 130 }
130 } 131 }
131 - menuDTO.copyToEntity(menu);  
132 - baseMapper.updateById(menu);  
133 - if (!Objects.equals(menuDTO.getPermission(), menu.getPermission())) { 132 + if (!Objects.equals(menuDTO.getPermission(), oldMenu.getPermission())) {
134 cacheUtils.invalidateCacheName(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY); 133 cacheUtils.invalidateCacheName(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY);
135 } 134 }
136 - menu.copyToDTO(menuDTO); 135 + menuDTO.copyToEntity(oldMenu);
  136 + baseMapper.updateById(oldMenu);
  137 + oldMenu.copyToDTO(menuDTO);
137 } 138 }
138 return menuDTO; 139 return menuDTO;
139 } 140 }