UI授权后,由于一个用户拥有多个角色问题,没有权限的角色可能会把有权限的角色数据替换,进行修改
已修改5个文件
52 ■■■■■ 文件已修改
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIEngineServiceI.java
@@ -177,7 +177,7 @@
     * @param pkComponent 组件的主键
     * @return 按钮的信息
     */
    List<UIButtonDefineVO> listButtonByComponent(String pkComponent, Map<String, RoleRightVO> roleRightMap);
    List<UIButtonDefineVO> listButtonByComponent(String pkComponent, Map<String, List<RoleRightVO>> roleRightMap);
    /**
     * 按钮的数据对象转换为显示对象
@@ -209,6 +209,6 @@
    //    UIContentVO UIContentDO2VO(PLPageLayoutDefination pageLayoutDefination, boolean queryDetail);
    UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail,Map<String, RoleRightVO> roleRightMap);
    UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail,Map<String, List<RoleRightVO>> roleRightMap);
}
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/UIManagerServiceI.java
@@ -213,7 +213,7 @@
     * @return
     * @throws PLException
     */
    Map<String,RoleRightVO> getRoleRightMap(String roleId) throws PLException;
    Map<String, List<RoleRightVO>> getRoleRightMap(String roleId) throws PLException;
    /**
     * UI授权
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/SmFunctionQueryServicePlatformImpl.java
@@ -722,7 +722,7 @@
        /* if(resourceControlTypeEnum == null){
            resourceControlTypeEnum = ResourceControlTypeEnum.BS;
        }*/
        Map<String, RoleRightVO> roleRightMap = uiManagerServiceI.getRoleRightMap(null);
        Map<String, List<RoleRightVO>> roleRightMap = uiManagerServiceI.getRoleRightMap(null);
        for (PLUILayout allPLUILayout : platformClientUtil.getUIService().getAllPLUILayouts()) {
            if(treeQueryObject.getConditionMap().getOrDefault("type","").equals(allPLUILayout.plRelatedType)
                    && treeQueryObject.getConditionMap().getOrDefault("context","").equals(allPLUILayout.plCode)){
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIEngineServiceImpl.java
@@ -894,7 +894,7 @@
     */
    @VciUnLog
    @Override
    public UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail,Map<String, RoleRightVO> roleRightMap){
    public UIContentVO UIContentDO2VO(PLUILayout pageLayoutDefination, boolean queryDetail,Map<String, List<RoleRightVO>> roleRightMap){
        UIContentVO contentVO = new UIContentVO();
        if(pageLayoutDefination !=null){
            contentVO.setOid(pageLayoutDefination.plOId);
@@ -1014,7 +1014,7 @@
     * @param pkContent UI上下文的主键
     * @return 上下文
     */
    private List<UILayoutVO> listLayoutByContent(String pkContent,Map<String, RoleRightVO> roleRightMap){
    private List<UILayoutVO> listLayoutByContent(String pkContent,Map<String, List<RoleRightVO>> roleRightMap){
        try {
            List<PLTabPage> tabPageList = Arrays.stream(platformClientUtil.getUIService().getPLTabPagesByPageDefinationOId(pkContent)).collect(Collectors.toList());
            //过滤掉没有访问权限的UI
@@ -1030,7 +1030,7 @@
     * @param tabPageList
     * @param roleRightMap
     */
    private List<PLTabPage> filterTabPageByRoleRight(List<PLTabPage> tabPageList, Map<String, RoleRightVO> roleRightMap){
    private List<PLTabPage> filterTabPageByRoleRight(List<PLTabPage> tabPageList, Map<String, List<RoleRightVO>> roleRightMap){
        if(Func.isEmpty(roleRightMap) || Func.isEmpty(tabPageList)){
            return tabPageList;
        }
@@ -1060,7 +1060,7 @@
     * @param plPageDefinationList
     * @param roleRightMap
     */
    private List<PLPageDefination> filterPageDefByRoleRight(List<PLPageDefination> plPageDefinationList, Map<String, RoleRightVO> roleRightMap){
    private List<PLPageDefination> filterPageDefByRoleRight(List<PLPageDefination> plPageDefinationList, Map<String, List<RoleRightVO>> roleRightMap){
        if(Func.isEmpty(roleRightMap) || Func.isEmpty(plPageDefinationList)){
            return plPageDefinationList;
        }
@@ -1136,7 +1136,7 @@
     * @param pages 区域的数据对象
     * @return 显示对象
     */
    private List<UILayoutVO> UILayoutDO2VOs(Collection<PLTabPage> pages, boolean queryDetail, Map<String, RoleRightVO> roleRightMap){
    private List<UILayoutVO> UILayoutDO2VOs(Collection<PLTabPage> pages, boolean queryDetail, Map<String, List<RoleRightVO>> roleRightMap){
        List<UILayoutVO> contentVOS = new ArrayList<>();
        Map<String, OsAttributeVO> attributeVOMap;
        if(pages != null && pages.size() > 0){
@@ -1174,7 +1174,7 @@
     * @return 区域的显示对象
     */
    @VciUnLog
    private UILayoutVO UILayoutDO2VO(PLTabPage page, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, RoleRightVO> roleRightMap){
    private UILayoutVO UILayoutDO2VO(PLTabPage page, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
        UILayoutVO layoutVO = new UILayoutVO();
        if(page !=null ){
            layoutVO.setOid(page.plOId);
@@ -1274,7 +1274,7 @@
     * @param pages 数据对象
     * @return 显示对象
     */
    private List<UIComponentVO> uiComponentDO2VOs(Collection<PLPageDefination> pages, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, RoleRightVO> roleRightMap){
    private List<UIComponentVO> uiComponentDO2VOs(Collection<PLPageDefination> pages, boolean queryDetail,Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
        List<UIComponentVO> componentVOS = new ArrayList<>();
        pages.stream().forEach(page->{
            componentVOS.add(uiComponentDO2VO(page,queryDetail,attributeVOMap,roleRightMap));
@@ -1288,7 +1288,7 @@
     * @return 显示对象
     */
    @VciUnLog
    private UIComponentVO uiComponentDO2VO(PLPageDefination page, boolean queryDetail, Map<String, OsAttributeVO> attributeVOMap, Map<String, RoleRightVO> roleRightMap){
    private UIComponentVO uiComponentDO2VO(PLPageDefination page, boolean queryDetail, Map<String, OsAttributeVO> attributeVOMap, Map<String, List<RoleRightVO>> roleRightMap){
        UIComponentVO componentVO = new UIComponentVO();
        if(page !=null){
            componentVO.setOid(page.plOId);
@@ -1466,7 +1466,7 @@
     * @return 按钮的信息
     */
    @Override
    public List<UIButtonDefineVO> listButtonByComponent(String pkComponent, Map<String, RoleRightVO> roleRightMap){
    public List<UIButtonDefineVO> listButtonByComponent(String pkComponent, Map<String, List<RoleRightVO>> roleRightMap){
        try {
            List<UIButtonDefineVO> buttonDefineVOS = buttonDO2VOs(Arrays.stream(platformClientUtil.getUIService().getPLTabButtonsByTableOId(pkComponent)).collect(Collectors.toSet())).stream().sorted(((o1, o2) -> o1.getOrderNum().compareTo(o2.getOrderNum()))).collect(Collectors.toList());
            if(Func.isEmpty(roleRightMap)){
@@ -1478,12 +1478,20 @@
            while (buttonDefineVO.hasNext()){
                UIButtonDefineVO buttonDefine = buttonDefineVO.next();
                if(roleRightMap.containsKey(buttonDefine.getPkComponent())) {
                    Long rightValue = roleRightMap.get(buttonDefine.getPkComponent()).getRightValue();
                    List<Long> rightValues = roleRightMap.get(buttonDefine.getPkComponent()).stream()
                            .map(e -> e.getRightValue()).collect(Collectors.toList());
                    int nodeValue = buttonDefine.getOrderNum();
                    if (nodeValue >= 0 && nodeValue <= 63) {
                        boolean authFlag = false;
                        //进行位与操作,如果相等则表示具有当前操作的权限
                        for (Long rightValue : rightValues) {
                        long preValue = (rightValue >> nodeValue) & 1;
                        if (preValue != 1) {
                            if (preValue == 1) {
                                authFlag = true;
                                break;
                            }
                        }
                        if(!authFlag){
                            buttonDefineVO.remove();
                        }
                    }
@@ -1642,7 +1650,7 @@
            throw WebUtil.getVciBaseException(vciError);
        }
        // 1、根据当前角色判断是管理人员还是普通用户(正常来说只有普通用户才会用到该查询接口)
        Map<String, RoleRightVO> roleRightMap = uiManagerServiceI.getRoleRightMap(null);
        Map<String, List<RoleRightVO>> roleRightMap = uiManagerServiceI.getRoleRightMap(null);
        // 2、按照当前登录用户查询权限(功能权限和UI授权的授权信息都是放在同一张表里的)
        // 3、找出当前要查询的UI上下文
        PLUILayout context = null;
Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
@@ -1696,7 +1696,7 @@
        String type = StringUtils.isBlank(conditionMap.get("type")) ? "" : conditionMap.get("type");
        String context = StringUtils.isBlank(conditionMap.get("context")) ? "" : conditionMap.get("context");
        boolean showCheckBox = Boolean.parseBoolean(conditionMap.get("showCheckBox"));
        Map<String,RoleRightVO> roleRightVOMap = new HashMap<>();
        Map<String, List<RoleRightVO>> roleRightVOMap = new HashMap<>();
        if(StringUtils.isNotBlank(roleId)){
            roleRightVOMap = this.getRoleRightMap(roleId);
        }
@@ -1734,7 +1734,7 @@
     * @throws PLException
     */
    @Override
    public Map<String,RoleRightVO> getRoleRightMap(String roleId) throws PLException {
    public Map<String, List<RoleRightVO>> getRoleRightMap(String roleId) throws PLException {
        RoleRightInfo[] rightInfos = null;
        String userName = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId();
        if(Func.isBlank(roleId)){
@@ -1743,7 +1743,9 @@
            rightInfos = platformClientUtil.getFrameworkService().getRoleRightList(roleId,userName);
        }
        List<RoleRightVO> roleRightVOList = roleRightDOO2VOS(Arrays.asList(rightInfos));
        Map<String,RoleRightVO> roleRightVOMap = roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO,(oldValue,newOldValue)->oldValue));
        //分组操作
        Map<String, List<RoleRightVO>> roleRightVOMap = roleRightVOList.stream().collect(Collectors.groupingBy(RoleRightVO::getFuncId,
                Collectors.mapping(e ->e, Collectors.toList())));
        return roleRightVOMap;
    }
@@ -2145,7 +2147,7 @@
     * @param contextList
     * @param isShowCheckBox
     */
    private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap, boolean isShowCheckBox){
    private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String, List<RoleRightVO>> roleRightVOMap, boolean isShowCheckBox){
        Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<>()).stream().forEach(pTree -> {
            Object funcObj = pTree.getData();
            List<Tree> chiledTreeList = new ArrayList<>();
@@ -2224,7 +2226,7 @@
                PLTabButton plTabButton = (PLTabButton) funcObj;
                String id = plTabButton.plTableOId;
                if(roleRightVOMap.containsKey(id)){
                    RoleRightVO roleRightVO = roleRightVOMap.get(id);
                    RoleRightVO roleRightVO = roleRightVOMap.get(id).get(0);
                    Long rightValue = roleRightVO.getRightValue();
                    int nodeValue = plTabButton.plSeq;
                    if (nodeValue >= 0 && nodeValue <= 63) {