Parcourir la source

区域信息修改为数据库

hexiao il y a 1 an
Parent
commit
6d1a63e017

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

@@ -28,7 +28,19 @@ public class AreaApiService implements AreaApi {
     @Override
     @RequestMapping("/getInfoLikeKeywordsAndSubdistrict")
     public List<AreaInfo> getInfoLikeKeywordsAndSubdistrict(String keywords, Integer subdistrict) {
-        return GaoDeWebUtil.getInfoLikeKeywordsAndSubdistrict(keywords, subdistrict);
+        List<SysRegion> list = sysRegionService.list();
+        if (!Collections.isEmpty(list)) {
+            List<AreaInfo> collect = list.stream().filter(o->o.getAdcode().equals(keywords) || o.getName().contains(keywords)).map(o -> {
+                AreaInfo areaInfo = new AreaInfo();
+                BeanUtils.copyProperties(o, areaInfo);
+                return areaInfo;
+            }).collect(Collectors.toList());
+            List<AreaInfo> areaInfos = buildData(collect, list);
+            // 构建树
+            return buildTree(areaInfos, list);
+        }
+        return new ArrayList<>();
+//        return GaoDeWebUtil.getInfoLikeKeywordsAndSubdistrict(keywords, subdistrict);
     }
 
     /**
@@ -46,10 +58,9 @@ public class AreaApiService implements AreaApi {
                 BeanUtils.copyProperties(o, areaInfo);
                 return areaInfo;
             }).collect(Collectors.toList());
-            List<SysRegion> listAll = sysRegionService.list();
-            List<AreaInfo> areaInfos = buildData(collect, listAll);
+            List<AreaInfo> areaInfos = buildData(collect, list);
             // 构建树
-            return buildTree(areaInfos, listAll);
+            return buildTree(areaInfos, list);
         }
         return new ArrayList<>();
 //        return GaoDeWebUtil.getProvinces();