|
@@ -1,10 +1,15 @@
|
|
|
package com.qs.mp.web.controller.api.admin;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.qs.mp.common.core.domain.AjaxResult;
|
|
|
import com.qs.mp.common.core.page.TableDataInfo;
|
|
|
import com.qs.mp.common.domain.Area;
|
|
|
+import com.qs.mp.common.domain.vo.CityVO;
|
|
|
+import com.qs.mp.common.domain.vo.ProvinceVO;
|
|
|
import com.qs.mp.common.service.IAreaService;
|
|
|
import com.qs.mp.web.controller.common.BaseApiController;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
@@ -12,6 +17,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiResponse;
|
|
|
import io.swagger.annotations.ApiResponses;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
@@ -35,6 +41,34 @@ public class AreaMgrController extends BaseApiController {
|
|
|
@Autowired
|
|
|
private IAreaService areaService;
|
|
|
|
|
|
+ @PostMapping("/admin/area/tree/list")
|
|
|
+ @ApiOperation("省市树状列表")
|
|
|
+ @ApiResponses(
|
|
|
+ @ApiResponse(code = 200, message = "成功", response = Area.class)
|
|
|
+ )
|
|
|
+ public AjaxResult treeList() {
|
|
|
+ // 获取省
|
|
|
+ List<Area> provinceList = areaService.list(new LambdaQueryWrapper<Area>().eq(Area::getParentId, 0));
|
|
|
+ List<ProvinceVO> provinceVOList = new ArrayList<>();
|
|
|
+ for (Area province : provinceList) {
|
|
|
+ ProvinceVO provinceVO = new ProvinceVO();
|
|
|
+ BeanUtils.copyProperties(province, provinceVO);
|
|
|
+ // 获取市
|
|
|
+ List<Area> cityList = areaService.list(new LambdaQueryWrapper<Area>().eq(Area::getParentId, province.getAreaId()));
|
|
|
+
|
|
|
+ List<CityVO> cityVOList = new ArrayList<>();
|
|
|
+ for (Area city : cityList) {
|
|
|
+ CityVO cityVO = new CityVO();
|
|
|
+ BeanUtils.copyProperties(city, cityVO);
|
|
|
+ cityVOList.add(cityVO);
|
|
|
+ }
|
|
|
+ provinceVO.setCityList(cityVOList);
|
|
|
+ provinceVOList.add(provinceVO);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(provinceVOList);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 分页获取
|
|
|
*/
|