添加了查询所有市的接口

This commit is contained in:
DESKTOP-G8BCEP0\HP 2021-07-22 11:54:01 +08:00
parent 613c4cf2b3
commit 956efcd15d
7 changed files with 43 additions and 2 deletions

View File

@ -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()

View File

@ -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"),

View File

@ -213,4 +213,16 @@ public class FirePointController {
WebSocketServer.broadInfo(message);
}
/**
* 查询该省所有的市
* @return
*/
@GetMapping("/selectCityName")
public String selectCityName(){
// 获取区域信息
Locale locale = LocaleContextHolder.getLocale();
List<Map<String, Object>> maps = firePointService.selectCityName();
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,maps,locale);
}
}

View File

@ -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<CityEntity,Long>, JpaSpecificatio
*/
@Query(value = "select city_name,city_code,city_latitude,city_longitude from city where pro_code = ?",nativeQuery = true)
List<Object[]> selectCityNameAndLatAndLog(String proCode);
/**
* 查询所有市和对应的编码
* @return
*/
@Query(value = "select city_name cityname,city_code citycode from city",nativeQuery = true)
List<Map<String,Object>> selectCityName();
}

View File

@ -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<Map<String,Object>> selectCityName();
}

View File

@ -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<Map<String, Object>> selectCityName() {
return cityDao.selectCityName();
}
}

View File

@ -34,8 +34,8 @@ public class Query {
public Predicate toPredicate(Root<FirePointEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
List<Predicate> 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));