From 7706e248092993884062dc34bf530ca46344044d Mon Sep 17 00:00:00 2001 From: XinYi Song <2037158277@qq.com> Date: Fri, 25 Feb 2022 16:49:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=81=AB=E6=83=85=E7=8A=B6=E6=80=81=E7=9A=84=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/xkrs/controller/FireController.java | 12 ++-------- .../java/com/xkrs/service/FireService.java | 7 ++++++ .../com/xkrs/service/impl/FireServerImpl.java | 22 +++++++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/xkrs/controller/FireController.java b/src/main/java/com/xkrs/controller/FireController.java index e33d604..5ca617b 100644 --- a/src/main/java/com/xkrs/controller/FireController.java +++ b/src/main/java/com/xkrs/controller/FireController.java @@ -104,19 +104,11 @@ public class FireController { * @param map * @return */ - @Transactional(rollbackOn = Exception.class) + @PostMapping("/updateFireState") public String updateFireState(@RequestBody Map map){ String alarmCode = (String) map.get("alarmCode"); - Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode); - if(byAlarmCode == null){ - return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale); - } - if("1".equals(byAlarmCode.getFireState())){ - return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale); - } - fireDao.updateFireState(alarmCode); - return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale); + return fireService.updateFireState(alarmCode); } /** diff --git a/src/main/java/com/xkrs/service/FireService.java b/src/main/java/com/xkrs/service/FireService.java index a4b7ff7..b40b49f 100644 --- a/src/main/java/com/xkrs/service/FireService.java +++ b/src/main/java/com/xkrs/service/FireService.java @@ -29,4 +29,11 @@ public interface FireService { * @return */ String findThreeHundredData(); + + /** + * 修改火点状态 + * @param alarmCode + * @return + */ + String updateFireState(String alarmCode); } diff --git a/src/main/java/com/xkrs/service/impl/FireServerImpl.java b/src/main/java/com/xkrs/service/impl/FireServerImpl.java index 49fb91e..308da11 100644 --- a/src/main/java/com/xkrs/service/impl/FireServerImpl.java +++ b/src/main/java/com/xkrs/service/impl/FireServerImpl.java @@ -6,11 +6,13 @@ import com.xkrs.model.entity.Fire; import com.xkrs.service.FireService; import com.xkrs.util.Query; import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.Cacheable; import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import javax.transaction.Transactional; import java.util.List; import java.util.Locale; @@ -78,4 +80,24 @@ public class FireServerImpl implements FireService { } return outputEncapsulationObject(PromptMessageEnum.SUCCESS,threeHundredData,locale); } + + /** + * 修改火点状态 + * @param alarmCode + * @return + */ + @CacheEvict(value = "FireServiceCache",allEntries = true) + @Transactional(rollbackOn = Exception.class) + @Override + public String updateFireState(String alarmCode) { + Fire byAlarmCode = fireDao.findByAlarmCode(alarmCode); + if(byAlarmCode == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"火情编码错误,请检查!",locale); + } + if("1".equals(byAlarmCode.getFireState())){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"该火情已处理!",locale); + } + fireDao.updateFireState(alarmCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"修改成功!",locale); + } }