diff --git a/src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java b/src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..c90e3e445660af38a92aba009f587c990917ad3b --- /dev/null +++ b/src/main/java/com/pms/ocp/common/utils/RandomStringUtil.java @@ -0,0 +1,29 @@ +package com.pms.ocp.common.utils; + + +import org.apache.commons.lang3.RandomStringUtils; + +import java.util.Random; + +/** + * @author zhaochengming + * 随机生成字符串 + */ +public class RandomStringUtil { + + /** + * length 字符串长度 + * @param length + * @return + */ + public static String getRandomString(int length){ + String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + Random random=new Random(); + StringBuffer sb=new StringBuffer(); + for(int i=0;i { */ - void updataOcpTree(OcpApiGroup ocpApiGroup); + boolean updataOcpTree(OcpApiGroup ocpApiGroup); /** * 删除服务分类 diff --git a/src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java b/src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java index a5e2f49b094c2362c4180d7ebf38ec5c285533f0..17ed992a69becf2efe48dd6970577e6b6697e9fd 100644 --- a/src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java +++ b/src/main/java/com/pms/ocp/service/impl/OcpApiTreeServiceImpl.java @@ -1,12 +1,14 @@ package com.pms.ocp.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.pms.ocp.common.utils.RandomStringUtil; import com.pms.ocp.mapper.OcpApiBaseMapper; import com.pms.ocp.mapper.OcpApiTreeMapper; import com.pms.ocp.model.dto.*; import com.pms.ocp.model.entity.OcpApiBase; import com.pms.ocp.model.entity.OcpApiGroup; import com.pms.ocp.service.OcpApiTreeService; +import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +42,7 @@ public class OcpApiTreeServiceImpl extends ServiceImpl oneTreeUpLists = new ArrayList<>(); for (OcpApiGroup ocpApiGroup : ocpApiGroups) { @@ -49,10 +51,9 @@ public class OcpApiTreeServiceImpl extends ServiceImpl twoDownLists = twoTreeLists(oneTreeUpLists, ocpApiGroups); List threeTreeLists = threeTreeLists(twoDownLists, ocpApiGroups); - apiTreeGroupList.setOneupList(oneTreeUpLists); + apiTreeGroupList.setOneList(oneTreeUpLists); apiTreeGroupList.setTwoList(twoDownLists); apiTreeGroupList.setThreeList(threeTreeLists); @@ -68,55 +69,68 @@ public class OcpApiTreeServiceImpl extends ServiceImpl twoTreeLists(List oneTreeUpLists,List ocpApiGroups){ + List twolists = new ArrayList<>(); List twoTreeLists = new ArrayList<>(); - - //服务树全表数据 - - for (OneTreeUpList oneTreeUpList : oneTreeUpLists) { - String code = oneTreeUpList.getApiGroupCode(); - for (OcpApiGroup ocpApiGroup : ocpApiGroups ) { - if (code.equals(ocpApiGroup.getApiGroupPcode())) { - TwoDownList twoDownList = new TwoDownList(); - BeanUtils.copyProperties(ocpApiGroup,twoDownList); - twoTreeLists.add(twoDownList); - - } + for (OcpApiGroup ocpApiGroup : ocpApiGroups) { + if (!(ocpApiGroup.getIsDelete() == 0)){ + if (ocpApiGroup.getApiGroupLevel() == 2){ + twolists.add(ocpApiGroup); + }else { + continue; + } } } - + BeanUtils.copyProperties(twolists,twoTreeLists); return twoTreeLists; } /** - * 三级目录 + * 3服务组层 * @param twoDownLists * @return */ public List threeTreeLists(List twoDownLists,List ocpApiGroups){ List threeTreeLists = new ArrayList<>(); - - - for (TwoDownList twoDownList : twoDownLists) { + List threeLists = new ArrayList<>(); for (OcpApiGroup ocpApiGroup : ocpApiGroups) { - String code = twoDownList.getApiGroupCode(); - if (code.equals(ocpApiGroup.getApiGroupPcode())){ - ThreeTreeList threeTreeList = new ThreeTreeList(); - BeanUtils.copyProperties(ocpApiGroup,threeTreeList); - threeTreeLists.add(threeTreeList); - /* threeTreeList.setThreeList(ocpApiGroup); - threeTreeLists.add(threeTreeList);*/ + if (!(ocpApiGroup.getIsDelete() == 0)) { + if (ocpApiGroup.getApiGroupLevel() == 3){ + threeLists.add(ocpApiGroup); + } + }else { + continue; } - } - + BeanUtils.copyProperties(threeLists,threeTreeLists); } return threeTreeLists; + } + /** + * 4服务层 + * @param threeTreeLists + * @return + */ + public List fourTreeLists(List threeTreeLists,List ocpApiGroups){ + List foureTreeList = new ArrayList<>(); + List foureLists = new ArrayList<>(); + for (OcpApiGroup ocpApiGroup : ocpApiGroups) { + if (!(ocpApiGroup.getIsDelete() == 0)) { + if (ocpApiGroup.getApiGroupLevel() == 4){ + foureLists.add(ocpApiGroup); + } + }else { + continue; + } + BeanUtils.copyProperties(foureLists,foureTreeList); + } + return foureTreeList; + } /** @@ -127,6 +141,8 @@ public class OcpApiTreeServiceImpl extends ServiceImpl ocpApiGroups = mapper.selectList(null); for (OcpApiGroup ocpApiGroup : ocpApiGroups) { @@ -139,16 +155,17 @@ public class OcpApiTreeServiceImpl extends ServiceImpl ocpApiGroups = mapper.selectList(null); + for (OcpApiGroup apiGroup : ocpApiGroups) { + String code = apiGroup.getApiGroupCode(); + if (code == ocpApiGroup.getApiGroupCode()){ + falg = false; + break; + } + } mapper.updateById(ocpApiGroup); + return falg; } @@ -179,7 +206,6 @@ public class OcpApiTreeServiceImpl extends ServiceImpl