|
|
|
@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.domain.po.MallPermission; |
|
|
|
import com.iformall.domain.po.MallUserInfo; |
|
|
|
import com.iformall.enums.EnumMenuType; |
|
|
|
import com.iformall.enums.EnumPermissionType; |
|
|
|
import com.iformall.enums.EnumUserAdmin; |
|
|
|
import com.iformall.mapper.MallPermissionMapper; |
|
|
|
@@ -36,7 +37,7 @@ public class MallPermissionServiceImpl implements MallPermissionService { |
|
|
|
private WxMallMapper wxMallMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<MallPermission> queryListParentId(Long parentId, List<Long> menuIdList) { |
|
|
|
public List<MallPermission> queryListParentId(Long parentId, List<Long> menuIdList, boolean boolNav) { |
|
|
|
List<MallPermission> menuList = queryListParentId(parentId); |
|
|
|
if(menuIdList == null){ |
|
|
|
return menuList; |
|
|
|
@@ -44,6 +45,11 @@ public class MallPermissionServiceImpl implements MallPermissionService { |
|
|
|
|
|
|
|
List<MallPermission> userMenuList = new ArrayList<>(); |
|
|
|
for(MallPermission menu : menuList){ |
|
|
|
if(boolNav) { |
|
|
|
if(menu.getId().longValue() == (long)EnumMenuType.MOBILE_ADMIN.getCode()) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
if(menuIdList.contains(menu.getId())){ |
|
|
|
userMenuList.add(menu); |
|
|
|
} |
|
|
|
@@ -70,18 +76,18 @@ public class MallPermissionServiceImpl implements MallPermissionService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<Long> queryUserMenuIds(MallUserInfo userInfo, Long parentId) { |
|
|
|
public List<Long> queryUserMenuIds(MallUserInfo userInfo, Long parentId, boolean boolNav) { |
|
|
|
List<Long> mpList = new ArrayList<Long>(); |
|
|
|
if(userInfo.isFmSuperAdmin() || |
|
|
|
userInfo.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { |
|
|
|
List<MallPermission> mps = getAllMenuListByParentId(parentId, null); |
|
|
|
List<MallPermission> mps = getAllMenuListByParentId(parentId, null, boolNav); |
|
|
|
mps.stream().forEach(mp->{ |
|
|
|
mpList.add(mp.getId()); |
|
|
|
}); |
|
|
|
return mpList; |
|
|
|
} else { |
|
|
|
List<Long> menuIdList = mallUserInfoMapper.queryAllMenuId(userInfo.getId()); |
|
|
|
List<MallPermission> mps = getAllMenuListByParentId(parentId, menuIdList); |
|
|
|
List<MallPermission> mps = getAllMenuListByParentId(parentId, menuIdList, boolNav); |
|
|
|
mps.stream().forEach(mp->{ |
|
|
|
mpList.add(mp.getId()); |
|
|
|
}); |
|
|
|
@@ -90,38 +96,31 @@ public class MallPermissionServiceImpl implements MallPermissionService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<MallPermission> getUserMenuList(MallUserInfo userInfo, Long parentId) { |
|
|
|
public List<MallPermission> getUserMenuList(MallUserInfo userInfo, Long parentId, boolean boolNav) { |
|
|
|
if(userInfo.isFmSuperAdmin()) { |
|
|
|
// 富茂系统管理员,返回所有菜单 |
|
|
|
return getAllMenuListByParentId(parentId, null); |
|
|
|
return getAllMenuListByParentId(parentId, null, boolNav); |
|
|
|
} |
|
|
|
else if(userInfo.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { |
|
|
|
// 租户超管 |
|
|
|
String menus = wxMallMapper.queryMenusByTenantId(userInfo.getTenantId()); |
|
|
|
JSONArray menuIdList = JSON.parseArray(menus); |
|
|
|
return getAllMenuListByParentId(0L, menuIdList.toJavaList(Long.class)); |
|
|
|
return getAllMenuListByParentId(0L, menuIdList.toJavaList(Long.class), boolNav); |
|
|
|
} else { |
|
|
|
//用户菜单列表 |
|
|
|
List<Long> menuIdList = mallUserInfoMapper.queryAllMenuId(userInfo.getId()); |
|
|
|
return getAllMenuListByParentId(0L, menuIdList); |
|
|
|
return getAllMenuListByParentId(0L, menuIdList, boolNav); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取所有菜单列表 |
|
|
|
*/ |
|
|
|
private List<MallPermission> getAllMenuList(List<Long> menuIdList){ |
|
|
|
return getAllMenuListByParentId(0L, menuIdList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取所有菜单列表 |
|
|
|
*/ |
|
|
|
private List<MallPermission> getAllMenuListByParentId(Long parentId, List<Long> menuIdList){ |
|
|
|
private List<MallPermission> getAllMenuListByParentId(Long parentId, List<Long> menuIdList, boolean boolNav){ |
|
|
|
//查询根菜单列表 |
|
|
|
List<MallPermission> menuList = queryListParentId(parentId, menuIdList); |
|
|
|
List<MallPermission> menuList = queryListParentId(parentId, menuIdList, boolNav); |
|
|
|
//递归获取子菜单 |
|
|
|
getMenuTreeList(menuList, menuIdList); |
|
|
|
getMenuTreeList(menuList, menuIdList, boolNav); |
|
|
|
|
|
|
|
return menuList; |
|
|
|
} |
|
|
|
@@ -129,13 +128,13 @@ public class MallPermissionServiceImpl implements MallPermissionService { |
|
|
|
/** |
|
|
|
* 递归 |
|
|
|
*/ |
|
|
|
private List<MallPermission> getMenuTreeList(List<MallPermission> menuList, List<Long> menuIdList){ |
|
|
|
private List<MallPermission> getMenuTreeList(List<MallPermission> menuList, List<Long> menuIdList, boolean boolNav){ |
|
|
|
List<MallPermission> subMenuList = new ArrayList<MallPermission>(); |
|
|
|
|
|
|
|
for(MallPermission entity : menuList){ |
|
|
|
//目录 |
|
|
|
if(entity.getResourceType().equals(EnumPermissionType.CATALOG.getCode())){ |
|
|
|
entity.setChildren(getMenuTreeList(queryListParentId(entity.getId(), menuIdList), menuIdList)); |
|
|
|
entity.setChildren(getMenuTreeList(queryListParentId(entity.getId(), menuIdList, boolNav), menuIdList, boolNav)); |
|
|
|
} |
|
|
|
subMenuList.add(entity); |
|
|
|
} |
|
|
|
|