diff --git a/luoo_user/src/main/java/com/luoo/user/controller/RegionController.java b/luoo_user/src/main/java/com/luoo/user/controller/RegionController.java index a681839..994171a 100644 --- a/luoo_user/src/main/java/com/luoo/user/controller/RegionController.java +++ b/luoo_user/src/main/java/com/luoo/user/controller/RegionController.java @@ -1,11 +1,15 @@ package com.luoo.user.controller; import api.Result; +import com.luoo.user.pojo.Region; import com.luoo.user.service.RegionService; import com.luoo.user.vo.RegionVo; import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import java.util.List; + +import io.swagger.annotations.ApiParam; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; @@ -43,4 +47,10 @@ public class RegionController { return Result.success(regionService.getRegionTreeList(level)); } + @ApiOperation(value = "获取子集地区TREE") + @GetMapping("/tree/child/{parentId}") + public Result> getRegionTreeListByParentId(@ApiParam(value = "查询的父id,如果是最上层,parentId=0", required = true) @PathVariable Integer parentId) { + return Result.success(regionService.getRegionTreeListByParentId(parentId)); + } + } diff --git a/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java b/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java index 307b7b4..bf691ae 100644 --- a/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java +++ b/luoo_user/src/main/java/com/luoo/user/dao/RegionDao.java @@ -10,4 +10,6 @@ public interface RegionDao extends JpaRepository, List getRegionsByLevel(Integer level); + List getRegionsByPid(Integer parentId); + } diff --git a/luoo_user/src/main/java/com/luoo/user/service/RegionService.java b/luoo_user/src/main/java/com/luoo/user/service/RegionService.java index dcf7313..9ce8b58 100644 --- a/luoo_user/src/main/java/com/luoo/user/service/RegionService.java +++ b/luoo_user/src/main/java/com/luoo/user/service/RegionService.java @@ -166,5 +166,9 @@ public class RegionService { return !getChildList(list, t).isEmpty(); } + public List getRegionTreeListByParentId(Integer parentId) { + return regionDao.getRegionsByPid(parentId); + } + }