diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java index 57f535b..614429c 100644 --- a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -49,6 +49,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.GET,"/selectFirePointNum").permitAll() .antMatchers(HttpMethod.GET,"/api/user/booleanUserName").permitAll() .antMatchers(HttpMethod.GET,"/websocketTest").permitAll() + .antMatchers(HttpMethod.GET,"/selectCityName").permitAll() // 所有其它请求需要身份认证 .anyRequest().authenticated() .and() diff --git a/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java b/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java index 8af04a8..74d5bdb 100644 --- a/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java +++ b/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java @@ -25,6 +25,7 @@ public enum PromptMessageEnum{ // 数据返回错误:3001-3999 DATA_NONE(3001, "sys.message.data.none"), + DATA_WRONG(3002, "sys.message.data.wrong"), DATA_EXIT(3003,"sys.message.exit"), diff --git a/src/main/java/com/xkrs/controller/FirePointController.java b/src/main/java/com/xkrs/controller/FirePointController.java index 4c3eca2..a086260 100644 --- a/src/main/java/com/xkrs/controller/FirePointController.java +++ b/src/main/java/com/xkrs/controller/FirePointController.java @@ -213,4 +213,16 @@ public class FirePointController { WebSocketServer.broadInfo(message); } + + /** + * 查询该省所有的市 + * @return + */ + @GetMapping("/selectCityName") + public String selectCityName(){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + List> maps = firePointService.selectCityName(); + 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 bd4d713..69b9927 100644 --- a/src/main/java/com/xkrs/dao/CityDao.java +++ b/src/main/java/com/xkrs/dao/CityDao.java @@ -7,6 +7,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; import java.util.List; +import java.util.Map; /** * @author xkrs @@ -21,4 +22,11 @@ public interface CityDao extends JpaRepository, JpaSpecificatio */ @Query(value = "select city_name,city_code,city_latitude,city_longitude from city where pro_code = ?",nativeQuery = true) List selectCityNameAndLatAndLog(String proCode); + + /** + * 查询所有市和对应的编码 + * @return + */ + @Query(value = "select city_name cityname,city_code citycode from city",nativeQuery = true) + List> selectCityName(); } diff --git a/src/main/java/com/xkrs/service/FirePointService.java b/src/main/java/com/xkrs/service/FirePointService.java index f2b8fe3..d3b8ebc 100644 --- a/src/main/java/com/xkrs/service/FirePointService.java +++ b/src/main/java/com/xkrs/service/FirePointService.java @@ -8,6 +8,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.List; +import java.util.Map; /** * @author XinYi Song @@ -95,4 +96,10 @@ public interface FirePointService { * @return */ String selectFirePointNumWeek(); + + /** + * 查询该省所有的市 + * @return + */ + List> selectCityName(); } diff --git a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java index 892c35c..0cd37b7 100644 --- a/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/FirePointServiceImpl.java @@ -62,6 +62,9 @@ public class FirePointServiceImpl implements FirePointService { @Resource private FireTaskPhotoDao fireTaskPhotoDao; + @Resource + private CityDao cityDao; + /** * 添加火点信息 * @param firePointQo @@ -347,4 +350,13 @@ public class FirePointServiceImpl implements FirePointService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); } + + /** + * 查询该省所有的市 + * @return + */ + @Override + public List> selectCityName() { + return cityDao.selectCityName(); + } } diff --git a/src/main/java/com/xkrs/utils/Query.java b/src/main/java/com/xkrs/utils/Query.java index 486b26b..dac4134 100644 --- a/src/main/java/com/xkrs/utils/Query.java +++ b/src/main/java/com/xkrs/utils/Query.java @@ -34,8 +34,8 @@ public class Query { public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { List list = new ArrayList<>(); if (cityCode != null && !"".equals(cityCode)) { - String substring = cityCode.substring(0, 4); - list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + substring + "%")); + //String substring = cityCode.substring(0, 4); + list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), "%" + cityCode + "%")); } if (satelliteType != null && !"".equals(satelliteType)) { list.add(criteriaBuilder.equal(root.get("satelliteType").as(String.class), satelliteType));