forked from github/dataease
Merge pull request #2541 from dataease/pr@dev@refactor_slow-sql
refactor: 优惠插件菜单同步慢sql
This commit is contained in:
commit
459b0d49c2
@ -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<String> permissions(Long userId) {
|
||||
try {
|
||||
// 用户登录获取菜单权限时同时更新插件菜单表
|
||||
dynamicMenuService.syncPluginMenu();
|
||||
dynamicMenuService.syncPluginMenu(PluginUtils.pluginMenus());
|
||||
} catch (Exception e) {
|
||||
LogUtil.error(e);
|
||||
//ignore
|
||||
|
@ -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<PluginSysMenu> pluginSysMenuList) {
|
||||
extPluginSysMenuMapper.deletePluginMenu();
|
||||
List<PluginSysMenu> pluginSysMenuList = PluginUtils.pluginMenus();
|
||||
Set<PluginSysMenu> pluginSysMenuSet = new HashSet<>(pluginSysMenuList);
|
||||
pluginSysMenuList = new ArrayList<>(pluginSysMenuSet);
|
||||
if (CollectionUtils.isNotEmpty(pluginSysMenuList)) {
|
||||
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class PluginUtils {
|
||||
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid)
|
||||
return new ArrayList<>();
|
||||
Map<String, PluginMenuService> pluginMenuServiceMap = SpringContextUtil.getApplicationContext().getBeansOfType(PluginMenuService.class);
|
||||
List<PluginSysMenu> menus = pluginMenuServiceMap.values().stream().flatMap(item -> item.menus().stream()).collect(Collectors.toList());
|
||||
List<PluginSysMenu> menus = pluginMenuServiceMap.values().stream().flatMap(item -> item.menus().stream()).distinct().collect(Collectors.toList());
|
||||
return menus;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user