New file |
| | |
| | | package com.dsh.guns.modular.system.controller.system; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.model.Region; |
| | | import com.dsh.guns.modular.system.service.IRegionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/3/1 15:26 |
| | | */ |
| | | @Controller |
| | | @RequestMapping("/region") |
| | | public class RegionController { |
| | | |
| | | @Autowired |
| | | private IRegionService regionService; |
| | | |
| | | |
| | | /** |
| | | * 获取行政区联动 |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getRegion") |
| | | public List<Region> getRegion(String pcode){ |
| | | Integer pid = 0; |
| | | if(ToolUtil.isNotEmpty(pcode)){ |
| | | Region code = regionService.getOne(new QueryWrapper<Region>().eq("code", pcode)); |
| | | pid = code.getId(); |
| | | } |
| | | return regionService.list(new QueryWrapper<Region>().eq("parent_id", pid)); |
| | | } |
| | | |
| | | } |