From 3a9aa33cdf2cc5e6081df5b3c94ac8372ec12b0b Mon Sep 17 00:00:00 2001 From: lizijie <lzjiiie@163.com> Date: Thu, 13 May 2021 11:29:15 +0800 Subject: [PATCH] 站点增删改查接口 --- screen-manage/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java | 73 +++++++++++++++++++++++++++++++++++- 1 files changed, 70 insertions(+), 3 deletions(-) diff --git a/screen-manage/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java b/screen-manage/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java index eead367..1df34a2 100644 --- a/screen-manage/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java +++ b/screen-manage/src/main/java/com/moral/api/service/impl/MonitorPointServiceImpl.java @@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.moral.api.entity.MonitorPoint; import com.moral.api.entity.Organization; @@ -128,6 +129,7 @@ } @Override + @Transactional public Map<String, Object> updateMonitorPoint(Map<String,Object> updateMap) { Map resultMap = new HashMap(); if(!updateMap.containsKey("id")){ @@ -145,7 +147,7 @@ wapper_name.eq("name",updateMap.get("name")); wapper_name.eq("is_delete",Constants.NOT_DELETE); MonitorPoint monitorPoint_name = monitorPointMapper.selectOne(wapper_name); - if(monitorPoint_name!=null&&!monitorPoint_name.getId().equals(updateMap.get("id"))){ + if(monitorPoint_name!=null&&!monitorPoint_name.getId().toString().equals(updateMap.get("id").toString())){ resultMap.put("code",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getCode()); resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_EXIST.getMsg()); return resultMap; @@ -154,7 +156,72 @@ QueryWrapper<MonitorPoint> wapper_id = new QueryWrapper<>(); wapper_id.eq("id",updateMap.get("id")); wapper_id.eq("is_delete",Constants.NOT_DELETE); - monitorPointMapper.selectOne(wapper_id); - return null; + MonitorPoint oldMonitorPoint = monitorPointMapper.selectOne(wapper_id); + if (oldMonitorPoint==null){ + resultMap.put("code",ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getCode()); + resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getMsg()); + return resultMap; + } + monitorPointMapper.updateMonitorPoint(updateMap); + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String content = "���������������:"+oldMonitorPoint.getName()+";"; + for (Object key:updateMap.keySet()) { + if (key.toString().equals("name")){ + content = content+"������������:"+oldMonitorPoint.getName()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("longitude")){ + content = content+"������:"+oldMonitorPoint.getLongitude()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("latitude")){ + content = content+"������:"+oldMonitorPoint.getLatitude()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("province_code")){ + content = content+"������������:"+oldMonitorPoint.getProvinceCode()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("city_code")){ + content = content+"���������������:"+oldMonitorPoint.getCityCode()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("area_code")){ + content = content+"���/���/���������:"+oldMonitorPoint.getAreaCode()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("address")){ + content = content+"������:"+oldMonitorPoint.getAddress()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("organization_id")){ + content = content+"������id:"+oldMonitorPoint.getOrganizationId()+"->"+updateMap.get(key)+";"; + } + if (key.toString().equals("desc")){ + content = content+"������:"+oldMonitorPoint.getDesc()+"->"+updateMap.get(key)+";"; + } + } + logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); + resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); + resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); + return resultMap; + } + + @Override + @Transactional + public Map<String, Object> deleteMonitorPoint(Map map) { + Map resultMap = new HashMap(); + QueryWrapper<MonitorPoint> wrapper = new QueryWrapper<>(); + wrapper.eq("id",map.get("id")); + wrapper.eq("is_delete","0"); + MonitorPoint monitorPoint = monitorPointMapper.selectOne(wrapper); + if(ObjectUtils.isEmpty(monitorPoint)){ + resultMap.put("code",ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getCode()); + resultMap.put("msg",ResponseCodeEnum.MONITOR_POINT_IS_NOT_EXIST.getMsg()); + return resultMap; + } + MonitorPoint deleteMonitorPoint = new MonitorPoint(); + deleteMonitorPoint.setIsDelete("1"); + monitorPointMapper.update(deleteMonitorPoint,wrapper); + //������������������ + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + String content = "���������������:"+monitorPoint.getName()+";"; + logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); + resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); + resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); + return resultMap; } } -- Gitblit v1.8.0