From f4ea57b76cfad4e350adaafe6338165be7e8e6ba Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Fri, 10 Sep 2021 13:47:44 +0800
Subject: [PATCH] gov_monitor_point更新、删除接口
---
screen-manage/src/main/java/com/moral/api/service/GovMonitorPointService.java | 22 +++++++++++
screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java | 62 +++++++++++++++++++++++++++++++
screen-manage/src/main/java/com/moral/api/controller/GovMonitorPoionController.java | 36 ++++++++++++++++++
3 files changed, 120 insertions(+), 0 deletions(-)
diff --git a/screen-manage/src/main/java/com/moral/api/controller/GovMonitorPoionController.java b/screen-manage/src/main/java/com/moral/api/controller/GovMonitorPoionController.java
index 37da36e..6bfbc14 100644
--- a/screen-manage/src/main/java/com/moral/api/controller/GovMonitorPoionController.java
+++ b/screen-manage/src/main/java/com/moral/api/controller/GovMonitorPoionController.java
@@ -68,4 +68,40 @@
govMonitorPointService.insert(govMonitorPoint);
return ResultMessage.ok();
}
+
+ @RequestMapping(value = "update", method = RequestMethod.POST)
+ @ResponseBody
+ public ResultMessage update(@RequestBody GovMonitorPoint govMonitorPoint){
+ int id = govMonitorPoint.getId();
+ if (ObjectUtils.isEmpty(id)){
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ QueryWrapper<GovMonitorPoint> wrapper_govMonitorPoint = new QueryWrapper<>();
+ wrapper_govMonitorPoint.eq("is_delete",Constants.NOT_DELETE);
+ wrapper_govMonitorPoint.eq("id",id);
+ List<GovMonitorPoint> govMonitorPoints = govMonitorPointMapper.selectList(wrapper_govMonitorPoint);
+ if (govMonitorPoints.size()==0){
+ return ResultMessage.fail(ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getCode(),ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getMsg());
+ }
+ govMonitorPointService.update(govMonitorPoint);
+ return ResultMessage.ok();
+ }
+
+ @RequestMapping(value = "delete", method = RequestMethod.POST)
+ @ResponseBody
+ public ResultMessage delete(@RequestBody Map map){
+ int id = Integer.parseInt(map.get("id").toString());
+ if (ObjectUtils.isEmpty(id)){
+ return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(),ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg());
+ }
+ QueryWrapper<GovMonitorPoint> wrapper_govMonitorPoint = new QueryWrapper<>();
+ wrapper_govMonitorPoint.eq("is_delete",Constants.NOT_DELETE);
+ wrapper_govMonitorPoint.eq("id",id);
+ List<GovMonitorPoint> govMonitorPoints = govMonitorPointMapper.selectList(wrapper_govMonitorPoint);
+ if (govMonitorPoints.size()==0){
+ return ResultMessage.fail(ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getCode(),ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getMsg());
+ }
+ govMonitorPointService.delete(id);
+ return ResultMessage.ok();
+ }
}
diff --git a/screen-manage/src/main/java/com/moral/api/service/GovMonitorPointService.java b/screen-manage/src/main/java/com/moral/api/service/GovMonitorPointService.java
index e4eda95..dc7c625 100644
--- a/screen-manage/src/main/java/com/moral/api/service/GovMonitorPointService.java
+++ b/screen-manage/src/main/java/com/moral/api/service/GovMonitorPointService.java
@@ -2,6 +2,7 @@
import com.moral.api.entity.GovMonitorPoint;
import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
@@ -31,7 +32,28 @@
*@Author: lizijie
*@Date: 2021/9/9 15:09
**/
+ @Transactional
void insert(GovMonitorPoint govMonitorPoint);
+
+ /**
+ *@Description: ������������������
+ *@Param: [govMonitorPoint]
+ *@return: void
+ *@Author: lizijie
+ *@Date: 2021/9/10 10:10
+ **/
+ @Transactional
+ void update(GovMonitorPoint govMonitorPoint);
+
+ /**
+ *@Description: ������������������
+ *@Param: [id]
+ *@return: void
+ *@Author: lizijie
+ *@Date: 2021/9/10 13:11
+ **/
+ @Transactional
+ void delete(Integer id);
/**
*@Description: ������id������������������������
diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java
index 83b0e4b..9cac6b4 100644
--- a/screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java
+++ b/screen-manage/src/main/java/com/moral/api/service/impl/GovMonitorPointServiceImpl.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.moral.api.entity.GovMonitorPoint;
@@ -17,10 +18,12 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -138,6 +141,7 @@
return resultMap;
}
+ @Transactional
@Override
public void insert(GovMonitorPoint govMonitorPoint) {
int count = govMonitorPointMapper.insert(govMonitorPoint);
@@ -152,6 +156,64 @@
}
}
+ @Transactional
+ @Override
+ public void update(GovMonitorPoint govMonitorPoint) {
+ Integer id = govMonitorPoint.getId();
+ GovMonitorPoint oldGovMonitorPoint = govMonitorPointMapper.selectById(id);
+ govMonitorPointMapper.updateById(govMonitorPoint);
+ //������redis
+ delGovMonitorPointInfoFromRedis(id.toString());
+ //������redis
+ setGovMonitorPointInfoToRedis(id.toString(),selectGovMonitorPointInfoById(id));
+ //������������������
+ HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
+ StringBuilder content = new StringBuilder();
+ content.append("������������������������").append("id:").append(govMonitorPoint.getId()+";");
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getGuid())){
+ content.append("guid:").append(oldGovMonitorPoint.getGuid()).append("->").append(govMonitorPoint.getGuid()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getName())){
+ content.append("name:").append(oldGovMonitorPoint.getName()).append("->").append(govMonitorPoint.getName()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getLongitude())){
+ content.append("longitude:").append(oldGovMonitorPoint.getLongitude()).append("->").append(govMonitorPoint.getLongitude()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getLatitude())){
+ content.append("latitude:").append(oldGovMonitorPoint.getLatitude()).append("->").append(govMonitorPoint.getLatitude()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getProvinceCode())){
+ content.append("provinceCode:").append(oldGovMonitorPoint.getProvinceCode()).append("->").append(govMonitorPoint.getProvinceCode()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getCityCode())){
+ content.append("cityCode:").append(oldGovMonitorPoint.getCityCode()).append("->").append(govMonitorPoint.getCityCode()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getAreaCode())){
+ content.append("areaCode:").append(oldGovMonitorPoint.getAreaCode()).append("->").append(govMonitorPoint.getAreaCode()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getStationLevel())){
+ content.append("stationLevel:").append(oldGovMonitorPoint.getStationLevel()).append("->").append(govMonitorPoint.getStationLevel()).append(";");
+ }
+ if (!ObjectUtils.isEmpty(govMonitorPoint.getDesc())){
+ content.append("desc:").append(oldGovMonitorPoint).append("->").append(govMonitorPoint.getDesc()).append(";");
+ }
+ logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE);
+ }
+
+ @Override
+ public void delete(Integer id) {
+ UpdateWrapper<GovMonitorPoint> wrapper_delete = new UpdateWrapper<>();
+ wrapper_delete.eq("id",id).set("is_delete",Constants.DELETE);
+ govMonitorPointMapper.update(null,wrapper_delete);
+ //������redis
+ delGovMonitorPointInfoFromRedis(id.toString());
+ //������������������
+ HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
+ StringBuilder content = new StringBuilder();
+ content.append("������������������").append("id:").append(id).append(";");
+ logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE);
+ }
+
@Override
public GovMonitorPoint selectGovMonitorPointInfoById(int id) {
GovMonitorPoint govMonitorPoint = govMonitorPointMapper.selectById(id);
--
Gitblit v1.8.0