From 2a06a2a8aed92fd2eb4b4570b79f304a1c0caf6d Mon Sep 17 00:00:00 2001 From: yuxc <yuxc@vci-tech.com> Date: 星期四, 12 九月 2024 09:39:37 +0800 Subject: [PATCH] 1、Action树查询接口增加id。 2、增加角色列表接口 --- Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java | 296 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 267 insertions(+), 29 deletions(-) diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java index 137973d..408a5c2 100644 --- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java +++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java @@ -8,11 +8,9 @@ import com.vci.corba.portal.data.*; import com.vci.dto.RoleRightDTO; import com.vci.dto.UIAuthorDTO; +import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; import com.vci.model.PLDefination; -import com.vci.pagemodel.PLDefinationVO; -import com.vci.pagemodel.PLTabButtonVO; -import com.vci.pagemodel.PLUILayoutCloneVO; -import com.vci.pagemodel.RoleRightVO; +import com.vci.pagemodel.*; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.*; import com.vci.starter.web.pagemodel.BaseQueryObject; @@ -33,11 +31,13 @@ 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; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.swing.*; +import javax.swing.tree.TreePath; import java.io.IOException; import java.util.*; import java.util.stream.Collectors; @@ -56,6 +56,12 @@ */ @Resource private PlatformClientUtil platformClientUtil; + + /*** + * 鏄惁鏄鐞嗗憳 + */ + @Autowired + RightControlUtil rightControlUtil; /** * 涓氬姟绫诲瀷 @@ -686,13 +692,22 @@ * @return */ @Override - public List<PLTabButtonVO> getTabButton(String pageDefinationOid) { + public List<PLTabButtonVO> getTabButtons(String pageDefinationOid) { VciBaseUtil.alertNotNull(pageDefinationOid,"椤甸潰瀹氫箟涓婚敭"); List<PLTabButton> buttonList = new ArrayList<>(); try { PLTabButton[] plTabButtons = platformClientUtil.getUIService().getPLTabButtonsByTableOId(pageDefinationOid); buttonList = Arrays.asList(plTabButtons); - return this.tabButton2TabButtonVOS(buttonList); + List<PLTabButtonVO> plTabButtonVOList = this.tabButton2TabButtonVOS(buttonList); + PLTabButtonVO plTabButtonVO = new PLTabButtonVO(); + for(int i = 0; i < plTabButtonVOList.size(); i++){ + plTabButtonVO = plTabButtonVOList.get(i); + + if(plTabButtonVO.getParentOid().equals("")){ + plTabButtonVO.setChildren(plTabButtonVO2Children(plTabButtonVOList,plTabButtonVO.getOId())); + } + } + return plTabButtonVOList; } catch (Exception e) { e.printStackTrace(); throw new VciBaseException("鍔犺浇椤电鍖哄煙鎸夐挳閰嶇疆淇℃伅寮傚父锛�" + e.getMessage()); @@ -759,6 +774,26 @@ plTabButtonVO.setButtonParams(parameterMap); } return plTabButtonVO; + } + + /** + * 鎸夐挳閰嶇疆瀛愯妭鐐规煡鎵� + * @param plOid + * @param plTabButtonVOList + * @return + */ + private List<PLTabButtonVO> plTabButtonVO2Children(List<PLTabButtonVO> plTabButtonVOList, String plOid){ + ArrayList<PLTabButtonVO> plTabButtonVOS = new ArrayList<>(); + for (PLTabButtonVO plTabButtonVO : plTabButtonVOList) { + if(StringUtils.isBlank(plTabButtonVO.getParentOid())){ + continue; + } + if(plTabButtonVO.getParentOid().equals(plOid)){ + plTabButtonVO.setChildren(plTabButtonVO2Children(plTabButtonVOList,plOid)); + plTabButtonVOS.add(plTabButtonVO); + } + } + return plTabButtonVOS; } /** @@ -896,7 +931,71 @@ return true; } + /** + * 鍒犻櫎鍗曚釜鎸夐挳閰嶇疆 + * @param tabButton + * @return + */ + @Override + public boolean deleteTapButton(PLTabButton tabButton) throws PLException { + VciBaseUtil.alertNotNull(tabButton,"鍒犻櫎鐨勬寜閽厤缃璞�"); + boolean success = UITools.getService().deletePLTabButton(tabButton); + if(success == false){ + throw new VciBaseException("璇ユ湁瀛愮骇鎸夐挳锛屼笉鑳藉垹闄わ紒"); + } + return true; + } + /** + * 璋冩暣涓轰笅绾ф寜閽� + * @param plTabButton + * @return + */ + @Override + public BaseResult joinBtn(PLTabButton plTabButton) throws PLException { + VciBaseUtil.alertNotNull(plTabButton,"闇�璋冩暣涓轰笅绾ф寜閽�",plTabButton.plTableOId,"褰撳墠鎸夐挳閰嶇疆鎵�鍦ㄧ殑椤甸潰涓婚敭"); + //鍚屼竴椤甸潰涓嬬殑鎸夐挳 + List<PLTabButtonVO> plTabButtons = this.getTabButtons(plTabButton.plTableOId); + if(Func.isEmpty(plTabButtons)){ + return BaseResult.fail("鏈幏鍙栧埌鎸夐挳閰嶇疆淇℃伅锛�"); + } + //鑾峰彇褰撳墠瑕佺Щ鍔ㄧ殑鎸夐挳鐨勪笅鏍� + int index = 0; + for (int i = 0; i < plTabButtons.size(); i++) { + if (plTabButtons.get(i).getOId().equals(plTabButton.plOId)) { + index = i; // 鎵惧埌鍚庤褰曚笅鏍� + break; // 鎵惧埌鍚庨��鍑哄惊鐜� + } + } + //褰撻�夋嫨鐨勬寜閽负鏍戠殑绗竴涓妭鐐圭殑鏃跺�欙紝浠栫殑鍏勮妭鐐规槸浠栬嚜宸憋紝瀵艰嚧璋冩暣涓轰笅绾ф寜閽椂鍑洪敊锛屾晠浣滄鍒ゆ柇銆� + if(index == 0){ + return BaseResult.fail("褰撳墠鑺傜偣涓嶅瓨鍦ㄥ厔鑺傜偣锛屾棤娉曡皟鏁翠负涓嬬骇鎸夐挳锛�"); + } + //璁剧疆鐖秈d涓轰笂涓�涓妭鐐圭殑 + plTabButton.plParentOid = plTabButtons.get(index-1).getOId(); + + boolean success = platformClientUtil.getUIService().updatePLTabButton(plTabButton); + if(success == false) { + return BaseResult.fail("淇敼澶辫触锛�"); + } + return BaseResult.fail("淇敼鎴愬姛锛�"); + } + + /** + * 璋冩暣涓轰笂绾ф寜閽� + * @param plTabButton + * @return + */ + @Override + public BaseResult exitBtn(PLTabButton plTabButton) throws PLException { + plTabButton.plParentOid = ""; + + boolean success = platformClientUtil.getUIService().updatePLTabButton(plTabButton); + if(success == false) { + BaseResult.fail("鎾ら攢澶辫触锛�"); + } + return BaseResult.success("鎾ら攢鎴愬姛锛�"); + } /** * 澶勭悊閰嶇疆鐨別vent浜嬩欢 @@ -1093,6 +1192,12 @@ return treeList; } + /*** + * UI鎺堟潈 + * @param uiAuthorDTO + * @return + * @throws Exception + */ @Override public boolean authorizedUI(UIAuthorDTO uiAuthorDTO) throws Exception { boolean res=false; @@ -1108,41 +1213,41 @@ 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) {//鎸夐挳 } @@ -1150,6 +1255,138 @@ + } + + /** + * 鑾峰彇鏉冮檺 + * @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; } /** @@ -1166,6 +1403,7 @@ } }); } + private void setChildNode(List<Tree> parentTree, List<PLUILayout>contextList,Map<String,RoleRightVO> roleRightVOMap,boolean isShowCheckBox){ Optional.ofNullable(parentTree).orElseGet(()->new ArrayList<Tree>()).stream().forEach(pTree -> { Object funcObj= pTree.getData(); -- Gitblit v1.9.3