Преглед изворни кода

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

沈静伟 пре 3 година
родитељ
комит
69a9082ec2
1 измењених фајлова са 13 додато и 3 уклоњено
  1. 13 3
      src/rest/openapi/restcontroller/wechatapp/system/countryareaid.java

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

@@ -29,7 +29,12 @@ public class countryareaid extends Controller {
             for (Row cityrow : cityrows) {
                 String city = cityrow.getString("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"}));
         }
@@ -50,11 +55,16 @@ public class countryareaid extends Controller {
             for (Row cityrow : cityrows) {
                 String city = cityrow.getString("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"}));
         }
 
-        return getReturnObject_suc(provincerows,true).toString();
+        return getReturnObject_suc(provincerows, true).toString();
     }
 }