fix: 修复更新xpack菜单 事务失效问题

This commit is contained in:
wangjiahao 2021-06-23 17:40:21 +08:00
parent 5ba240b781
commit c07462bd55
3 changed files with 23 additions and 15 deletions

View File

@ -33,7 +33,7 @@ public class AuthUserServiceImpl implements AuthUserService {
@Resource
private SysUserMapper sysUserMapper;
@Resource
private ExtPluginSysMenuMapper extPluginSysMenuMapper;
private DynamicMenuServiceImpl dynamicMenuService;
/**
* 此处需被F2CRealm登录认证调用 也就是说每次请求都会被调用 所以最好加上缓存
@ -65,7 +65,7 @@ public class AuthUserServiceImpl implements AuthUserService {
@Override
public List<String> permissions(Long userId){
// 用户登录获取菜单权限时同时更新插件菜单表
this.syncPluginMenu();
dynamicMenuService.syncPluginMenu();
List<String> permissions;
SysUser sysUser = sysUserMapper.selectByPrimaryKey(userId);
if(sysUser.getIsAdmin()!=null&&sysUser.getIsAdmin()){
@ -102,12 +102,4 @@ public class AuthUserServiceImpl implements AuthUserService {
LogUtil.info("正在清除用户缓存【{}】",userId);
}
@Transactional
public void syncPluginMenu() {
List<PluginSysMenu> pluginSysMenuList = PluginUtils.pluginMenus();
extPluginSysMenuMapper.deletePluginMenu();
if(CollectionUtils.isNotEmpty(pluginSysMenuList)){
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
}
}
}

View File

@ -6,11 +6,15 @@ import io.dataease.auth.service.DynamicMenuService;
import io.dataease.base.domain.SysMenu;
import io.dataease.base.domain.SysMenuExample;
import io.dataease.base.mapper.SysMenuMapper;
import io.dataease.base.mapper.ext.ExtPluginSysMenuMapper;
import io.dataease.plugins.common.dto.PluginSysMenu;
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.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@ -22,6 +26,9 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
@Autowired(required = false)
private SysMenuMapper sysMenuMapper;
@Resource
private ExtPluginSysMenuMapper extPluginSysMenuMapper;
@Override
public List<DynamicMenuDto> load(String userId) {
SysMenuExample sysMenuExample = new SysMenuExample();
@ -109,4 +116,13 @@ public class DynamicMenuServiceImpl implements DynamicMenuService {
private Boolean isParent(Long pid){
return null == pid || pid==0L;
}
@Transactional
public void syncPluginMenu() {
List<PluginSysMenu> pluginSysMenuList = PluginUtils.pluginMenus();
extPluginSysMenuMapper.deletePluginMenu();
if(CollectionUtils.isNotEmpty(pluginSysMenuList)){
extPluginSysMenuMapper.savePluginMenu(pluginSysMenuList);
}
}
}

View File

@ -14,10 +14,9 @@
<component-gap class="attr-selector" />
</el-row>
</el-collapse-item>
<el-collapse-item :title="$t('chart.module_style')" name="component">
<el-collapse-item :title="$t('panel.table')" name="table">
<el-row style="background-color: #f7f8fa; margin: 5px">
<!-- <title-selector class="attr-selector" :chart="chart" @onTextChange="onTextChange" />-->
<background-color-selector v-if="chart" class="attr-selector" :chart="chart" @onChangeBackgroundForm="onChangeBackgroundForm" />
<color-selector index="10002" :source-type="'panelTable'" class="attr-selector" :chart="tableChart" @onColorChange="onTableColorChange" />
</el-row>
</el-collapse-item>
<el-collapse-item :title="$t('chart.shape_attr')" name="graphical">
@ -25,9 +24,10 @@
<color-selector :source-type="'panelEchart'" class="attr-selector" :chart="chart" @onColorChange="onColorChange" />
</el-row>
</el-collapse-item>
<el-collapse-item :title="$t('panel.table')" name="table">
<el-collapse-item :title="$t('chart.module_style')" name="component">
<el-row style="background-color: #f7f8fa; margin: 5px">
<color-selector index="10002" :source-type="'panelTable'" class="attr-selector" :chart="tableChart" @onColorChange="onTableColorChange" />
<!-- <title-selector class="attr-selector" :chart="chart" @onTextChange="onTextChange" />-->
<background-color-selector v-if="chart" class="attr-selector" :chart="chart" @onChangeBackgroundForm="onChangeBackgroundForm" />
</el-row>
</el-collapse-item>
</el-collapse>