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.base.mapper.SysUserMapper;
|
||||||
import io.dataease.plugins.common.service.PluginCommonService;
|
import io.dataease.plugins.common.service.PluginCommonService;
|
||||||
import io.dataease.plugins.config.SpringContextUtil;
|
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.cas.service.CasXpackService;
|
||||||
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
import io.dataease.plugins.xpack.ldap.service.LdapXpackService;
|
||||||
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
import io.dataease.plugins.xpack.oidc.service.OidcXpackService;
|
||||||
@ -95,7 +96,7 @@ public class AuthUserServiceImpl implements AuthUserService {
|
|||||||
public List<String> permissions(Long userId) {
|
public List<String> permissions(Long userId) {
|
||||||
try {
|
try {
|
||||||
// 用户登录获取菜单权限时同时更新插件菜单表
|
// 用户登录获取菜单权限时同时更新插件菜单表
|
||||||
dynamicMenuService.syncPluginMenu();
|
dynamicMenuService.syncPluginMenu(PluginUtils.pluginMenus());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LogUtil.error(e);
|
LogUtil.error(e);
|
||||||
//ignore
|
//ignore
|
||||||
|
@ -12,6 +12,7 @@ import io.dataease.plugins.util.PluginUtils;
|
|||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
@ -118,12 +119,9 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
|
|||||||
return null == pid || pid == 0L;
|
return null == pid || pid == 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||||
public void syncPluginMenu() {
|
public void syncPluginMenu(List<PluginSysMenu> pluginSysMenuList) {
|
||||||
extPluginSysMenuMapper.deletePluginMenu();
|
extPluginSysMenuMapper.deletePluginMenu();
|
||||||
List<PluginSysMenu> pluginSysMenuList = PluginUtils.pluginMenus();
|
|
||||||
Set<PluginSysMenu> pluginSysMenuSet = new HashSet<>(pluginSysMenuList);
|
|
||||||
pluginSysMenuList = new ArrayList<>(pluginSysMenuSet);
|
|
||||||
if (CollectionUtils.isNotEmpty(pluginSysMenuList)) {
|
if (CollectionUtils.isNotEmpty(pluginSysMenuList)) {
|
||||||
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
|
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class PluginUtils {
|
|||||||
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid)
|
if (f2CLicenseResponse.getStatus() != F2CLicenseResponse.Status.valid)
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
Map<String, PluginMenuService> pluginMenuServiceMap = SpringContextUtil.getApplicationContext().getBeansOfType(PluginMenuService.class);
|
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;
|
return menus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user