diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/system/SysAreaController.java b/ghy-admin/src/main/java/com/ghy/web/controller/system/SysAreaController.java index b2766795..7549dc80 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/system/SysAreaController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/system/SysAreaController.java @@ -5,6 +5,7 @@ import com.ghy.common.constant.UserConstants; import com.ghy.common.core.controller.BaseController; import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.enums.BusinessType; +import com.ghy.common.json.JSONObject; import com.ghy.common.utils.ExceptionUtil; import com.ghy.system.domain.SysArea; import com.ghy.system.service.ISysAreaService; @@ -15,6 +16,7 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; /** @@ -45,6 +47,43 @@ public class SysAreaController extends BaseController { } + @PostMapping("/app/all") + @ResponseBody + public Object appAll(@RequestBody SysArea sysArea) + { + try { + // 第一层 省 + List provinceAreas = sysAreaService.selectSysAreaList(sysArea); + for (SysArea provinceArea : provinceAreas) { + logger.info("进行中的省 : " + provinceArea.getAreaName()); + SysArea param1 = new SysArea(); + param1.setParentCode(provinceArea.getAreaCode()); + // 第二层 市 + List cityAreas = sysAreaService.selectSysAreaList(param1); + for (SysArea cityArea : cityAreas){ + SysArea param2 = new SysArea(); + param2.setParentCode(cityArea.getAreaCode()); + // 第三层 区 + List countryAreas = sysAreaService.selectSysAreaList(param2); + for (SysArea countryArea : countryAreas){ + SysArea param3 = new SysArea(); + param3.setParentCode(countryArea.getAreaCode()); + // 第三层 街道 + List streetAreas = sysAreaService.selectSysAreaList(param3); + countryArea.setChild(streetAreas); + } + cityArea.setChild(countryAreas); + } + provinceArea.setChild(cityAreas); + } + return provinceAreas; + }catch (Exception e){ + logger.error(ExceptionUtil.getExceptionMessage(e)); + return AjaxResult.error(e.getMessage()); + } + + } + @PostMapping("/app/list") @ResponseBody public AjaxResult appList(@RequestBody SysArea sysArea) diff --git a/ghy-system/src/main/java/com/ghy/system/domain/SysArea.java b/ghy-system/src/main/java/com/ghy/system/domain/SysArea.java index 00377fb7..21c37784 100644 --- a/ghy-system/src/main/java/com/ghy/system/domain/SysArea.java +++ b/ghy-system/src/main/java/com/ghy/system/domain/SysArea.java @@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel; import com.ghy.common.core.domain.BaseEntity; import lombok.Data; +import java.util.List; + /** * @author clunt * 区域表 @@ -49,4 +51,6 @@ public class SysArea extends BaseEntity { @Excel(name = "纬度", cellType = Excel.ColumnType.STRING) private String lat; + private List child; + }