Ver código fonte

获取所有子区域

master
WendyYang 1 ano atrás
pai
commit
baa4f39d3f
2 arquivos alterados com 21 adições e 0 exclusões
  1. +10
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java
  2. +11
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java

+ 10
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/RegionCacheHelper.java Ver arquivo

@@ -54,6 +54,16 @@ public interface RegionCacheHelper {
List<RegionDTO> listParents(String code, int level);

/**
* 根据传入的地区code与level获取所有子区域集合
*
* @param code 地域编码
* @param level 地域层级
* @return 所有子区域(包含自己)
* @author WendyYang
**/
List<RegionDTO> listChildren(String code, int level);

/**
* 获取当前区域所有的子区域(包括自己)
*
* @param code 区域编码


+ 11
- 0
pmapi/src/main/java/com/ningdatech/pmapi/common/helper/impl/RegionsCacheHelperImpl.java Ver arquivo

@@ -170,4 +170,15 @@ public class RegionsCacheHelperImpl extends AbstractRegionCacheHelper implements
return result;
}

@Override
public List<RegionDTO> listChildren(String code, int level) {
RegionDTO curr = getByCodeAndLevel(code, level);
if (curr.getParentCode().equals(curr.getRegionCode())) {
return Collections.singletonList(curr);
}
return all().stream()
.filter(w -> StrUtils.split(w.getRegionCodePath()).contains(code))
.collect(Collectors.toList());
}

}

Carregando…
Cancelar
Salvar