增加根据名称获取地址信息
This commit is contained in:
parent
e760af7216
commit
a988dedfbf
@ -2,9 +2,9 @@ package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.service.RegionService;
|
||||
import cn.lili.modules.system.entity.dos.Region;
|
||||
import cn.lili.modules.system.entity.vo.RegionVO;
|
||||
import cn.lili.modules.system.service.RegionService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
@ -38,6 +38,11 @@ public class RegionController {
|
||||
return ResultUtil.data(regionService.getRegion(cityCode,townName));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/name")
|
||||
@ApiOperation(value = "根据名字获取地区地址id")
|
||||
public ResultMessage<String> getItemByLastName(String lastName) {
|
||||
return ResultUtil.data(regionService.getItemByLastName(lastName));
|
||||
}
|
||||
|
||||
@GetMapping(value = "/item/{id}")
|
||||
@ApiImplicitParam(name = "id", value = "地区ID", required = true, dataType = "String", paramType = "path")
|
||||
|
@ -36,6 +36,14 @@ public interface RegionService extends IService<Region> {
|
||||
@Cacheable(key = "#id")
|
||||
List<Region> getItem(String id);
|
||||
|
||||
/**
|
||||
* 根据最后一级名称获取改所有上级地区id
|
||||
*
|
||||
* @param lastName 最后一级名称
|
||||
* @return 全部地区id
|
||||
*/
|
||||
String getItemByLastName(String lastName);
|
||||
|
||||
/**
|
||||
* 获取地址
|
||||
*
|
||||
|
@ -61,6 +61,25 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据最后一级名称获取改所有上级地区id
|
||||
*
|
||||
* @param lastName 最后一级名称
|
||||
* @return 全部地区id
|
||||
*/
|
||||
@Override
|
||||
public String getItemByLastName(String lastName) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
LambdaQueryWrapper<Region> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(Region::getName, lastName);
|
||||
Region region = this.getOne(lambdaQueryWrapper, false);
|
||||
if (region != null) {
|
||||
sql.append(region.getPath()).append(",").append(region.getId());
|
||||
return sql.toString().replace(",0,","");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Region> getItem(String id) {
|
||||
LambdaQueryWrapper<Region> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user