|
@@ -3,8 +3,6 @@ package com.lantone.security.facade;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
-import com.lantone.dblayermbg.entity.MenuInfo;
|
|
|
-import com.lantone.dblayermbg.service.impl.MenuInfoServiceImpl;
|
|
|
import com.lantone.security.dto.MenuInfoDTO;
|
|
|
import com.lantone.security.enums.ConstantEnum;
|
|
|
import com.lantone.security.enums.StatusEnum;
|
|
@@ -20,83 +18,83 @@ import java.util.List;
|
|
|
* @Date 2021/7/19
|
|
|
* @Version 1.0
|
|
|
*/
|
|
|
-public class UserMenuInfoFacade extends MenuInfoServiceImpl {
|
|
|
+public class UserMenuInfoFacade {
|
|
|
|
|
|
- /**
|
|
|
- * @Author songxl
|
|
|
- * @Description 获取用户显示的菜单
|
|
|
- * @Date 2021/7/20
|
|
|
- * @Param [userId]
|
|
|
- * @Return java.util.List<com.lantone.security.dto.MenuInfoDTO>
|
|
|
- * @MethodName getUserMenuList
|
|
|
- */
|
|
|
- public List<MenuInfoDTO> getUserMenuList(Long userId) {
|
|
|
-
|
|
|
- //系统管理员,拥有最高权限
|
|
|
- if (userId.intValue() == ConstantEnum.SUPER_USER.getKey()) {
|
|
|
- return getAllMenuList(null);
|
|
|
- }
|
|
|
-
|
|
|
- //用户菜单列表
|
|
|
- List<Long> menuIdList = this.baseMapper.queryAllMenuIdByUserId(userId, null);
|
|
|
- return getAllMenuList(menuIdList);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @Author songxl
|
|
|
- * @Description 获取所有菜单列表
|
|
|
- * @Date 2021/7/20
|
|
|
- * @Param [menuIdList]
|
|
|
- * @Return java.util.List<com.lantone.security.dto.MenuInfoDTO>
|
|
|
- * @MethodName getAllMenuList
|
|
|
- */
|
|
|
- private List<MenuInfoDTO> getAllMenuList(List<Long> menuIdList) {
|
|
|
- //查询根菜单列表
|
|
|
- List<MenuInfoDTO> menuList = queryListParentId(0L, menuIdList);
|
|
|
- //递归获取子菜单
|
|
|
- getMenuTreeList(menuList, menuIdList);
|
|
|
-
|
|
|
- return menuList;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 递归
|
|
|
- */
|
|
|
- private List<MenuInfoDTO> getMenuTreeList(List<MenuInfoDTO> menuList, List<Long> menuIdList) {
|
|
|
- List<MenuInfoDTO> subMenuList = new ArrayList();
|
|
|
-
|
|
|
- for (MenuInfoDTO menuInfoDTO : menuList) {
|
|
|
- menuInfoDTO.setSonMenuInfo(getMenuTreeList(queryListParentId(menuInfoDTO.getId(), menuIdList), menuIdList));
|
|
|
- subMenuList.add(menuInfoDTO);
|
|
|
- }
|
|
|
-
|
|
|
- return subMenuList;
|
|
|
- }
|
|
|
-
|
|
|
- public List<MenuInfoDTO> queryListParentId(Long parentId, List<Long> menuIdList) {
|
|
|
- List<MenuInfo> menuListEntity = this.list(new QueryWrapper<MenuInfo>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("status", StatusEnum.Enable.getKey())
|
|
|
- .eq("parent_id", parentId));
|
|
|
- List<MenuInfoDTO> menuList = new ArrayList<>();
|
|
|
- if (ListUtil.isNotEmpty(menuListEntity)) {
|
|
|
- menuListEntity.stream().forEach(menuInfo -> {
|
|
|
- MenuInfoDTO menuInfoDTO = new MenuInfoDTO();
|
|
|
- BeanUtils.copyProperties(menuInfo, menuInfoDTO);
|
|
|
- menuList.add(menuInfoDTO);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- if (menuIdList == null) {
|
|
|
- return menuList;
|
|
|
- }
|
|
|
-
|
|
|
- List<MenuInfoDTO> userMenuList = new ArrayList<>();
|
|
|
- for (MenuInfoDTO menu : menuList) {
|
|
|
- if (menuIdList.contains(menu.getId())) {
|
|
|
- userMenuList.add(menu);
|
|
|
- }
|
|
|
- }
|
|
|
- return userMenuList;
|
|
|
- }
|
|
|
+// /**
|
|
|
+// * @Author songxl
|
|
|
+// * @Description 获取用户显示的菜单
|
|
|
+// * @Date 2021/7/20
|
|
|
+// * @Param [userId]
|
|
|
+// * @Return java.util.List<com.lantone.security.dto.MenuInfoDTO>
|
|
|
+// * @MethodName getUserMenuList
|
|
|
+// */
|
|
|
+// public List<MenuInfoDTO> getUserMenuList(Long userId) {
|
|
|
+//
|
|
|
+// //系统管理员,拥有最高权限
|
|
|
+// if (userId.intValue() == ConstantEnum.SUPER_USER.getKey()) {
|
|
|
+// return getAllMenuList(null);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //用户菜单列表
|
|
|
+// List<Long> menuIdList = this.baseMapper.queryAllMenuIdByUserId(userId, null);
|
|
|
+// return getAllMenuList(menuIdList);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * @Author songxl
|
|
|
+// * @Description 获取所有菜单列表
|
|
|
+// * @Date 2021/7/20
|
|
|
+// * @Param [menuIdList]
|
|
|
+// * @Return java.util.List<com.lantone.security.dto.MenuInfoDTO>
|
|
|
+// * @MethodName getAllMenuList
|
|
|
+// */
|
|
|
+// private List<MenuInfoDTO> getAllMenuList(List<Long> menuIdList) {
|
|
|
+// //查询根菜单列表
|
|
|
+// List<MenuInfoDTO> menuList = queryListParentId(0L, menuIdList);
|
|
|
+// //递归获取子菜单
|
|
|
+// getMenuTreeList(menuList, menuIdList);
|
|
|
+//
|
|
|
+// return menuList;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 递归
|
|
|
+// */
|
|
|
+// private List<MenuInfoDTO> getMenuTreeList(List<MenuInfoDTO> menuList, List<Long> menuIdList) {
|
|
|
+// List<MenuInfoDTO> subMenuList = new ArrayList();
|
|
|
+//
|
|
|
+// for (MenuInfoDTO menuInfoDTO : menuList) {
|
|
|
+// menuInfoDTO.setSonMenuInfo(getMenuTreeList(queryListParentId(menuInfoDTO.getId(), menuIdList), menuIdList));
|
|
|
+// subMenuList.add(menuInfoDTO);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return subMenuList;
|
|
|
+// }
|
|
|
+//
|
|
|
+// public List<MenuInfoDTO> queryListParentId(Long parentId, List<Long> menuIdList) {
|
|
|
+// List<MenuInfo> menuListEntity = this.list(new QueryWrapper<MenuInfo>()
|
|
|
+// .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+// .eq("status", StatusEnum.Enable.getKey())
|
|
|
+// .eq("parent_id", parentId));
|
|
|
+// List<MenuInfoDTO> menuList = new ArrayList<>();
|
|
|
+// if (ListUtil.isNotEmpty(menuListEntity)) {
|
|
|
+// menuListEntity.stream().forEach(menuInfo -> {
|
|
|
+// MenuInfoDTO menuInfoDTO = new MenuInfoDTO();
|
|
|
+// BeanUtils.copyProperties(menuInfo, menuInfoDTO);
|
|
|
+// menuList.add(menuInfoDTO);
|
|
|
+// });
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (menuIdList == null) {
|
|
|
+// return menuList;
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<MenuInfoDTO> userMenuList = new ArrayList<>();
|
|
|
+// for (MenuInfoDTO menu : menuList) {
|
|
|
+// if (menuIdList.contains(menu.getId())) {
|
|
|
+// userMenuList.add(menu);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return userMenuList;
|
|
|
+// }
|
|
|
}
|