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/impl/GovMonitorPointServiceImpl.java | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) 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