screen-manage screen-api
更改拦截器逻辑,记录token无效的请求IP以及URL。
manage记录到数据库日志中
api记录在日志文件中
1 files added
25 files modified
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.WebUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.method.HandlerMethod; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | |
| | | import com.moral.util.TokenUtils; |
| | | |
| | | @Component |
| | | import java.io.PrintWriter; |
| | | |
| | | @Slf4j |
| | | public class WebInterceptor implements HandlerInterceptor { |
| | | |
| | | @Override |
| | |
| | | return true; |
| | | }*/ |
| | | String token = request.getHeader("token"); |
| | | TokenUtils.checkToken(token); |
| | | boolean result = TokenUtils.checkToken(token); |
| | | if (!result) { |
| | | ResultMessage resultMessage = ResultMessage.fail(ResponseCodeEnum.TOKEN_INVALID.getCode(), |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("text/html; charset=utf-8"); |
| | | PrintWriter writer = response.getWriter(); |
| | | writer.print(JSON.toJSONString(resultMessage)); |
| | | log.info("token无效访问"); |
| | | log.info("ip:"+ WebUtils.getIpAddr(request)); |
| | | log.info("请求URL:"+request.getRequestURL()); |
| | | return false; |
| | | } |
| | | //TokenUtils.extendTokenTime(token); |
| | | return true; |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.moral.api.mapper.HistoryWeeklyMapper"> |
| | | |
| | | <!-- 通用查询映射结果 --> |
| | | <resultMap id="BaseResultMap" type="com.moral.api.entity.HistoryWeekly"> |
| | | <result column="mac" property="mac" /> |
| | | <result column="time" property="time" /> |
| | | <result column="value" property="value" /> |
| | | </resultMap> |
| | | |
| | | </mapper> |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/3/10 |
| | | */ |
| | | public static void checkToken(String token) { |
| | | public static boolean checkToken(String token) { |
| | | try { |
| | | String[] tokenArray = TokenEncryptUtils.decoded(token).split("/"); |
| | | //校验token是否合法 |
| | |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | } |
| | | } catch (Exception e) { |
| | | throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(), |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | |
| | |
| | | package com.moral.api.exception; |
| | | |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.exception.TokenException; |
| | |
| | | package com.moral.api.interceptor; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.util.LogUtils; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.constant.ResultMessage; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import java.io.PrintWriter; |
| | | @Slf4j |
| | | public class ManageInterceptor implements HandlerInterceptor { |
| | | |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | String token = request.getHeader("token"); |
| | | TokenUtils.checkToken(token); |
| | | boolean result = TokenUtils.checkToken(token); |
| | | if (!result) { |
| | | ResultMessage resultMessage = ResultMessage.fail(ResponseCodeEnum.TOKEN_INVALID.getCode(), |
| | | ResponseCodeEnum.TOKEN_INVALID.getMsg()); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | response.setContentType("text/html; charset=utf-8"); |
| | | PrintWriter writer = response.getWriter(); |
| | | writer.print(JSON.toJSONString(resultMessage)); |
| | | log.info("token无效访问"); |
| | | log.info("ip:"+ WebUtils.getIpAddr(request)); |
| | | log.info("请求URL:"+request.getRequestURL()); |
| | | //记录到数据库日志 |
| | | LogUtils.saveFailedRequestForManage(request,"token无效访问;url:"+request.getRequestURL()+";请求token:"+token); |
| | | return false; |
| | | } |
| | | //TokenUtils.extendTokenTime(token); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
| | | |
| | | } |
| | | } |
| | |
| | | private SensorMapper sensorMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | |
| | | @Override |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加了"+deviceAdjustValue.getMac()+"设备"+deviceAdjustValue.getSensorCode()+"传感器"+deviceAdjustValue.getStartTime()+"到"+deviceAdjustValue.getEndTime()+"的校准信息:"+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(deviceAdjustValue.getMac()); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | |
| | | content = content+"校准公式:"+deviceAdjustValueOld.getValue()+"->"+map.get(key)+";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(deviceAdjustValueOld.getMac()); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "删除了"+deviceAdjustValue.getMac()+"设备"+deviceAdjustValue.getSensorCode()+"传感器"+deviceAdjustValue.getStartTime()+"到"+deviceAdjustValue.getEndTime()+"的校准信息:"+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(deviceAdjustValue.getMac()); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | |
| | | @Autowired |
| | | private SysDictDataService sysDictDataService; |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了设备:").append(device.getName()).append(":").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了设备:").append(device.getName()).append(";").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | @Autowired(required = false) |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Resource |
| | | private OrganizationService organizationService; |
| | | |
| | |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了政府站点:").append("id:").append(govMonitorPoint.getId() + ";").append("name:").append(govMonitorPoint.getName() + ";").append("guid:").append(govMonitorPoint.getGuid() + ";"); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | content.append("添加了政府站点:").append("id:").append(govMonitorPoint.getId() + ";").append(govMonitorPoint.getName() + ";").append(":").append("guid:").append(govMonitorPoint.getGuid() + ";"); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | if (!ObjectUtils.isEmpty(govMonitorPoint.getDesc())) { |
| | | content.append("desc:").append(oldGovMonitorPoint).append("->").append(govMonitorPoint.getDesc()).append(";"); |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | 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); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | ManageRoleService manageRoleService; |
| | | @Autowired |
| | | ManageAccountMapper manageAccountMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | else |
| | | content.append(updateRole.getName()+";"); |
| | | |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | } |
| | |
| | | ManageMenuService manageMenuService; |
| | | @Autowired |
| | | ManageAccountRoleMapper manageAccountRoleMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | /** |
| | | * @Description: 登陆接口 |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append(manageAccount.getUserName()).append("登陆了后台系统;"); |
| | | logUtils.saveLoginForManage(request, content.toString(), manageAccount, manageAccount.getUserName()); |
| | | LogUtils.saveLoginForManage(request, content.toString(), manageAccount, manageAccount.getUserName()); |
| | | |
| | | return loginDTO; |
| | | } |
| | |
| | | if(!ObjectUtils.isEmpty(newAccount.getPassword())) |
| | | content.append("修改了密码"); |
| | | String resultContent = CompareFieldUtils.resultsConvertContent(results,content.toString()); |
| | | logUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了后台用户:").append(manageAccount.getUserName() + ";") |
| | | .append("account:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了用户:").append(manageAccount.getUserName() + ";") |
| | | .append("账号:" + manageAccount.getAccount() + ";"); |
| | | logUtils.saveOperationForManage( content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage( content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | @Autowired(required = false) |
| | | private ManageRoleMenuMapper manageRoleMenuMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加菜单:"+manageMenu.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | content = content+"描述:"+manageMenuOld.getDesc()+"->"+map.get(key)+";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "删除菜单:"+manageMenuDelete.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | |
| | | @Autowired(required = false) |
| | | private ManageRoleMapper manageRoleMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | manageMenuNewList.add("空"); |
| | | } |
| | | content = content+"菜单:"+manageMenuOldList+"->"+manageMenuNewList+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | @Autowired(required = false) |
| | | private ManageAccountRoleMapper manageAccountRoleMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | public Map<String,Object> getAllWithPagingQuery(Map map) { |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加角色:"+manageRole.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | content = content+"备注:"+manageRoleOld.getDesc()+"->"+map.get(key)+";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | ManageRole manageRole1 = manageRoleMapper.selectById(Integer.parseInt(map.get("id").toString())); |
| | | String content = "删除角色:"+manageRole1.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | } |
| | |
| | | GroupService groupService; |
| | | @Autowired |
| | | GroupMenuMapper groupMenuMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | |
| | | @Override |
| | | public MenuQueryDTO queryAllMenus() { |
| | |
| | | content.append("及其子菜单:" + menuMapper.selectById(childrenId).getName() + ";"); |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | //封装返回对象 |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | |
| | | } |
| | | } |
| | | String content = CompareFieldUtils.resultsConvertContent(compareResult, "修改了前台菜单"); |
| | | logUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | |
| | | if (menu.getUrl() != null) |
| | | content.append("url:" + menu.getUrl() + ";"); |
| | | content.append("顺序:" + menu.getOrder() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired(required = false) |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加了站点:"+monitorPoint.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | } |
| | | } |
| | | content = content+deviceContent; |
| | | logUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "删除了站点:"+monitorPoint.getName()+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | resultMap.put("code",ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg",ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | @Autowired(required = false) |
| | | private DeviceMapper deviceMapper; |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getData(Map map) { |
| | | int organization_id = Integer.parseInt(map.get("organization_id").toString()); |
| | |
| | | content = content +organizationLayout.getId()+" "; |
| | | } |
| | | content = content+";"; |
| | | logUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,content,Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | if (!ObjectUtils.isEmpty(list) && list.size()>0){ |
| | | organizationLayoutMapper.insertList(list); |
| | |
| | | contentInsert = contentInsert + organizationLayout.getId()+" "; |
| | | } |
| | | contentInsert = contentInsert+";"; |
| | | logUtils.saveOperationForManage(request,contentInsert,Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,contentInsert,Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | } |
| | | |
| | |
| | | OrganizationMapper organizationMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | UserService userService; |
| | | |
| | | @Autowired |
| | |
| | | content.append("以及所有子组织;"); |
| | | else |
| | | content.append(";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | |
| | | return dto; |
| | | } |
| | |
| | | private void insertLog(Organization organization) { |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了组织:").append(organization.getName() + ";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | public void updateLog(Organization oldOrganization, Organization newOrganization) { |
| | |
| | | } |
| | | |
| | | String content = CompareFieldUtils.resultsConvertContent(results, "修改了组织;组织名称:" + oldOrganization.getName()); |
| | | logUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired(required = false) |
| | | private OrganizationUnitAlarmMapper organizationUnitAlarmMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "添加因子:" + sensor.getName() + ";"; |
| | | logUtils.saveOperationForManage(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content, Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //刷新缓存 |
| | |
| | | content = content + "默认单位:" + oldSensor.getDesc() + "->" + updateSensorMap.get(key) + ";"; |
| | | } |
| | | } |
| | | logUtils.saveOperationForManage(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content, Constants.UPDATE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //刷新缓存 |
| | |
| | | //操作插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | String content = "删除因子:" + sensor.getName() + ";"; |
| | | logUtils.saveOperationForManage(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content, Constants.DELETE_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | //刷新缓存 |
| | |
| | | @Autowired(required = false) |
| | | private GovMonitorPointMapper govMonitorPointMapper; |
| | | |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | public Map<String, Object> getDataByCondition(Map map) { |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了历史特殊设备:").append(specialDeviceHistory.getName()).append(";").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | } |
| | |
| | | private GovMonitorPointMapper govMonitorPointMapper; |
| | | |
| | | @Autowired |
| | | private LogUtils logUtils; |
| | | |
| | | @Autowired |
| | | private AdjustDataUtils adjustDataUtils; |
| | | |
| | | /* |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了特殊设备历史数据:").append(insertSpecialDeviceHistory.getName()).append(":").append("mac:").append(insertSpecialDeviceHistory.getMac()); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | }else { |
| | | /*UpdateWrapper<SpecialDeviceHistory> wrapper_insertSpecialDeviceHistory = new UpdateWrapper<>(); |
| | | wrapper_specialDeviceHistory.eq("is_delete",Constants.NOT_DELETE); |
| | |
| | | } |
| | | |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | //Map<String, Object> deviceInfo = selectDeviceInfoById(specialDevice.getId()); |
| | | SpecialDeviceInfoDTO specialDeviceInfoDTO = selectDeviceInfoDTOById(specialDevice.getId()); |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了特殊设备:").append(specialDevice.getName()).append(":").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | resultMap.put("code", ResponseCodeEnum.SUCCESS.getCode()); |
| | | resultMap.put("msg", ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return resultMap; |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("添加了特殊设备历史数据:").append(updateSpecialDeviceHistory.getName()).append(":").append("mac:").append(updateSpecialDeviceHistory.getMac()); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | }else { |
| | | /*UpdateWrapper<SpecialDeviceHistory> wrapper_insertSpecialDeviceHistory = new UpdateWrapper<>(); |
| | | wrapper_specialDeviceHistory.eq("is_delete",Constants.NOT_DELETE); |
| | |
| | | } |
| | | |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | //操作日志记录 |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | |
| | | } |
| | | |
| | | } |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append("删除了设备:").append(specialDevice.getName()).append(";").append("mac:").append(mac); |
| | | logUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request, content.toString(), Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | @Override |
| | |
| | | SysDictDataMapper sysDictDataMapper; |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | content.append("类型:"+type.getName()+"("+type.getDesc()+")"+";"); |
| | | content.append("key:"+existData.getDataKey()+";"); |
| | | content.append("value:"+existData.getDataValue()+";"); |
| | | logUtils.saveOperationForManage(content.toString(),Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.DELETE_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(); |
| | | //封装返回对象 |
| | |
| | | content.append("类型:"+type.getName()+"("+type.getDesc()+")"+";"); |
| | | content.append("key:"+existData.getDataKey()+";"); |
| | | content.append("value:"+existData.getDataValue()+"->"+sysDictData.getDataValue()+";"); |
| | | logUtils.saveOperationForManage(content.toString(),Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.UPDATE_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(); |
| | | //封装返回结果 |
| | |
| | | content.append("类型:"+type.getName()+"("+type.getDesc()+")"+";"); |
| | | content.append("key:"+sysDictData.getDataKey()+";"); |
| | | content.append("value:"+sysDictData.getDataValue()+";"); |
| | | logUtils.saveOperationForManage(content.toString(),Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.INSERT_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(); |
| | | //封装返回结果 |
| | |
| | | SysDictDataService sysDictDataService; |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | sysDictDataService.update(null,deleteDataWrapper); |
| | | //插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | logUtils.saveOperationForManage(request,"删除字典类型:"+type.getName(),Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,"删除字典类型:"+type.getName(),Constants.DELETE_OPERATE_TYPE); |
| | | //刷新缓存数据 |
| | | refreshCache(); |
| | | //封装返回数据 |
| | |
| | | sysDictTypeMapper.insert(sysDictType); |
| | | //插入日志 |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | logUtils.saveOperationForManage(request,"添加字典类型:"+sysDictType.getName(),Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(request,"添加字典类型:"+sysDictType.getName(),Constants.INSERT_OPERATE_TYPE); |
| | | //刷新缓存 |
| | | refreshCache(); |
| | | //封装返回对象 |
| | |
| | | import com.moral.api.mapper.TestMapper; |
| | | import com.moral.api.service.TestService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @since 2021-02-25 |
| | | */ |
| | | @Service |
| | | @ConfigurationProperties(prefix = "code") |
| | | public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements TestService { |
| | | |
| | | @Resource |
| | | private TestMapper testMapper; |
| | | |
| | | Map<String,String> map; |
| | | |
| | | public void setMap(Map<String, String> map) { |
| | | this.map = map; |
| | | } |
| | | |
| | | @Override |
| | | public Page<Test> selectByPage(Test test, Integer page, Integer size) { |
| | | //设置分页条件 |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,String> getMap(){ |
| | | return map; |
| | | } |
| | | } |
| | |
| | | @Autowired |
| | | RedisTemplate redisTemplate; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | @Autowired |
| | | SensorService sensorService; |
| | | |
| | | |
| | |
| | | content.append("针对因子:"+sensor.getName()+";"); |
| | | } |
| | | |
| | | logUtils.saveOperationForManage(content.toString(),Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(sensor!=null) |
| | | content.append("针对因子:"+sensor.getName()+";"); |
| | | } |
| | | logUtils.saveOperationForManage(content.toString(),Constants.DELETE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.DELETE_OPERATE_TYPE); |
| | | } |
| | | |
| | | /** |
| | |
| | | if(sensor!=null) |
| | | content.append("针对因子:"+sensor.getName()+";"); |
| | | } |
| | | logUtils.saveOperationForManage(content.toString(),Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(),Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | } |
| | |
| | | UserGroupMapper userGroupMapper; |
| | | @Autowired |
| | | GroupMenuMapper groupMenuMapper; |
| | | @Autowired |
| | | LogUtils logUtils; |
| | | |
| | | |
| | | @Override |
| | | public UserQueryDTO queryUsers(UserQueryForm form) { |
| | |
| | | content.append("手机:"+user.getMobile()+";"); |
| | | if(user.getWechat()!=null) |
| | | content.append("微信:"+user.getWechat()+";"); |
| | | logUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(content.toString(), Constants.INSERT_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | |
| | | if(newUser.getPassword()!=null) |
| | | content.append("修改了密码;"); |
| | | String resultContent = CompareFieldUtils.resultsConvertContent(results,content.toString()); |
| | | logUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | LogUtils.saveOperationForManage(resultContent, Constants.UPDATE_OPERATE_TYPE); |
| | | } |
| | | |
| | | |
| | |
| | | import com.moral.api.entity.ManageLog; |
| | | import com.moral.api.mapper.ManageLogMapper; |
| | | import com.moral.api.pojo.redisBean.AccountInfoDTO; |
| | | import com.moral.api.service.UnitConversionService; |
| | | import com.moral.constant.Constants; |
| | | import com.moral.util.TokenUtils; |
| | | import com.moral.util.WebUtils; |
| | |
| | | @Component |
| | | public class LogUtils { |
| | | |
| | | @Autowired |
| | | private ManageLogMapper manageLogMapper; |
| | | private static ManageLogMapper manageLogMapper; |
| | | |
| | | public void saveOperationForManage(String content,String type){ |
| | | @Autowired |
| | | public void setManageLogMapper(ManageLogMapper manageLogMapper){LogUtils.manageLogMapper = manageLogMapper;} |
| | | |
| | | public static void saveOperationForManage(String content,String type){ |
| | | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); |
| | | saveOperationForManage(request,content,type); |
| | | } |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/8 |
| | | */ |
| | | @Transactional |
| | | public void saveOperationForManage(HttpServletRequest request, String content,String type) { |
| | | public static void saveOperationForManage(HttpServletRequest request, String content,String type) { |
| | | String token = request.getHeader("token"); |
| | | AccountInfoDTO accountInfoDTO = (AccountInfoDTO) TokenUtils.getUserInfoByToken(token); |
| | | ManageAccount manageAccount = accountInfoDTO.getAccount(); |
| | |
| | | String userName = manageAccount.getUserName(); |
| | | String account = manageAccount.getAccount(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | |
| | | ManageLog log = new ManageLog(); |
| | | log.setType(type); |
| | | log.setUserName(userName); |
| | |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/4/8 |
| | | */ |
| | | @Transactional |
| | | public void saveLoginForManage(HttpServletRequest request,String content,ManageAccount account,String userName){ |
| | | public static void saveLoginForManage(HttpServletRequest request,String content,ManageAccount account,String userName){ |
| | | ManageLog log = new ManageLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | log.setAccountId(account.getId()); |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @Description: 存储token解析失败的日志 |
| | | * @Param: [request, content] |
| | | * @return: void |
| | | * @Author: 陈凯裕 |
| | | * @Date: 2021/10/8 |
| | | */ |
| | | public static void saveFailedRequestForManage(HttpServletRequest request,String content){ |
| | | ManageLog log = new ManageLog(); |
| | | String ip = WebUtils.getIpAddr(request); |
| | | log.setAccountId(0); |
| | | log.setAccount("null"); |
| | | log.setUserName("null"); |
| | | log.setIp(ip); |
| | | log.setContent(content); |
| | | log.setType(Constants.LOGIN_OPERTATE_TYPE); |
| | | manageLogMapper.insert(log); |
| | | } |
| | | |
| | | |
| | | } |