行政区查询
parent
9182cf665b
commit
85f4358d0d
|
|
@ -1,6 +1,5 @@
|
|||
package com.njzscloud.supervisory.sys.district.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.njzscloud.common.core.utils.R;
|
||||
import com.njzscloud.common.mp.support.PageParam;
|
||||
import com.njzscloud.common.mp.support.PageResult;
|
||||
|
|
@ -71,12 +70,24 @@ public class DistrictController {
|
|||
/**
|
||||
* 获取默认区域
|
||||
*/
|
||||
@GetMapping("/obtain_area")
|
||||
public R<List<DistrictEntity>> obtainArea() {
|
||||
@GetMapping("/default_place")
|
||||
public R<AppProperties.DefaultPlace> defaultPlace() {
|
||||
AppProperties.DefaultPlace defaultPlace = appProperties.getDefaultPlace();
|
||||
return R.success(districtService.list(Wrappers.<DistrictEntity>lambdaQuery()
|
||||
.eq(DistrictEntity::getPid, defaultPlace.getCity())
|
||||
.orderByAsc(DistrictEntity::getSort, DistrictEntity::getId)));
|
||||
return R.success(defaultPlace);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @param pid 父级pid
|
||||
* @param name 地区名称
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public R<List<DistrictEntity>> listDistrict(
|
||||
@RequestParam(value = "pid", required = false, defaultValue = "0") String pid,
|
||||
@RequestParam(value = "name", required = false) String name
|
||||
) {
|
||||
return R.success(districtService.listDistrict(pid, name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.njzscloud.supervisory.sys.district.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
|
@ -69,4 +70,11 @@ public class DistrictService extends ServiceImpl<DistrictMapper, DistrictEntity>
|
|||
.collect(Collectors.toList());
|
||||
return Tree.listToTree(list, DistrictTreeResult::getId, DistrictTreeResult::getPid, DistrictTreeResult::setChildren, "0");
|
||||
}
|
||||
|
||||
public List<DistrictEntity> listDistrict(String pid, String name) {
|
||||
return this.list(Wrappers.<DistrictEntity>lambdaQuery()
|
||||
.eq(DistrictEntity::getPid, pid)
|
||||
.like(StrUtil.isNotBlank(name), DistrictEntity::getDistrictName, name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue