diff --git a/src/main/java/com/nis/domain/restful/NtcHttpRecordLog.java b/src/main/java/com/nis/domain/restful/NtcHttpRecordLog.java new file mode 100644 index 0000000..5c958b4 --- /dev/null +++ b/src/main/java/com/nis/domain/restful/NtcHttpRecordLog.java @@ -0,0 +1,140 @@ +package com.nis.domain.restful; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.nis.domain.LogEntity; +import com.wordnik.swagger.annotations.ApiModelProperty; + +/** + * + */ +public class NtcHttpRecordLog extends LogEntity { + + private static final long serialVersionUID = 2553033624540656138L; + + @ApiModelProperty(value="url地址", required=true) + protected String url; + @ApiModelProperty(value="", required=true) + protected Integer httpSeq; + @ApiModelProperty(value="", required=true) + protected Integer proxyFlag; + @ApiModelProperty(value="", required=true) + protected Integer isn; + @ApiModelProperty(value="入口页面", required=true) + protected String referer; + + protected String searchUrl; //url查询条件 + + protected String searchDeviceId; //串联设备编号查询条件 + protected String searchDPort; //目的端口查询条件 + protected String searchSPort; //源端口查询条件 + protected String searchReferer; //入口页面查询条件 + + protected Long foundStartTime;//开始发现时间(时间戳类型) + protected Long foundEndTime;//结束发现时间(时间戳类型) + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + + public Integer getHttpSeq() { + return httpSeq; + } + + public void setHttpSeq(Integer httpSeq) { + this.httpSeq = httpSeq; + } + + public Integer getProxyFlag() { + return proxyFlag; + } + + public void setProxyFlag(Integer proxyFlag) { + this.proxyFlag = proxyFlag; + } + + public Integer getIsn() { + return isn; + } + + public void setIsn(Integer isn) { + this.isn = isn; + } + + public String getReferer() { + return referer; + } + + public void setReferer(String referer) { + this.referer = referer; + } + + /** + * @return the searchUrl + */ + + @JsonIgnore + public String getSearchUrl() { + return searchUrl; + } + + /** + * @param searchUrl the searchUrl to set + */ + public void setSearchUrl(String searchUrl) { + this.searchUrl = searchUrl; + } + @JsonIgnore + public String getSearchDeviceId() { + return searchDeviceId; + } + + public void setSearchDeviceId(String searchDeviceId) { + this.searchDeviceId = searchDeviceId; + } + @JsonIgnore + public String getSearchDPort() { + return searchDPort; + } + + public void setSearchDPort(String searchDPort) { + this.searchDPort = searchDPort; + } + @JsonIgnore + public String getSearchSPort() { + return searchSPort; + } + + public void setSearchSPort(String searchSPort) { + this.searchSPort = searchSPort; + } + @JsonIgnore + public String getSearchReferer() { + return searchReferer; + } + + public void setSearchReferer(String searchReferer) { + this.searchReferer = searchReferer; + } + @JsonIgnore + public Long getFoundStartTime() { + return foundStartTime; + } + + public void setFoundStartTime(Long foundStartTime) { + this.foundStartTime = foundStartTime; + } + @JsonIgnore + public Long getFoundEndTime() { + return foundEndTime; + } + + public void setFoundEndTime(Long foundEndTime) { + this.foundEndTime = foundEndTime; + } + + +} diff --git a/src/main/java/com/nis/domain/restful/NtcSslRecordLog.java b/src/main/java/com/nis/domain/restful/NtcSslRecordLog.java index c889104..dbb69bf 100644 --- a/src/main/java/com/nis/domain/restful/NtcSslRecordLog.java +++ b/src/main/java/com/nis/domain/restful/NtcSslRecordLog.java @@ -27,6 +27,8 @@ public class NtcSslRecordLog extends LogEntity { @ApiModelProperty(value="SNI", required=true) protected String searchSni ; + protected Long foundStartTime;//开始发现时间(时间戳类型) + protected Long foundEndTime;//结束发现时间(时间戳类型) public String getVersion() { return version; @@ -74,4 +76,22 @@ public class NtcSslRecordLog extends LogEntity { public String getSearchSni() { return searchSni; } + @JsonIgnore + public Long getFoundStartTime() { + return foundStartTime; + } + + public void setFoundStartTime(Long foundStartTime) { + this.foundStartTime = foundStartTime; + } + @JsonIgnore + public Long getFoundEndTime() { + return foundEndTime; + } + + public void setFoundEndTime(Long foundEndTime) { + this.foundEndTime = foundEndTime; + } + + } diff --git a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java index 00af934..22a9960 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import com.nis.datasource.CustomerContextHolder; import com.nis.domain.Page; import com.nis.domain.restful.NtcAppLog; import com.nis.domain.restful.NtcBgpLog; @@ -24,6 +25,7 @@ import com.nis.domain.restful.NtcDdosLog; import com.nis.domain.restful.NtcDnsLog; import com.nis.domain.restful.NtcFtpLog; import com.nis.domain.restful.NtcHttpLog; +import com.nis.domain.restful.NtcHttpRecordLog; import com.nis.domain.restful.NtcIpLog; import com.nis.domain.restful.NtcIpsecLog; import com.nis.domain.restful.NtcKeywordsUrlLog; @@ -47,6 +49,8 @@ import com.nis.util.ExceptionUtil; import com.nis.web.controller.BaseRestController; import com.nis.web.service.AuditLogThread; import com.nis.web.service.LogDataService; +import com.nis.web.service.NtcHttpRecordLogsService; +import com.nis.web.service.NtcSslRecordLogsService; import com.nis.web.service.ServicesRequestLogService; import com.nis.web.service.restful.NtcLogService; import com.wordnik.swagger.annotations.Api; @@ -66,7 +70,13 @@ import com.zdjizhi.utils.StringUtil; public class NtcLogSearchController extends BaseRestController { @Autowired protected ServicesRequestLogService servicesRequestLogService; + + @Autowired + protected NtcSslRecordLogsService ntcSslRecordLogsService;//ssl泛收 + @Autowired + protected NtcHttpRecordLogsService ntcHttpRecordLogsService;//http泛收 + @Autowired protected NtcLogService ntcLogService; @Autowired @@ -878,11 +888,15 @@ public class NtcLogSearchController extends BaseRestController { long start = System.currentTimeMillis(); AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, null); - + Page pages= new Page<>(); try { resetTime(ntcSslRecordLog); ntcLogService.queryConditionCheck(auditLogThread, start, ntcSslRecordLog, NtcSslRecordLog.class, page); - logDataService.getData(page, ntcSslRecordLog); +// logDataService.getData(page, ntcSslRecordLog); + //将数据源切换到本地clickhouse + CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B); + pages=ntcSslRecordLogsService.getNtcSslRecordLogsList(page, ntcSslRecordLog); + CustomerContextHolder.clearCustomerType(); } catch (Exception e) { auditLogThread.setExceptionInfo("SSL泛收日志检索失败:" + e.getMessage()); logger.error("SSL泛收日志检索失败:" + ExceptionUtil.getExceptionMsg(e)); @@ -898,6 +912,40 @@ public class NtcLogSearchController extends BaseRestController { } } - return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "SSL泛收日志检索成功", page, 0); + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "SSL泛收日志检索成功", pages, 0); + } + + @RequestMapping(value = "/ntcHttpRecordLogs", method = RequestMethod.GET) + @ApiOperation(value = "HTTP泛收日志查询", httpMethod = "GET", notes = "对应配置为“网站管理-HTTP”,存储动作为阻断与监测的命中日志。对日志功能“网站管理-HTTP”提供数据基础查询服务") + public Map ntcHttpRecordLogs(Page page, NtcHttpRecordLog ntcHttpRecordLog, Model model, HttpServletRequest request, + HttpServletResponse response) { + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request, + null); + Page pages= new Page<>(); + try { + resetTime(ntcHttpRecordLog); + ntcLogService.queryConditionCheck(auditLogThread, start, ntcHttpRecordLog, NtcHttpRecordLog.class, page); +// logDataService.getData(page, ntcHttpRecordLog); + //将数据源切换到本地clickhouse + CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_B); + pages=ntcHttpRecordLogsService.getNtcHttpRecordLogsList(page, ntcHttpRecordLog); + CustomerContextHolder.clearCustomerType(); + } catch (Exception e) { + auditLogThread.setExceptionInfo("Http泛收日志检索失败:" + e.getMessage()); + logger.error("Http泛收日志检索失败:" + ExceptionUtil.getExceptionMsg(e)); + if (e instanceof RestServiceException) { + throw new RestServiceException(auditLogThread, System.currentTimeMillis() - start, + "Http泛收日志检索失败:" + e.getMessage(), ((RestServiceException) e).getErrorCode()); + } else if (e instanceof ServiceRuntimeException) { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "Http泛收日志检索失败:" + e.getMessage(), ((ServiceRuntimeException) e).getErrorCode()); + } else { + throw new ServiceRuntimeException(auditLogThread, System.currentTimeMillis() - start, + "Http泛收日志检索失败:" + e.getMessage(), RestBusinessCode.service_runtime_error.getValue()); + } + } + + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "Http泛收日志检索成功", pages, 0); } } diff --git a/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.java b/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.java new file mode 100644 index 0000000..5dc48fb --- /dev/null +++ b/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.java @@ -0,0 +1,12 @@ +package com.nis.web.dao; + +import java.util.List; + +import com.nis.domain.restful.NtcHttpRecordLog; + +@MyBatisDao +public interface NtcHttpRecordLogsDao { + + //http泛收 查询 + List findNtcHttpRecordLogList(NtcHttpRecordLog obj); +} diff --git a/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.xml b/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.xml new file mode 100644 index 0000000..0fe6974 --- /dev/null +++ b/src/main/java/com/nis/web/dao/NtcHttpRecordLogsDao.xml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.java b/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.java new file mode 100644 index 0000000..5dcb93f --- /dev/null +++ b/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.java @@ -0,0 +1,12 @@ +package com.nis.web.dao; + +import java.util.List; + +import com.nis.domain.restful.NtcSslRecordLog; + +@MyBatisDao +public interface NtcSslRecordLogsDao { + + //ssl泛收 查询 + List findNtcSslRecordLogList(NtcSslRecordLog obj); +} diff --git a/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.xml b/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.xml new file mode 100644 index 0000000..1ca8f84 --- /dev/null +++ b/src/main/java/com/nis/web/dao/NtcSslRecordLogsDao.xml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/NtcHttpRecordLogsService.java b/src/main/java/com/nis/web/service/NtcHttpRecordLogsService.java new file mode 100644 index 0000000..acd2703 --- /dev/null +++ b/src/main/java/com/nis/web/service/NtcHttpRecordLogsService.java @@ -0,0 +1,73 @@ +package com.nis.web.service; + +import java.text.SimpleDateFormat; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.nis.domain.Page; +import com.nis.domain.restful.NtcHttpRecordLog; +import com.nis.restful.RestBusinessCode; +import com.nis.restful.RestServiceException; +import com.nis.web.dao.NtcHttpRecordLogsDao; +import com.zdjizhi.utils.StringUtil; + +@Service +public class NtcHttpRecordLogsService extends BaseService{ + + @Autowired + protected NtcHttpRecordLogsDao ntcHttpRecordLogsDao; + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + //查询 http泛收 日志数据 + public Page getNtcHttpRecordLogsList(Page page ,NtcHttpRecordLog entity) { + //把String类型的时间 转换成 时间戳类型 + if (!StringUtil.isBlank(entity.getSearchFoundStartTime())) { + try { + entity.setFoundStartTime(sdf.parse(entity.getSearchFoundStartTime().trim()).getTime() / 1000); + } catch (Exception e) { + throw new RestServiceException("searchFoundStartTime参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) { + try { + entity.setFoundEndTime(sdf.parse(entity.getSearchFoundEndTime().trim()).getTime() / 1000); + } catch (Exception e) { + throw new RestServiceException("searchFoundEndTime参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchEntranceId())) { + try { + entity.setEntranceId(Long.valueOf(entity.getSearchEntranceId())); + } catch (Exception e) { + throw new RestServiceException("searchEntranceId参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchDeviceId())) { + try { + entity.setDeviceId(Integer.valueOf(entity.getSearchDeviceId())); + } catch (Exception e) { + throw new RestServiceException("searchDeviceId参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchDPort())) { + try { + entity.setdPort(Integer.valueOf(entity.getSearchDPort())); + } catch (Exception e) { + throw new RestServiceException("searchDPort参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchSPort())) { + try { + entity.setsPort(Integer.valueOf(entity.getSearchSPort())); + } catch (Exception e) { + throw new RestServiceException("searchSPort参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + entity.setPage(page); + List findNtcHttpRecordLogList = ntcHttpRecordLogsDao.findNtcHttpRecordLogList(entity); + page.setList(findNtcHttpRecordLogList); + return page; + } +} diff --git a/src/main/java/com/nis/web/service/NtcSslRecordLogsService.java b/src/main/java/com/nis/web/service/NtcSslRecordLogsService.java new file mode 100644 index 0000000..8dab62b --- /dev/null +++ b/src/main/java/com/nis/web/service/NtcSslRecordLogsService.java @@ -0,0 +1,61 @@ +package com.nis.web.service; + +import java.text.SimpleDateFormat; +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import com.nis.domain.Page; +import com.nis.domain.restful.NtcSslRecordLog; +import com.nis.restful.RestBusinessCode; +import com.nis.restful.RestServiceException; +import com.nis.web.dao.NtcSslRecordLogsDao; +import com.zdjizhi.utils.StringUtil; + +@Service +public class NtcSslRecordLogsService extends BaseService{ + + @Autowired + protected NtcSslRecordLogsDao ntcSslRecordLogsDao; + private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + //查询 ssl泛收 日志数据 + public Page getNtcSslRecordLogsList(Page page ,NtcSslRecordLog entity) throws Exception{ + //把String类型的时间 转换成 时间戳类型 + if (!StringUtil.isBlank(entity.getSearchFoundStartTime())) { + try { + entity.setFoundStartTime(sdf.parse(entity.getSearchFoundStartTime().trim()).getTime() / 1000); + } catch (Exception e) { + throw new RestServiceException("searchFoundStartTime参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchFoundEndTime())) { + try { + entity.setFoundEndTime(sdf.parse(entity.getSearchFoundEndTime().trim()).getTime() / 1000); + } catch (Exception e) { + throw new RestServiceException("searchFoundEndTime参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchCfgId())) { + try { + entity.setCfgId(Long.valueOf(entity.getSearchCfgId())); + } catch (Exception e) { + throw new RestServiceException("searchCfgId参数错误", RestBusinessCode.param_formate_error.getValue()); + } + } + if (!StringUtil.isBlank(entity.getSearchEntranceId())) { + try { + entity.setEntranceId(Long.valueOf(entity.getSearchEntranceId())); + } catch (Exception e) { + throw new RestServiceException("searchEntranceId", RestBusinessCode.param_formate_error.getValue()); + } + } + entity.setPage(page); + List findNtcSslRecordLogList = ntcSslRecordLogsDao.findNtcSslRecordLogList(entity); + page.setList(findNtcSslRecordLogList); + return page; + } + + +}