zhongrj
2024-04-27 7e82c16716481ee185330c63535936af6ff6af79
src/main/java/org/springblade/modules/system/service/impl/MenuServiceImpl.java
@@ -1,19 +1,3 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.system.service.impl;
import com.alibaba.fastjson.JSON;
@@ -21,10 +5,8 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import net.logstash.logback.encoder.org.apache.commons.lang3.StringUtils;
import org.springblade.common.cache.SysCache;
import org.springblade.common.constant.CommonConstant;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
@@ -35,8 +17,6 @@
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.modules.house.dto.UserHouseLabelDTO;
import org.springblade.modules.house.service.IUserHouseLabelService;
import org.springblade.modules.system.dto.MenuDTO;
import org.springblade.modules.system.entity.*;
import org.springblade.modules.system.mapper.MenuMapper;
@@ -73,9 +53,6 @@
   private final static String PARENT_ID = "parentId";
   private final static Integer MENU_CATEGORY = 1;
   @Resource
   private final IUserHouseLabelService iUserHouseLabelService;
   @Override
   public List<MenuVO> lazyList(Long parentId, Map<String, Object> param) {
      if (Func.isEmpty(Func.toStr(param.get(PARENT_ID)))) {
@@ -111,7 +88,7 @@
   @Override
   public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType, Integer menuType, String roleName) {
   public List<MenuVO> routes(String roleId, Long topMenuId, Integer labelType, Integer menuType, String roleName,String houseCode) {
      if (StringUtil.isBlank(roleId)) {
         return null;
      }
@@ -124,10 +101,6 @@
      // 非超级管理员并且不是顶部菜单请求则返回对应角色权限菜单
      else if (!AuthUtil.isAdministrator() && Func.isEmpty(topMenuId)) {
         roleMenus = tenantPackageMenu(baseMapper.roleMenuByRoleId(Func.toLongList(roleId), menuType));
         // 1:居民,居民需要通过人的标签来显示取保候审
         if (CommonConstant.RESIDENT.equals(roleName)) {
            extracted(labelType, roleMenus);
         }
      }
      // 顶部菜单请求返回对应角色权限菜单
      else {
@@ -153,34 +126,10 @@
    * @param roleMenus
    * @param labelType
    */
   private void extracted(Integer labelType, List<Menu> roleMenus) {
      UserHouseLabelDTO userHouseLabelDTO = new UserHouseLabelDTO();
      userHouseLabelDTO.setUserId(AuthUtil.getUserId());
      userHouseLabelDTO.setLableType(labelType);
      List<Integer> integers = iUserHouseLabelService.selectUserLabelList(userHouseLabelDTO);
   private void extracted(Integer labelType, List<Menu> roleMenus,String houseCode) {
      Iterator<Menu> iterator = roleMenus.iterator();
      while (iterator.hasNext()) {
         Menu next = iterator.next();
         if (!next.getParentId().equals(0)) {
            if (StringUtils.isNotBlank(next.getLabelId())) {
               String[] split = next.getLabelId().split(",");
               List<Integer> integerList = Arrays.stream(split).map(Integer::valueOf).collect(Collectors.toList());
               Collection<? extends Serializable> union = CollectionUtils.intersection(integerList, integers);
               if (union.size() == 0) {
                  iterator.remove();
                  // 场所的时候,删除取保候审
               } else if (CommonConstant.NUMBER_TWO.equals(labelType)) {
                  if (next.getName().trim().equals("取保候审")) {
                     iterator.remove();
                  }
               }
            } else {
               if (next.getName().trim().equals("取保候审")) {
                  iterator.remove();
               }
            }
         }
      }
   }