From dc9c235745b44c2a71dd8992746075015a99dbe8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-G8BCEP0\\HP" <2037158277@qq.com> Date: Mon, 2 Aug 2021 17:05:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=90=84=E7=9C=81=E5=B8=82=E7=9A=84=E5=8C=BA=E5=8E=BF=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E5=92=8C=E7=BC=96=E7=A0=81=E7=9A=84=E5=AE=B6=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/FirePointController.java | 11 ++++++++--- src/main/java/com/xkrs/dao/CityDao.java | 5 +++-- src/main/java/com/xkrs/dao/CountyDao.java | 11 +++++++++++ .../com/xkrs/service/FirePointService.java | 10 +++++++++- .../service/impl/FirePointServiceImpl.java | 18 ++++++++++++++++-- 5 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 1187bad..74b69a7 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -247,11 +247,16 @@ public class FirePointController { * @return */ @GetMapping("/selectCityName") - public String selectCityName(){ + public String selectCityName(@RequestParam("code") String code){ // 获取区域信息 Locale locale = LocaleContextHolder.getLocale(); - List> maps = firePointService.selectCityName(); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale); + if(code.substring(2).equals("0000")){ + List> maps = firePointService.selectCityName(code); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale); + }else { + List> maps = firePointService.selectCountyName(code); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale); + } } /** diff --git a/src/main/java/com/xkrs/dao/CityDao.java b/src/main/java/com/xkrs/dao/CityDao.java index 69b9927..9f27699 100644 --- a/src/main/java/com/xkrs/dao/CityDao.java +++ b/src/main/java/com/xkrs/dao/CityDao.java @@ -25,8 +25,9 @@ public interface CityDao extends JpaRepository, JpaSpecificatio /** * 查询所有市和对应的编码 + * @param code * @return */ - @Query(value = "select city_name cityname,city_code citycode from city",nativeQuery = true) - List> selectCityName(); + @Query(value = "select city_name cityname,city_code citycode from city where pro_code = :code",nativeQuery = true) + List> selectCityName(String code); } diff --git a/src/main/java/com/xkrs/dao/CountyDao.java b/src/main/java/com/xkrs/dao/CountyDao.java index d131465..6914b6e 100644 --- a/src/main/java/com/xkrs/dao/CountyDao.java +++ b/src/main/java/com/xkrs/dao/CountyDao.java @@ -2,11 +2,22 @@ package com.xkrs.dao; import com.xkrs.model.entity.CountyEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; +import java.util.List; +import java.util.Map; + /** * @author XinYi Song */ @Component public interface CountyDao extends JpaRepository { + /** + * 查询市包含的区县和编码 + * @param code + * @return + */ + @Query(value = "select county_name cityname,county_code citycode from county where city_code = :code",nativeQuery = true) + List> selectCountyName(String code); } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index 202b905..c2387b2 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -124,7 +124,15 @@ public interface FirePointService { /** * 查询该省所有的市 + * @param code * @return */ - List> selectCityName(); + List> selectCityName(String code); + + /** + * 查询市包含的区县和编码 + * @param code + * @return + */ + List> selectCountyName(String code); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 698ce53..555112e 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -63,6 +63,9 @@ public class FirePointServiceImpl implements FirePointService { @Resource private CityDao cityDao; + @Resource + private CountyDao countyDao; + /** * 添加火点信息 * @param firePointQo @@ -386,10 +389,21 @@ public class FirePointServiceImpl implements FirePointService { /** * 查询该省所有的市 + * @param code * @return */ @Override - public List> selectCityName() { - return cityDao.selectCityName(); + public List> selectCityName(String code) { + return cityDao.selectCityName(code); + } + + /** + * 查询市包含的区县和编码 + * @param code + * @return + */ + @Override + public List> selectCountyName(String code) { + return countyDao.selectCountyName(code); } }