| | |
| | | package com.ruoyi.tms.controller; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.tms.domain.vo.AddressVo; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | |
| | | { |
| | | return AjaxResult.success(tmsRegionService.selectRegionVoList(code)); |
| | | } |
| | | @GetMapping(value = "/getAddressCode") |
| | | public AjaxResult getAddressCode(AddressVo addressVo) |
| | | { |
| | | Map<String,String> hasMap = new HashMap<>(); |
| | | |
| | | if (StringUtils.isNotEmpty(addressVo.getProvince())){ |
| | | TmsRegion tmsRegion = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class) |
| | | .eq(TmsRegion::getRegionName, addressVo.getProvince()) |
| | | .last("limit 1") |
| | | ); |
| | | if (tmsRegion != null){ |
| | | hasMap.put("provinceCode",tmsRegion.getRegionCode()); |
| | | if (StringUtils.isNotEmpty(addressVo.getCity())){ |
| | | TmsRegion tmsRegion2 = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class) |
| | | .eq(TmsRegion::getRegionName, addressVo.getCity()) |
| | | .eq(TmsRegion::getParentRegionCode, tmsRegion.getRegionCode()) |
| | | .last("limit 1") |
| | | ); |
| | | if (tmsRegion2 != null){ |
| | | hasMap.put("cityCode",tmsRegion2.getRegionCode()); |
| | | |
| | | if (StringUtils.isNotEmpty(addressVo.getDistrict())){ |
| | | TmsRegion tmsRegion3= tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class) |
| | | .eq(TmsRegion::getRegionName, addressVo.getDistrict()) |
| | | .eq(TmsRegion::getParentRegionCode, tmsRegion2.getRegionCode()) |
| | | .last("limit 1") |
| | | ); |
| | | if (tmsRegion3 != null){ |
| | | hasMap.put("districtCode",tmsRegion3.getRegionCode()); |
| | | |
| | | if (StringUtils.isNotEmpty(addressVo.getTownship())){ |
| | | TmsRegion tmsRegion4 = tmsRegionService.getBaseMapper().selectOne(new LambdaUpdateWrapper<>(TmsRegion.class) |
| | | .eq(TmsRegion::getRegionName, addressVo.getTownship()) |
| | | .eq(TmsRegion::getParentRegionCode, tmsRegion3.getRegionCode()) |
| | | .last("limit 1") |
| | | ); |
| | | if (tmsRegion4 != null){ |
| | | hasMap.put("townshipCode",tmsRegion4.getRegionCode()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(hasMap); |
| | | } |
| | | |
| | | /** |
| | | * 新增行政区域 |