|
|
@ -22,17 +22,23 @@ import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.Constant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.exception.ErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.HttpContextUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.utils.TreeUtils; |
|
|
|
import com.epmet.dao.GovMenuDao; |
|
|
|
import com.epmet.dao.GovRoleDao; |
|
|
|
import com.epmet.dao.GovRoleMenuDao; |
|
|
|
import com.epmet.dao.GovRoleUserDao; |
|
|
|
import com.epmet.dto.GovMenuDTO; |
|
|
|
import com.epmet.entity.GovMenuEntity; |
|
|
|
import com.epmet.enums.MenuTypeEnum; |
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
|
import com.epmet.redis.GovCustomerMenuRedis; |
|
|
|
import com.epmet.redis.GovMenuRedis; |
|
|
|
import com.epmet.service.*; |
|
|
@ -45,6 +51,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* 菜单管理 |
|
|
@ -67,6 +74,14 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
private GovLanguageService govLanguageService; |
|
|
|
@Autowired |
|
|
|
private GovCustomerMenuService govCustomerMenuService; |
|
|
|
@Autowired |
|
|
|
private GovRoleDao govRoleDao; |
|
|
|
@Autowired |
|
|
|
private GovRoleMenuDao govRoleMenuDao; |
|
|
|
@Autowired |
|
|
|
private GovRoleUserDao govRoleUserDao; |
|
|
|
@Autowired |
|
|
|
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<GovMenuDTO> page(Map<String, Object> params) { |
|
|
@ -218,7 +233,26 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
// PC端 每个客户的菜单信息,不放入缓存,每次登陆重新查询。
|
|
|
|
// 或者 你可以选择,在给每个客户 配置可见菜单的时候, 在saveCustomerMenu方法中,增加更新缓存的逻辑
|
|
|
|
tableName = getTableName(tableName); |
|
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName); |
|
|
|
return getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(),tableName,tokenDto.getUserId()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<GovMenuDTO> navDigitalCommunity(TokenDto tokenDto, String tableName) { |
|
|
|
tableName = getTableName(tableName); |
|
|
|
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(tokenDto.getCustomerId(), MenuTypeEnum.MENU.value(), HttpContextUtils.getLanguage(),tableName); |
|
|
|
Result<Boolean> isRootManager = epmetUserOpenFeignClient.getIsRootManager(tokenDto.getUserId()); |
|
|
|
if (!isRootManager.success()){ |
|
|
|
throw new EpmetException("getIsRootManager method is failure"); |
|
|
|
} |
|
|
|
if (isRootManager.getData()){ |
|
|
|
List<GovMenuDTO> govMenuDTOS = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); |
|
|
|
return TreeUtils.buildTree(govMenuDTOS); |
|
|
|
} |
|
|
|
disposeGovMenu(menuList,tokenDto.getUserId()); |
|
|
|
Map<Boolean, List<GovMenuEntity>> groupByStatus = menuList.stream().collect(Collectors.groupingBy(GovMenuEntity::getRoleStatus)); |
|
|
|
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(CollectionUtils.isEmpty(groupByStatus.get(true)) ? new ArrayList<>() : groupByStatus.get(true), GovMenuDTO.class); |
|
|
|
List<GovMenuDTO> govMenuDTOS = TreeUtils.buildTree(dtoList); |
|
|
|
return govMenuDTOS; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -231,7 +265,7 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
* @Author zhangyong |
|
|
|
* @Date 15:51 2021-03-16 |
|
|
|
**/ |
|
|
|
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type, String tableName) { |
|
|
|
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type, String tableName,String userId) { |
|
|
|
List<GovMenuDTO> govMenuDTOS = govCustomerMenuRedis.getCustomerMenuList(customerId,type,tableName); |
|
|
|
if (!CollectionUtils.isEmpty(govMenuDTOS)){ |
|
|
|
return govMenuDTOS; |
|
|
@ -243,6 +277,26 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit |
|
|
|
return govMenuDTOS; |
|
|
|
} |
|
|
|
|
|
|
|
public void disposeGovMenu(List<GovMenuEntity> menuList,String userId){ |
|
|
|
List<String> roleIdList = govRoleUserDao.getRoleIdList(userId); |
|
|
|
if (CollectionUtils.isEmpty(roleIdList)){ |
|
|
|
menuList = new ArrayList<>(); |
|
|
|
return; |
|
|
|
} |
|
|
|
List<String> menuIdsList = govRoleMenuDao.getMenuIdsList(roleIdList); |
|
|
|
if (CollectionUtils.isEmpty(menuIdsList)){ |
|
|
|
menuList = new ArrayList<>(); |
|
|
|
return; |
|
|
|
} |
|
|
|
for (String id : menuIdsList) { |
|
|
|
for (GovMenuEntity m : menuList) { |
|
|
|
if (m.getId().equals(id)){ |
|
|
|
m.setRoleStatus(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Set<String> getUserPermissions(TokenDto tokenDto) { |
|
|
|
//用户权限列表
|
|
|
|