临时区域接口

This commit is contained in:
kuang.yife 2023-05-20 23:48:51 +08:00
parent 444c532f9a
commit 8b7ab3c6fe
2 changed files with 43 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.ghy.common.constant.UserConstants;
import com.ghy.common.core.controller.BaseController; import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.enums.BusinessType; import com.ghy.common.enums.BusinessType;
import com.ghy.common.json.JSONObject;
import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ExceptionUtil;
import com.ghy.system.domain.SysArea; import com.ghy.system.domain.SysArea;
import com.ghy.system.service.ISysAreaService; import com.ghy.system.service.ISysAreaService;
@ -15,6 +16,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List; 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<SysArea> provinceAreas = sysAreaService.selectSysAreaList(sysArea);
for (SysArea provinceArea : provinceAreas) {
logger.info("进行中的省 : " + provinceArea.getAreaName());
SysArea param1 = new SysArea();
param1.setParentCode(provinceArea.getAreaCode());
// 第二层
List<SysArea> cityAreas = sysAreaService.selectSysAreaList(param1);
for (SysArea cityArea : cityAreas){
SysArea param2 = new SysArea();
param2.setParentCode(cityArea.getAreaCode());
// 第三层
List<SysArea> countryAreas = sysAreaService.selectSysAreaList(param2);
for (SysArea countryArea : countryAreas){
SysArea param3 = new SysArea();
param3.setParentCode(countryArea.getAreaCode());
// 第三层 街道
List<SysArea> 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") @PostMapping("/app/list")
@ResponseBody @ResponseBody
public AjaxResult appList(@RequestBody SysArea sysArea) public AjaxResult appList(@RequestBody SysArea sysArea)

View File

@ -4,6 +4,8 @@ import com.ghy.common.annotation.Excel;
import com.ghy.common.core.domain.BaseEntity; import com.ghy.common.core.domain.BaseEntity;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* @author clunt * @author clunt
* 区域表 * 区域表
@ -49,4 +51,6 @@ public class SysArea extends BaseEntity {
@Excel(name = "纬度", cellType = Excel.ColumnType.STRING) @Excel(name = "纬度", cellType = Excel.ColumnType.STRING)
private String lat; private String lat;
private List<SysArea> child;
} }