| | |
| | | import lombok.NoArgsConstructor; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | */ |
| | | @Resource |
| | | private SmRoleQueryServiceI smRoleQueryServiceI; |
| | | |
| | | /*** |
| | | * æ¯å¦æ¯ç®¡çå |
| | | */ |
| | | @Autowired |
| | | RightControlUtil rightControlUtil; |
| | | /** |
| | | * ä¸å¡ç±»å |
| | | */ |
| | |
| | | return treeList; |
| | | } |
| | | |
| | | /*** |
| | | * UIææ |
| | | * @param uiAuthorDTO |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public boolean authorizedUI(UIAuthorDTO uiAuthorDTO) throws Exception { |
| | | boolean res=false; |
| | |
| | | treeQueryObject.setConditionMap(conditionMap); |
| | | List<Tree> treeList=this.getUIAuthor(treeQueryObject); |
| | | HashMap<String,Tree> allTreeMap=new HashMap<>(); |
| | | Map<String,RoleRightVO> roleRightVOMap=new HashMap<>(); |
| | | if(!CollectionUtil.isEmpty(treeList)){ |
| | | if(StringUtils.isNotBlank(uiAuthorDTO.getRoleId())){ |
| | | String userName= WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | RoleRightInfo[] rightInfos= platformClientUtil.getFrameworkService().getRoleRightList(uiAuthorDTO.getRoleId(),userName); |
| | | List<RoleRightVO> roleRightVOList=roleRightDOO2VOS(Arrays.asList(rightInfos)); |
| | | roleRightVOMap=roleRightVOList.stream().collect(Collectors.toMap(RoleRightVO::getFuncId,roleRightVO ->roleRightVO)); |
| | | } |
| | | convertTreeDOO2Map(treeList,allTreeMap); |
| | | List<RoleRightDTO> roleRightDTOList=new ArrayList<>(); |
| | | List<Tree> selectTreeList= uiAuthorDTO.getSelectTreeList(); |
| | | getRoleRightDTOS(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); |
| | | getSelectedRoleRightObjs(uiAuthorDTO.getRoleId(),selectTreeList,allTreeMap,roleRightDTOList); |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | private void getRoleRightDTOS(String roleOid,List<Tree> selectTreeList,HashMap<String,Tree> allTreeMap, List<RoleRightDTO> roleRightDTOList){ |
| | | /** |
| | | * |
| | | * @param roleOid |
| | | * @param selectTreeList |
| | | * @param allTreeMap |
| | | * @param roleRightDTOList |
| | | */ |
| | | private void getSelectedRoleRightObjs(String roleOid,List<Tree> selectTreeList,HashMap<String,Tree> allTreeMap, List<RoleRightDTO> roleRightDTOList){ |
| | | Date date=new Date(); |
| | | Map<String,RoleRightDTO> roleRightDTOMap=new HashMap<>(); |
| | | selectTreeList.stream().forEach(tree -> { |
| | | RoleRightDTO roleRightDTO=new RoleRightDTO(); |
| | | String id=ObjectUtility.getNewObjectID36(); |
| | | Object data= tree.getData(); |
| | | |
| | | if (data instanceof BizType) {//ä¸å¡ç±»å |
| | | BizType bizType=(BizType)data; |
| | | roleRightDTO.setId(id);//ä¸»é® |
| | | roleRightDTO.setCreateUser(null);//å建è
|
| | | roleRightDTO.setCreateTime(null);//å建æ¶é´ |
| | | roleRightDTO.setModifyUser(null);//ä¿®æ¹è
|
| | | roleRightDTO.setModifyTime(null);//ä¿®æ¹æ¶é´ |
| | | roleRightDTO.setRoleId(roleOid);//è§è²ID |
| | | roleRightDTO.setRightValue(1);// æéå¼ |
| | | roleRightDTO.setRightType((short) -1);//æéç±»å æéç±»åï¼è¶
级管çåç»ç®¡çåææä¸º1ï¼ç®¡çåç»æ®éç¨æ·ææä¸º2 |
| | | roleRightDTO.setFuncId(null); |
| | | roleRightDTO.setLicensor(null); |
| | | }else if (data instanceof PLUILayout){//UI |
| | | |
| | | }else if (data instanceof PLTabPage) {//UIä¸ä¸æ |
| | | |
| | | |
| | | }else if (data instanceof PLPageDefination) {// |
| | | |
| | | |
| | | if(data instanceof String){ |
| | | getRightValue(roleOid,tree,allTreeMap,false,roleRightDTOMap);//åä¸è·åæææ¨¡åçæéå¼ |
| | | }else if (!(data instanceof PLTabButton)) {//ä¸å¡ç±»å |
| | | getRightValue(roleOid,tree,allTreeMap,true,roleRightDTOMap);//åä¸å¤ç |
| | | getRightValue(roleOid,tree,allTreeMap,false,roleRightDTOMap);//åä¸å¤çï¼å
å«å½åèç¹ï¼ |
| | | }else if (data instanceof PLTabButton) {//æé® |
| | | |
| | | } |
| | |
| | | |
| | | |
| | | } |
| | | /** |
| | | * è·åæé |
| | | * @param isUp æ¯å¦æ¯åä¸è·åï¼å¦ææ¯åä¸è·åï¼ä¼ è¿æ¥çå¿
ç¶æ¯æ¨¡åèç¹ï¼ä¸ä¸çº§æ¨¡åå¿
ç¶æ¯æ²¡æéä¸ |
| | | */ |
| | | private void getRightValue(String roleId,Tree node,HashMap<String,Tree> allTreeMap,boolean isUp,Map<String,RoleRightDTO> rightMap){ |
| | | SessionInfo sessionInfo = WebThreadLocalUtil.getCurrentUserSessionInfoInThread(); |
| | | String currentUserName = sessionInfo.getUserId(); |
| | | boolean isDeveloper= rightControlUtil.isDeveloper(currentUserName); |
| | | String parentOid=node.getParentId(); |
| | | if(allTreeMap.containsKey(parentOid)){ |
| | | String id=ObjectUtility.getNewObjectID36(); |
| | | Tree parentNode =allTreeMap.get(parentOid); |
| | | Object parentData= parentNode.getData(); |
| | | if(isUp) {//åä¸è·åï¼å卿¯ä¸ªä¸çº§æ¨¡åçæéå¼ |
| | | while (!"root".equals(parentNode.getData())){ |
| | | String funcId = ""; |
| | | if (parentData instanceof BizType) { |
| | | BizType bizType = (BizType) parentData; |
| | | funcId = bizType.name; |
| | | } else if (parentData instanceof PLUILayout) { |
| | | PLUILayout context = (PLUILayout)parentData; |
| | | funcId = context.plOId; |
| | | } else if (parentData instanceof PLTabPage) { |
| | | PLTabPage tab = (PLTabPage) parentData; |
| | | funcId = tab.plOId; |
| | | } else if (parentData instanceof PLPageDefination){ |
| | | PLPageDefination pageDef = (PLPageDefination) parentData; |
| | | funcId = pageDef.plOId; |
| | | } else if (parentData instanceof PLTabButton) { |
| | | PLTabButton but = (PLTabButton)parentData; |
| | | funcId = but.plOId; |
| | | } |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setId(id);//ä¸»é® |
| | | roleRightDTO.setFuncId(funcId); |
| | | if(isDeveloper) { |
| | | roleRightDTO.setRightType((short) 1);//æéç±»å æéç±»åï¼è¶
级管çåç»ç®¡çåææä¸º1ï¼ç®¡çåç»æ®éç¨æ·ææä¸º2 |
| | | }else{ |
| | | roleRightDTO.setRightType((short) 2); |
| | | } |
| | | roleRightDTO.setRightValue(1);// æéå¼ï¼æ²¡ææä½ç模åæéå¼åå¨ä¸º0 |
| | | roleRightDTO.setRoleId(roleId);//è§è²ID |
| | | roleRightDTO.setCreateUser(currentUserName);//å建è
|
| | | roleRightDTO.setCreateTime(new Date());//å建æ¶é´ |
| | | roleRightDTO.setModifyUser(currentUserName);//ä¿®æ¹è
|
| | | roleRightDTO.setModifyTime(new Date());//ä¿®æ¹æ¶é´ |
| | | roleRightDTO.setLicensor(""); |
| | | if(!rightMap.containsKey(funcId)){ |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | } |
| | | }else{ |
| | | String funcId = ""; |
| | | if(parentData instanceof String){ |
| | | funcId = (String)parentData; |
| | | } else if (parentData instanceof BizType) { |
| | | BizType bizType = (BizType)parentData; |
| | | funcId = bizType.name; |
| | | } else if (parentData instanceof PLUILayout) { |
| | | PLUILayout context = (PLUILayout)parentData; |
| | | funcId = context.plOId; |
| | | } else if (parentData instanceof PLTabPage) { |
| | | PLTabPage tab = (PLTabPage) parentData; |
| | | funcId = tab.plOId; |
| | | } else if (parentData instanceof PLPageDefination){ |
| | | PLPageDefination pageDef = (PLPageDefination) parentData; |
| | | funcId = pageDef.plOId; |
| | | } else if (parentData instanceof PLTabButton) { |
| | | PLTabButton but = (PLTabButton)parentData; |
| | | funcId = but.plOId; |
| | | } |
| | | if(!(parentData instanceof PLPageDefination)) {//åèç¹ä¸æ¯æä½ |
| | | if(!rightMap.containsKey(funcId)&&!funcId.equals("root")){ |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setFuncId(funcId); |
| | | if(isDeveloper) { |
| | | roleRightDTO.setRightType((short) 1);//æéç±»å æéç±»åï¼è¶
级管çåç»ç®¡çåææä¸º1ï¼ç®¡çåç»æ®éç¨æ·ææä¸º2 |
| | | }else{ |
| | | roleRightDTO.setRightType((short) 2); |
| | | } |
| | | roleRightDTO.setRightValue(0);//没ææä½ç模åæéå¼åå¨ä¸º0 |
| | | roleRightDTO.setRoleId(roleId); |
| | | roleRightDTO.setCreateUser(currentUserName); |
| | | roleRightDTO.setCreateTime(new Date()); |
| | | roleRightDTO.setModifyUser(currentUserName); |
| | | roleRightDTO.setModifyTime(new Date()); |
| | | roleRightDTO.setLicensor(""); |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | for(int i = 0;i < parentNode.getChildren().size();i++){ |
| | | //对æ¯ä¸ªååä¸éå½éå |
| | | getRightValue(roleId,parentNode.getChildren().get(i),allTreeMap,false,rightMap); |
| | | } |
| | | }else { |
| | | if(!rightMap.containsKey(funcId)){ |
| | | RoleRightDTO roleRightDTO = new RoleRightDTO(); |
| | | roleRightDTO.setFuncId(funcId); |
| | | roleRightDTO.setRightType((short)2); // 设置UIæé |
| | | roleRightDTO.setRightValue(countRightValue(parentNode,true));//没ææä½ç模åæéå¼åå¨ä¸º0 |
| | | roleRightDTO.setRoleId(roleId); |
| | | |
| | | roleRightDTO.setCreateUser(currentUserName); |
| | | roleRightDTO.setCreateTime(new Date()); |
| | | roleRightDTO.setModifyUser(currentUserName); |
| | | roleRightDTO.setModifyTime(new Date()); |
| | | roleRightDTO.setLicensor(""); |
| | | rightMap.put(funcId, roleRightDTO); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | /** |
| | | * ä¼ å
¥ç´æ¥ææ¥æä½ç模åçèç¹,计ç®è¯¥èç¹çæéå¼ |
| | | * @param node 模åèç¹ |
| | | * @param isAll æ¯å¦å级å
¨é¨éä¸ |
| | | * @return |
| | | */ |
| | | private long countRightValue(Tree node,boolean isAll){ |
| | | long value = 0; |
| | | for(int i = 0;i < node.getChildren().size();i++){ |
| | | Tree childNode = (Tree)node.getChildren().get(i); |
| | | if(isAll && node.getData() instanceof PLTabButton ){ |
| | | PLTabButton obj = (PLTabButton)node.getData(); |
| | | value += (long)Math.pow(2, obj.plSeq);//累计å ä¸å个æä½çæéå¼ |
| | | } |
| | | } |
| | | return value; |
| | | } |
| | | |
| | | /** |
| | | * |