diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java index a597d37d..97839c8a 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommunityServiceImpl.java @@ -22,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.util.*; /** * @author yuyang @@ -62,11 +59,15 @@ public class XhpcCommunityServiceImpl extends BaseService implements IXhpcCommun } } - for (Map commMap: list){ - List> userMapList = xhpcCommunityMapper.communityPersonnelTree(commMap.get("id").toString().replaceAll("COMM_", "")); - if(userMapList.size() > 0){ - commMap.put("children", userMapList); - } + Iterator> iterator = list.iterator(); + while (iterator.hasNext()){ + Map commMap = iterator.next(); + List> userMapList = xhpcCommunityMapper.communityPersonnelTree(commMap.get("id").toString().replaceAll("COMM_", "")); + if (userMapList.size() < 1){ + iterator.remove(); + } else { + commMap.put("children", userMapList); + } } return list; } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java index 918406a7..86f73756 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCustomersServiceImpl.java @@ -38,7 +38,7 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom @Override public List> userList(HttpServletRequest request,String name){ - List> list =new ArrayList<>(); + List> list = new ArrayList<>(); LoginUser loginUser = tokenService.getLoginUser(request); String userType = loginUser.getSysUser().getUserType(); if(UserTypeUtil.SYS_USER_TYPE_ZERO.equals(userType)){ @@ -47,13 +47,16 @@ public class XhpcCustomersServiceImpl extends BaseService implements IXhpcCustom list = xhpcCustomersMapper.tree(name,loginUser.getSysUser().getOperatorId(),loginUser.getTenantId()); } - for(Map cusMap: list){ + Iterator> iterator = list.iterator(); + while (iterator.hasNext()){ + Map cusMap = iterator.next(); List> userList = xhpcCustomersMapper.customersPersonnelTree(cusMap.get("id").toString().replaceAll("CUS_", "")); - if (userList.size() > 0){ + if (userList.size() < 1){ + iterator.remove(); + } else { cusMap.put("children", userList); } } - return list; }