添加了查询护林员信息和根据手机号修改护林员位置的接口

This commit is contained in:
DESKTOP-4U0TDEF\20371 2021-07-16 09:20:08 +08:00
parent 9b3a680fd6
commit 1c07a698ad
4 changed files with 14 additions and 14 deletions

View File

@ -11,7 +11,7 @@ import java.util.Map;
* @author xkrs * @author xkrs
*/ */
@RestController @RestController
public class XkRsForestRangerController { public class ForestRangerController {
@Resource @Resource
private ForestRangerService forestRangerService; private ForestRangerService forestRangerService;

View File

@ -11,7 +11,7 @@ import java.util.List;
/** /**
* @author xkrs * @author xkrs
*/ */
public interface XkRsForestRangerDao extends JpaRepository<ForestRanger,Long>, JpaSpecificationExecutor<ForestRanger> { public interface ForestRangerDao extends JpaRepository<ForestRanger,Long>, JpaSpecificationExecutor<ForestRanger> {
/** /**
* 根据市区县编码查询护林员的信息 * 根据市区县编码查询护林员的信息
@ -27,7 +27,7 @@ public interface XkRsForestRangerDao extends JpaRepository<ForestRanger,Long>, J
* @param rangerPhone * @param rangerPhone
*/ */
@Modifying(clearAutomatically=true) @Modifying(clearAutomatically=true)
@Query(value = "update xk_forest_ranger set ranger_latitude = ?1,ranger_longitude = ?2 where ranger_phone = ?3",nativeQuery = true) @Query(value = "update forest_ranger set ranger_latitude = ?1,ranger_longitude = ?2 where ranger_phone = ?3",nativeQuery = true)
void updateLatAndLonByPhone(String rangerLatitude,String rangerLongitude,String rangerPhone); void updateLatAndLonByPhone(String rangerLatitude,String rangerLongitude,String rangerPhone);
/** /**
@ -36,7 +36,7 @@ public interface XkRsForestRangerDao extends JpaRepository<ForestRanger,Long>, J
* @param rangerType * @param rangerType
*/ */
@Modifying(clearAutomatically=true) @Modifying(clearAutomatically=true)
@Query(value = "update xk_forest_ranger set ranger_type = ?2 where ranger_phone = ?1",nativeQuery = true) @Query(value = "update forest_ranger set ranger_type = ?2 where ranger_phone = ?1",nativeQuery = true)
void updateRangerTypeByPhone(String rangerPhone,String rangerType); void updateRangerTypeByPhone(String rangerPhone,String rangerType);
/** /**
@ -58,6 +58,6 @@ public interface XkRsForestRangerDao extends JpaRepository<ForestRanger,Long>, J
* @param rangerCountyCode * @param rangerCountyCode
* @return * @return
*/ */
@Query(value = "select * from xk_forest_ranger where ranger_county_code like CONCAT('%',:rangerCountyCode,'%')",nativeQuery = true) @Query(value = "select * from forest_ranger where ranger_county_code like CONCAT('%',:rangerCountyCode,'%')",nativeQuery = true)
List<ForestRanger> findAllsByRangerCountyCode(String rangerCountyCode); List<ForestRanger> findAllsByRangerCountyCode(String rangerCountyCode);
} }

View File

@ -3,7 +3,7 @@ package com.xkrs.service;
/** /**
* @author xkrs * @author xkrs
*/ */
public interface XkRsForestRangerService { public interface ForestRangerService {
/** /**
* 根据区县编码查询护林员的信息 * 根据区县编码查询护林员的信息

View File

@ -2,9 +2,9 @@ package com.xkrs.service.impl;
import com.xkrs.common.encapsulation.PromptMessageEnum; import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.common.tool.TokenUtil; import com.xkrs.common.tool.TokenUtil;
import com.xkrs.dao.XkRsForestRangerDao; import com.xkrs.dao.ForestRangerDao;
import com.xkrs.model.entity.ForestRanger; import com.xkrs.model.entity.ForestRanger;
import com.xkrs.service.XkRsForestRangerService; import com.xkrs.service.ForestRangerService;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -19,10 +19,10 @@ import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulat
* @author xkrs * @author xkrs
*/ */
@Service @Service
public class XkRsForestRangerServiceImpl implements XkRsForestRangerService { public class ForestRangerServiceImpl implements ForestRangerService {
@Resource @Resource
private XkRsForestRangerDao xkRsForestRangerDao; private ForestRangerDao forestRangerDao;
/** /**
* 根据曲线编码查询护林员的信息 * 根据曲线编码查询护林员的信息
@ -33,7 +33,7 @@ public class XkRsForestRangerServiceImpl implements XkRsForestRangerService {
public String findByRangerCountyCode(String rangerCountyCode) { public String findByRangerCountyCode(String rangerCountyCode) {
// 获取区域信息 // 获取区域信息
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
ForestRanger byRangerCountyCode = xkRsForestRangerDao.findByRangerCountyCode(rangerCountyCode); ForestRanger byRangerCountyCode = forestRangerDao.findByRangerCountyCode(rangerCountyCode);
if(byRangerCountyCode == null){ if(byRangerCountyCode == null){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该区县暂时还没有相关护林员的信息",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"该区县暂时还没有相关护林员的信息",locale);
} }
@ -51,13 +51,13 @@ public class XkRsForestRangerServiceImpl implements XkRsForestRangerService {
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
String tokenUserName = TokenUtil.getTokenUserName(token); String tokenUserName = TokenUtil.getTokenUserName(token);
if("370000".equals(countyCode)){ if("370000".equals(countyCode)){
List<ForestRanger> all = xkRsForestRangerDao.findAll(); List<ForestRanger> all = forestRangerDao.findAll();
if(all == null || all.size() == 0){ if(all == null || all.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该省护林员的信息",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该省护林员的信息",locale);
} }
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,all,locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,all,locale);
}else { }else {
List<ForestRanger> allByRangerCountyCode = xkRsForestRangerDao.findAllsByRangerCountyCode(countyCode); List<ForestRanger> allByRangerCountyCode = forestRangerDao.findAllsByRangerCountyCode(countyCode);
if(allByRangerCountyCode == null || allByRangerCountyCode.size() == 0){ if(allByRangerCountyCode == null || allByRangerCountyCode.size() == 0){
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该市护林员的信息",locale); return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时还没该市护林员的信息",locale);
} }
@ -77,7 +77,7 @@ public class XkRsForestRangerServiceImpl implements XkRsForestRangerService {
public String updateLatAndLonByPhone(String rangerLatitude, String rangerLongitude, String rangerPhone) { public String updateLatAndLonByPhone(String rangerLatitude, String rangerLongitude, String rangerPhone) {
// 获取区域信息 // 获取区域信息
Locale locale = LocaleContextHolder.getLocale(); Locale locale = LocaleContextHolder.getLocale();
xkRsForestRangerDao.updateLatAndLonByPhone(rangerLatitude,rangerLongitude,rangerPhone); forestRangerDao.updateLatAndLonByPhone(rangerLatitude,rangerLongitude,rangerPhone);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功",locale); return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"操作成功",locale);
} }
} }