|
@@ -1,6 +1,7 @@
|
|
|
package com.usky.system.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.system.domain.SysMenu;
|
|
@@ -47,15 +48,11 @@ public class SysPlatformMenuServiceImpl extends AbstractCrudService<SysPlatformM
|
|
|
return baseMapper.getMobileMenuList(platformId, null);
|
|
|
}
|
|
|
|
|
|
- public Long[] selectPlatformMenu(Integer tenantId){
|
|
|
+ public List<SysTenantMenu> selectPlatformMenu(Integer tenantId){
|
|
|
LambdaQueryWrapper<SysTenantMenu> queryWrapper = Wrappers.lambdaQuery();
|
|
|
queryWrapper.eq(SysTenantMenu::getTenantId, tenantId).orderByAsc(SysTenantMenu::getMenuId);
|
|
|
List<SysTenantMenu> menuList = sysTenantMenuService.list(queryWrapper);
|
|
|
- Long[] arr = new Long[menuList.size()];
|
|
|
- for (int i = 0; i < menuList.size(); i++) {
|
|
|
- arr[i] = menuList.get(i).getMenuId();
|
|
|
- }
|
|
|
- return arr;
|
|
|
+ return menuList;
|
|
|
}
|
|
|
|
|
|
public Long[] selectMobilePlatformMenu(Integer tenantId){
|
|
@@ -196,68 +193,61 @@ public class SysPlatformMenuServiceImpl extends AbstractCrudService<SysPlatformM
|
|
|
@Transactional
|
|
|
public void updateMenu(TenantMenuVo tenantMenuVo) {
|
|
|
List arr3 = new ArrayList();
|
|
|
- Long[] arr = tenantMenuVo.getMenuIds();
|
|
|
- //菜单ID
|
|
|
- List<SysMenu> menuIdList = baseMapper.getMenuIdList(arr, "F");
|
|
|
- Long arr1[] = new Long[menuIdList.size()];
|
|
|
- for (int i = 0; i < menuIdList.size(); i++) {
|
|
|
- arr1[i] = menuIdList.get(i).getParentId();
|
|
|
- }
|
|
|
- //目录ID
|
|
|
- if(arr1.length > 0){
|
|
|
- List<SysMenu> menuIdListOne = baseMapper.getMenuIdList(arr1, "C");
|
|
|
- Long arr2[] = new Long[menuIdListOne.size()];
|
|
|
- for (int i = 0; i < menuIdListOne.size(); i++) {
|
|
|
- arr2[i] = menuIdListOne.get(i).getParentId();
|
|
|
- }
|
|
|
- List<SysMenu> menuIdListTwo = baseMapper.getMenuIdList(arr, "C");
|
|
|
- Long arr4[] = new Long[menuIdListTwo.size()];
|
|
|
- for (int i = 0; i < menuIdListTwo.size(); i++) {
|
|
|
- arr4[i] = menuIdListTwo.get(i).getParentId();
|
|
|
- }
|
|
|
- Long[] arr5 = arrayMerge(arr1, arr2);
|
|
|
- Long[] arr6 = arrayMerge(arr5, arr4);
|
|
|
- Long[] arr7 = arrayMerge(arr6, arr);
|
|
|
- for (int i = 0; i < arr7.length; i++) {
|
|
|
- if (!arr3.contains(arr7[i])) {
|
|
|
- arr3.add(arr7[i]);
|
|
|
+ List<PlatformMenuVo> platformMenuVos = tenantMenuVo.getPlatformMenuVos();
|
|
|
+ if (CollectionUtils.isNotEmpty(platformMenuVos)){
|
|
|
+ // 删除租户菜单关联
|
|
|
+ baseMapper.deleteTenantMenuBy(tenantMenuVo.getTenantId());
|
|
|
+ for (int j=0;j<platformMenuVos.size();j++){
|
|
|
+ Long[] arr = platformMenuVos.get(j).getMenuIds();
|
|
|
+ //菜单ID
|
|
|
+ List<SysMenu> menuIdList = baseMapper.getMenuIdList(arr, "F");
|
|
|
+ Long arr1[] = new Long[menuIdList.size()];
|
|
|
+ for (int i = 0; i < menuIdList.size(); i++) {
|
|
|
+ arr1[i] = menuIdList.get(i).getParentId();
|
|
|
}
|
|
|
- }
|
|
|
- }else{
|
|
|
- List<SysMenu> menuIdListTwo = baseMapper.getMenuIdList(arr, "C");
|
|
|
- Long arr4[] = new Long[menuIdListTwo.size()];
|
|
|
- for (int i = 0; i < menuIdListTwo.size(); i++) {
|
|
|
- arr4[i] = menuIdListTwo.get(i).getParentId();
|
|
|
- }
|
|
|
- Long[] arr7 = arrayMerge(arr4, arr);
|
|
|
- for (int i = 0; i < arr7.length; i++) {
|
|
|
- if (!arr3.contains(arr7[i])) {
|
|
|
- arr3.add(arr7[i]);
|
|
|
+ //目录ID
|
|
|
+ if(arr1.length > 0){
|
|
|
+ List<SysMenu> menuIdListOne = baseMapper.getMenuIdList(arr1, "C");
|
|
|
+ Long arr2[] = new Long[menuIdListOne.size()];
|
|
|
+ for (int i = 0; i < menuIdListOne.size(); i++) {
|
|
|
+ arr2[i] = menuIdListOne.get(i).getParentId();
|
|
|
+ }
|
|
|
+ List<SysMenu> menuIdListTwo = baseMapper.getMenuIdList(arr, "C");
|
|
|
+ Long arr4[] = new Long[menuIdListTwo.size()];
|
|
|
+ for (int i = 0; i < menuIdListTwo.size(); i++) {
|
|
|
+ arr4[i] = menuIdListTwo.get(i).getParentId();
|
|
|
+ }
|
|
|
+ Long[] arr5 = arrayMerge(arr1, arr2);
|
|
|
+ Long[] arr6 = arrayMerge(arr5, arr4);
|
|
|
+ Long[] arr7 = arrayMerge(arr6, arr);
|
|
|
+ for (int i = 0; i < arr7.length; i++) {
|
|
|
+ if (!arr3.contains(arr7[i])) {
|
|
|
+ arr3.add(arr7[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ List<SysMenu> menuIdListTwo = baseMapper.getMenuIdList(arr, "C");
|
|
|
+ Long arr4[] = new Long[menuIdListTwo.size()];
|
|
|
+ for (int i = 0; i < menuIdListTwo.size(); i++) {
|
|
|
+ arr4[i] = menuIdListTwo.get(i).getParentId();
|
|
|
+ }
|
|
|
+ Long[] arr7 = arrayMerge(arr4, arr);
|
|
|
+ for (int i = 0; i < arr7.length; i++) {
|
|
|
+ if (!arr3.contains(arr7[i])) {
|
|
|
+ arr3.add(arr7[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //新增菜单
|
|
|
+ if (arr3.size() > 0) {
|
|
|
+ for (int i = 0; i < arr3.size(); i++) {
|
|
|
+ SysTenantMenu sysTenantMenu = new SysTenantMenu();
|
|
|
+ sysTenantMenu.setMenuId((Long) arr3.get(i));
|
|
|
+ sysTenantMenu.setTenantId(tenantMenuVo.getTenantId());
|
|
|
+ sysTenantMenu.setPlatformId(platformMenuVos.get(j).getPlatformId());
|
|
|
+ sysTenantMenuService.save(sysTenantMenu);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-// Long[] arr3 =ifRepeat2(arr6);
|
|
|
-// Long arr3[] = new Long[arr1.length+arr2.length+arr.length];
|
|
|
-// for (int i=0;i<arr1.length;i++){
|
|
|
-// arr3[i] = arr1[i];
|
|
|
-// }
|
|
|
-// for (int i=0;i<arr2.length;i++){
|
|
|
-// arr3[i+arr1.length] = arr2[i];
|
|
|
-// }
|
|
|
-// for (int i=0;i<arr.length;i++){
|
|
|
-// arr3[i+arr1.length+arr2.length] = arr[i];
|
|
|
-// }
|
|
|
-
|
|
|
- // 删除租户菜单关联
|
|
|
- baseMapper.deleteTenantMenuBy(tenantMenuVo.getTenantId());
|
|
|
- //新增菜单
|
|
|
- if (arr3.size() > 0) {
|
|
|
- for (int i = 0; i < arr3.size(); i++) {
|
|
|
- SysTenantMenu sysTenantMenu = new SysTenantMenu();
|
|
|
- sysTenantMenu.setMenuId((Long) arr3.get(i));
|
|
|
- sysTenantMenu.setTenantId(tenantMenuVo.getTenantId());
|
|
|
- sysTenantMenuService.save(sysTenantMenu);
|
|
|
}
|
|
|
}
|
|
|
}
|