Explorar o código

区域信息修改为数据库

hexiao hai 1 ano
pai
achega
0e069ff25f

+ 7 - 4
application-webadmin/src/main/java/com/ankaibei/workFlow/webadmin/api/AreaApiService.java

@@ -38,15 +38,18 @@ public class AreaApiService implements AreaApi {
     @RequestMapping("/getProvinces")
     public List<AreaInfo> getProvinces() {
 
-        QueryWrapper<SysRegion> qw = new QueryWrapper();
-        qw.eq("level", "province");
-        List<SysRegion> list = sysRegionService.list(qw);
+
+        List<SysRegion> list = sysRegionService.list();
         if (!Collections.isEmpty(list)) {
-            return list.stream().map(o -> {
+            List<AreaInfo> collect = list.stream().filter(o->o.getName().equals("中华人民共和国")).map(o -> {
                 AreaInfo areaInfo = new AreaInfo();
                 BeanUtils.copyProperties(o, areaInfo);
                 return areaInfo;
             }).collect(Collectors.toList());
+            List<SysRegion> listAll = sysRegionService.list();
+            List<AreaInfo> areaInfos = buildData(collect, listAll);
+            // 构建树
+            return buildTree(areaInfos, listAll);
         }
         return new ArrayList<>();
 //        return GaoDeWebUtil.getProvinces();