|
|
@@ -4,17 +4,24 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.tr.core.exception.ServiceException;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
+import cn.tr.module.sys.tenant.dto.SysTenantCommonDTO;
|
|
|
import cn.tr.module.sys.tenant.dto.SysTenantPackageDTO;
|
|
|
+import cn.tr.module.sys.tenant.dto.SysTenantQueryDTO;
|
|
|
import cn.tr.module.sys.tenant.enums.PackageEnum;
|
|
|
import cn.tr.module.sys.tenant.po.SysTenantPackageMenuPO;
|
|
|
import cn.tr.module.sys.tenant.repository.SysTenantPackageMenuRepository;
|
|
|
import cn.tr.module.sys.tenant.service.ISysTenantPackageMenuService;
|
|
|
import cn.tr.module.sys.tenant.service.ISysTenantPackageService;
|
|
|
+import cn.tr.module.sys.tenant.service.ISysTenantService;
|
|
|
import cn.tr.module.sys.user.dto.SysMenuDTO;
|
|
|
+import cn.tr.module.sys.user.dto.SysPortalDTO;
|
|
|
import cn.tr.module.sys.user.dto.SysRoleDTO;
|
|
|
import cn.tr.core.enums.CreateEnum;
|
|
|
import cn.tr.module.sys.user.service.ISysMenuService;
|
|
|
+import cn.tr.module.sys.user.service.ISysPortalMenuService;
|
|
|
+import cn.tr.module.sys.user.service.ISysPortalService;
|
|
|
import cn.tr.module.sys.user.service.ISysRoleService;
|
|
|
+import cn.tr.plugin.biz.tenant.utils.TenantUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -47,6 +54,18 @@ public class SysTenantPackageMenuServiceImpl extends ServiceImpl<SysTenantPacka
|
|
|
@Lazy
|
|
|
private ISysMenuService menuService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private ISysPortalMenuService portalMenuService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private ISysPortalService portalService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ @Lazy
|
|
|
+ private ISysTenantService tenantService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void assignPackageMenu(String packageId,List<String> menuIds) {
|
|
|
@@ -54,14 +73,14 @@ public class SysTenantPackageMenuServiceImpl extends ServiceImpl<SysTenantPacka
|
|
|
if(StrUtil.equals(tenantPackage.getType(), CreateEnum.sys.name())){
|
|
|
throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"无法对系统套餐进行操作");
|
|
|
}
|
|
|
- Collection<SysRoleDTO> sysRoles = roleService.findAllSysRoles();
|
|
|
+
|
|
|
baseMapper.delete(
|
|
|
new LambdaQueryWrapper<SysTenantPackageMenuPO>().eq(SysTenantPackageMenuPO::getPackageId,packageId)
|
|
|
);
|
|
|
- self.delCacheMenuIdByPackageId(packageId);
|
|
|
if(CollectionUtil.isNotEmpty(menuIds)){
|
|
|
List<SysTenantPackageMenuPO> packageMenus = menuIds
|
|
|
.stream()
|
|
|
+ .distinct()
|
|
|
.map(menuId -> {
|
|
|
SysTenantPackageMenuPO result = new SysTenantPackageMenuPO();
|
|
|
result.setMenuId(menuId);
|
|
|
@@ -71,7 +90,24 @@ public class SysTenantPackageMenuServiceImpl extends ServiceImpl<SysTenantPacka
|
|
|
.collect(Collectors.toList());
|
|
|
this.saveBatch(packageMenus);
|
|
|
}
|
|
|
- sysRoles.forEach(role->menuService.delRoleMenusCache(role.getId()));
|
|
|
+ self.delCacheMenuIdByPackageId(packageId);
|
|
|
+
|
|
|
+
|
|
|
+ //对套餐绑定的租户进行操作
|
|
|
+ SysTenantQueryDTO query = new SysTenantQueryDTO();
|
|
|
+ query.setPackageId(packageId);
|
|
|
+ List<SysTenantCommonDTO> tenants = tenantService.selectSysTenantList(query);
|
|
|
+ if (CollectionUtil.isNotEmpty(tenants)) {
|
|
|
+ for (SysTenantCommonDTO tenant : tenants) {
|
|
|
+ TenantUtils.execute(tenant.getId(),()->{
|
|
|
+ Collection<SysRoleDTO> sysRoles = roleService.findAllSysRoles();
|
|
|
+ Collection<SysPortalDTO> sysPortals = portalService.findAllSysPortals();
|
|
|
+
|
|
|
+ sysRoles.forEach(role->menuService.delRoleMenusCache(role.getId()));
|
|
|
+ sysPortals.forEach(portal->portalMenuService.delCacheMenusByPortalId(portal.getId()));
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|