From fea3440c5b5345870071e250d4baad15cdf10b22 Mon Sep 17 00:00:00 2001 From: "DESKTOP-4U0TDEF\\20371" <2037158277@qq.com> Date: Fri, 16 Jul 2021 08:52:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=81=AB=E7=82=B9=E7=BC=96=E7=A0=81=E6=9F=A5=E8=AF=A2=E7=81=AB?= =?UTF-8?q?=E7=82=B9=E4=BF=A1=E6=81=AF=E7=9A=84sql=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oller.java => ForestRangerController.java} | 21 ++++++++++--------- src/main/java/com/xkrs/dao/FirePointDao.java | 10 ++++++++- 2 files changed, 20 insertions(+), 11 deletions(-) rename src/main/java/com/xkrs/controller/{XkRsForestRangerController.java => ForestRangerController.java} (55%) diff --git a/src/main/java/com/xkrs/controller/XkRsForestRangerController.java b/src/main/java/com/xkrs/controller/ForestRangerController.java similarity index 55% rename from src/main/java/com/xkrs/controller/XkRsForestRangerController.java rename to src/main/java/com/xkrs/controller/ForestRangerController.java index 4c86287..61103f6 100644 --- a/src/main/java/com/xkrs/controller/XkRsForestRangerController.java +++ b/src/main/java/com/xkrs/controller/ForestRangerController.java @@ -1,7 +1,6 @@ package com.xkrs.controller; -import com.xkrs.service.XkRsForestRangerService; -import com.xkrs.utils.Result; +import com.xkrs.service.ForestRangerService; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -15,7 +14,7 @@ import java.util.Map; public class XkRsForestRangerController { @Resource - private XkRsForestRangerService xkRsForestRangerService; + private ForestRangerService forestRangerService; /** * 根据区县编码查询相关护林员的信息 @@ -23,8 +22,9 @@ public class XkRsForestRangerController { * @return */ @GetMapping("/findByRangerCountyCode") - public Result findByRangerCountyCode(@RequestParam("rangerCountyCode") String rangerCountyCode){ - return xkRsForestRangerService.findByRangerCountyCode(rangerCountyCode); + @PreAuthorize("hasAnyAuthority('auth_general_user')") + public String findByRangerCountyCode(@RequestParam("rangerCountyCode") String rangerCountyCode, @RequestHeader(value="Authorization") String token){ + return forestRangerService.findByRangerCountyCode(rangerCountyCode); } /** @@ -33,10 +33,10 @@ public class XkRsForestRangerController { * @param token * @return */ - @PreAuthorize("hasAnyRole('ROLE_city','ROLE_county')") @GetMapping("/findAllByRangerCountyCode") - public Result findAllByRangerCountyCode(@RequestParam("countyCode") String countyCode, @RequestHeader(value="Authorization") String token){ - return xkRsForestRangerService.findAllByRangerCountyCode(countyCode,token); + @PreAuthorize("hasAnyAuthority('auth_general_user')") + public String findAllByRangerCountyCode(@RequestParam("countyCode") String countyCode, @RequestHeader(value="Authorization") String token){ + return forestRangerService.findAllByRangerCountyCode(countyCode,token); } /** @@ -45,11 +45,12 @@ public class XkRsForestRangerController { * @return */ @PostMapping("/updateLatAndLonByPhone") - public Result updateLatAndLonByPhone(@RequestBody Map map){ + @PreAuthorize("hasAnyAuthority('auth_general_user')") + public String updateLatAndLonByPhone(@RequestBody Map map, @RequestHeader(value="Authorization") String token){ String rangerLatitude = (String) map.get("rangerLatitude"); String rangerLongitude = (String) map.get("rangerLongitude"); String rangerPhone = (String) map.get("rangerPhone"); - return xkRsForestRangerService.updateLatAndLonByPhone(rangerLatitude,rangerLongitude,rangerPhone); + return forestRangerService.updateLatAndLonByPhone(rangerLatitude,rangerLongitude,rangerPhone); } diff --git a/src/main/java/com/xkrs/dao/FirePointDao.java b/src/main/java/com/xkrs/dao/FirePointDao.java index 3c3ac1f..8108b58 100644 --- a/src/main/java/com/xkrs/dao/FirePointDao.java +++ b/src/main/java/com/xkrs/dao/FirePointDao.java @@ -2,6 +2,7 @@ package com.xkrs.dao; import com.xkrs.model.entity.FirePointEntity; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Component; @@ -11,7 +12,7 @@ import java.util.List; * @author XinYi Song */ @Component -public interface FirePointDao extends JpaRepository { +public interface FirePointDao extends JpaRepository, JpaSpecificationExecutor { /** * 查询今天的火点信息 @@ -20,4 +21,11 @@ public interface FirePointDao extends JpaRepository { */ @Query(value = "select * from fire_point where add_time like CONCAT('%',:addTime,'%')",nativeQuery = true) List selectTodayFirePoint(String addTime); + + /** + * 根据火点编码查询火点信息 + * @param fireCode + * @return + */ + FirePointEntity findByFireCode(String fireCode); }