diff --git a/backend/src/main/java/io/dataease/auth/service/impl/AuthUserServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/AuthUserServiceImpl.java index 485f6af09e..d2be520475 100644 --- a/backend/src/main/java/io/dataease/auth/service/impl/AuthUserServiceImpl.java +++ b/backend/src/main/java/io/dataease/auth/service/impl/AuthUserServiceImpl.java @@ -13,6 +13,7 @@ import io.dataease.plugins.common.base.domain.SysUser; import io.dataease.plugins.common.base.mapper.SysUserMapper; import io.dataease.plugins.common.service.PluginCommonService; import io.dataease.plugins.config.SpringContextUtil; +import io.dataease.plugins.util.PluginUtils; import io.dataease.plugins.xpack.cas.service.CasXpackService; import io.dataease.plugins.xpack.ldap.service.LdapXpackService; import io.dataease.plugins.xpack.oidc.service.OidcXpackService; @@ -95,7 +96,7 @@ public class AuthUserServiceImpl implements AuthUserService { public List permissions(Long userId) { try { // 用户登录获取菜单权限时同时更新插件菜单表 - dynamicMenuService.syncPluginMenu(); + dynamicMenuService.syncPluginMenu(PluginUtils.pluginMenus()); } catch (Exception e) { LogUtil.error(e); //ignore diff --git a/backend/src/main/java/io/dataease/auth/service/impl/DynamicMenuServiceImpl.java b/backend/src/main/java/io/dataease/auth/service/impl/DynamicMenuServiceImpl.java index 86a808436f..dc8b5e8954 100644 --- a/backend/src/main/java/io/dataease/auth/service/impl/DynamicMenuServiceImpl.java +++ b/backend/src/main/java/io/dataease/auth/service/impl/DynamicMenuServiceImpl.java @@ -12,6 +12,7 @@ import io.dataease.plugins.util.PluginUtils; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -118,12 +119,9 @@ public class DynamicMenuServiceImpl implements DynamicMenuService { return null == pid || pid == 0L; } - @Transactional - public void syncPluginMenu() { + @Transactional(propagation = Propagation.REQUIRES_NEW) + public void syncPluginMenu(List pluginSysMenuList) { extPluginSysMenuMapper.deletePluginMenu(); - List pluginSysMenuList = PluginUtils.pluginMenus(); - Set pluginSysMenuSet = new HashSet<>(pluginSysMenuList); - pluginSysMenuList = new ArrayList<>(pluginSysMenuSet); if (CollectionUtils.isNotEmpty(pluginSysMenuList)) { extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList); } diff --git a/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java b/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java index 57a8cabca5..ffbecb5d67 100644 --- a/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java +++ b/backend/src/main/java/io/dataease/plugins/util/PluginUtils.java @@ -30,7 +30,7 @@ public class PluginUtils { if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid) return new ArrayList<>(); Map pluginMenuServiceMap = SpringContextUtil.getApplicationContext().getBeansOfType(PluginMenuService.class); - List menus = pluginMenuServiceMap.values().stream().flatMap(item -> item.menus().stream()).collect(Collectors.toList()); + List menus = pluginMenuServiceMap.values().stream().flatMap(item -> item.menus().stream()).distinct().collect(Collectors.toList()); return menus; }