Commit b7c6fef053175e51d651e4042b01f147b0b25152

Authored by 云中非
1 parent c7b45e61

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

... ... @@ -105,6 +105,7 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
105 105 Menu menu = menuDTO.getEntity(Menu.class);
106 106 int insertCount = baseMapper.insert(menu);
107 107 if (insertCount > 0) {
  108 + cacheUtils.invalidateCacheName(FastIotConstants.CacheConfigKey.CACHE_CONFIG_KEY);
108 109 menu.copyToDTO(menuDTO);
109 110 return menuDTO;
110 111 }
... ... @@ -119,8 +120,8 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
119 120 @Override
120 121 @Transactional
121 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 125 throw new YtDataValidationException("cannot find menu to update");
125 126 } else {
126 127 if (!isSysAdmin) {
... ... @@ -128,12 +129,12 @@ public class MenuServiceImpl extends AbstractBaseService<MenuMapper, Menu> imple
128 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 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 139 return menuDTO;
139 140 }
... ...