Przeglądaj źródła

省市县查询时,如果市下面没有县,则自动添加市辖区

沈静伟 3 lat temu
rodzic
commit
69a9082ec2

+ 13 - 3
src/rest/openapi/restcontroller/wechatapp/system/countryareaid.java

@@ -29,7 +29,12 @@ public class countryareaid extends Controller {
             for (Row cityrow : cityrows) {
             for (Row cityrow : cityrows) {
                 String city = cityrow.getString("city");
                 String city = cityrow.getString("city");
                 Rows countyrows = countyrowsMap.get(province + city);
                 Rows countyrows = countyrowsMap.get(province + city);
-                cityrow.put("county", countyrows.removeColumn(new String[]{"province", "city"}).toArray("county"));
+                if (countyrows.isEmpty()) {
+                    String[] countys = new String[]{"ÊÐÏ½Çø"};
+                    cityrow.put("county", countys);
+                } else {
+                    cityrow.put("county", countyrows.removeColumn(new String[]{"province", "city"}).toArray("county"));
+                }
             }
             }
             provincerow.put("city", cityrows.removeColumn(new String[]{"province"}));
             provincerow.put("city", cityrows.removeColumn(new String[]{"province"}));
         }
         }
@@ -50,11 +55,16 @@ public class countryareaid extends Controller {
             for (Row cityrow : cityrows) {
             for (Row cityrow : cityrows) {
                 String city = cityrow.getString("city");
                 String city = cityrow.getString("city");
                 Rows countyrows = countyrowsMap.get(province + city);
                 Rows countyrows = countyrowsMap.get(province + city);
-                cityrow.put("county", countyrows.removeColumn(new String[]{"province", "city"}).toArray("county"));
+                if (countyrows.isEmpty()) {
+                    String[] countys = new String[]{"ÊÐÏ½Çø"};
+                    cityrow.put("county", countys);
+                } else {
+                    cityrow.put("county", countyrows.removeColumn(new String[]{"province", "city"}).toArray("county"));
+                }
             }
             }
             provincerow.put("city", cityrows.removeColumn(new String[]{"province"}));
             provincerow.put("city", cityrows.removeColumn(new String[]{"province"}));
         }
         }
 
 
-        return getReturnObject_suc(provincerows,true).toString();
+        return getReturnObject_suc(provincerows, true).toString();
     }
     }
 }
 }