|
@@ -6,6 +6,8 @@ import com.huimv.farm.damsubsidy.common.utils.ResultCode;
|
|
import com.huimv.farm.damsubsidy.entity.*;
|
|
import com.huimv.farm.damsubsidy.entity.*;
|
|
import com.huimv.farm.damsubsidy.mapper.AreaByLevelMapper;
|
|
import com.huimv.farm.damsubsidy.mapper.AreaByLevelMapper;
|
|
import com.huimv.farm.damsubsidy.service.IAreaByLevelService;
|
|
import com.huimv.farm.damsubsidy.service.IAreaByLevelService;
|
|
|
|
+import net.sf.json.JSONArray;
|
|
|
|
+import net.sf.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -60,6 +62,43 @@ public class AreaByLevelServiceImpl implements IAreaByLevelService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public Result treeOfTongWei() {
|
|
|
|
+ AreaAll province = new AreaAll("62", "甘肃省", "1+", "2+", null),
|
|
|
|
+ city = new AreaAll("6211", "定西市", "2+", "3+", null),
|
|
|
|
+ county = new AreaAll("621121", "通渭县", "3+", "4+", null);
|
|
|
|
+ QueryWrapper<AreaAll> townsWrapper = new QueryWrapper<>();
|
|
|
|
+ townsWrapper.likeRight("id", "621121")
|
|
|
|
+ .eq("level", "4+");
|
|
|
|
+ List<AreaAll> towns = dbMapper.selectList(townsWrapper);
|
|
|
|
+ JSONArray towns_json = new JSONArray();
|
|
|
|
+ for (AreaAll town : towns) {
|
|
|
|
+ QueryWrapper<AreaAll> villagesWrapper = new QueryWrapper<>();
|
|
|
|
+ villagesWrapper.likeRight("id", town.getId())
|
|
|
|
+ .eq("level", town.getChild());
|
|
|
|
+ List<AreaAll> villages = dbMapper.selectList(villagesWrapper);
|
|
|
|
+
|
|
|
|
+ JSONObject town_json = JSONObject.fromObject(town);
|
|
|
|
+ town_json.put("children", villages);
|
|
|
|
+ towns_json.add(town_json);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ JSONArray counties_json = new JSONArray(),
|
|
|
|
+ cities_json = new JSONArray(),
|
|
|
|
+ provinces_json = new JSONArray();
|
|
|
|
+ JSONObject county_json = JSONObject.fromObject(county),
|
|
|
|
+ city_json = JSONObject.fromObject(city),
|
|
|
|
+ province_json = JSONObject.fromObject(province);
|
|
|
|
+ county_json.put("children", towns_json);
|
|
|
|
+ counties_json.add(county_json);
|
|
|
|
+ city_json.put("children", counties_json);
|
|
|
|
+ cities_json.add(city_json);
|
|
|
|
+ province_json.put("children", cities_json);
|
|
|
|
+ provinces_json.add(province_json);
|
|
|
|
+
|
|
|
|
+ return new Result(ResultCode.SUCCESS, provinces_json);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public Result insert(AreaAll one) {
|
|
public Result insert(AreaAll one) {
|
|
try {
|
|
try {
|
|
int res = dbMapper.insert(one);
|
|
int res = dbMapper.insert(one);
|