diff --git a/src/main/java/com/nis/domain/restful/NtcP2pLog.java b/src/main/java/com/nis/domain/restful/NtcP2pLog.java new file mode 100644 index 0000000..ff1e5eb --- /dev/null +++ b/src/main/java/com/nis/domain/restful/NtcP2pLog.java @@ -0,0 +1,17 @@ +package com.nis.domain.restful; + +import com.nis.domain.LogEntity; + +/** + * + * @ClassName:NtcP2pLog + * @Description:TODO(这里用一句话描述这个类的作用) + * @author (zdx) + * @date 2018年8月7日 上午9:23:52 + * @version V1.0 + */ +public class NtcP2pLog extends LogEntity { + + private static final long serialVersionUID = -8085222950278735219L; + +} 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 8d044ee..c2f76de 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -28,6 +28,7 @@ import com.nis.domain.restful.NtcIpsecLog; import com.nis.domain.restful.NtcL2tpLog; import com.nis.domain.restful.NtcMailLog; import com.nis.domain.restful.NtcOpenvpnLog; +import com.nis.domain.restful.NtcP2pLog; import com.nis.domain.restful.NtcPptpLog; import com.nis.domain.restful.NtcSshLog; import com.nis.domain.restful.NtcSslLog; @@ -840,6 +841,65 @@ public class NtcLogSearchController extends BaseRestController { return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "DDos日志检索成功", ntcDdosLogPage, 0); } + + @RequestMapping(value = "/ntcP2pLogs", method = RequestMethod.GET) + @ApiOperation(value = "P2P日志查询", httpMethod = "GET", notes = "对应配置为“文件传输管理-P2P”,存储动作为阻断的命中日志。对日志功能“文件传输管理-P2P日志”提供数据基础查询服务") + public Map ntcP2pLogs(Page page, NtcP2pLog ntcP2pLog, Model model, HttpServletRequest request, + HttpServletResponse response) { + long start = System.currentTimeMillis(); + AuditLogThread auditLogThread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, + request, null); + + Page ntcP2pLogPage = null; + try { + resetTime(ntcP2pLog); + ntcLogService.queryConditionCheck(auditLogThread, start, ntcP2pLog, NtcP2pLog.class, page); + ntcP2pLogPage = new Page(); + ntcP2pLogPage.setPageNo(page.getPageNo()); + ntcP2pLogPage.setPageSize(page.getPageSize()); + String orderBy = ""; + if (null != page.getOrderBy() && !page.getOrderBy().equals("")) { + orderBy = Page.getOrderBySql(NtcP2pLog.class.getSimpleName(), page.getOrderBy()); + } else { + orderBy = "found_Time"; + } + ResultSet rs = HiveSqlService.getResultSet(page, ntcP2pLog, + Configurations.getStringProperty(NtcP2pLog.class.getSimpleName() + "HiveTable", "ntc_p2p_log"), + getCol2Col(), orderBy, null); + Map tableMapping = HiveJDBC.tableMapping(page, null, rs, NtcP2pLog.class, "foundTime", + "recvTime"); + if (tableMapping == null) { + ntcP2pLogPage.setList(new ArrayList()); + } else { + List list = tableMapping.get("obj"); +// if (tableMapping.get("obj").size() > page.getPageSize()) { +// list = tableMapping.get("obj").subList(0, page.getPageSize()); +// } else { +// list = tableMapping.get("obj").subList(0, tableMapping.get("obj").size()); +// } + if (list.size() > 0) { + String jsonString = JsonMapper.toJsonString(list); + List List = (java.util.List) JsonMapper.fromJsonList(jsonString, + NtcP2pLog.class); + ntcP2pLogPage.setList(List); + ntcP2pLogPage.setCount(List.size()); + + } else { + ntcP2pLogPage.setList(new ArrayList()); + } + } + } catch (Exception e) { + e.printStackTrace(); + auditLogThread.setExceptionInfo(e.getMessage() + " " + e.getCause()); + logger.error(e); + if (!(e instanceof RestServiceException)) { + e = new RestServiceException(auditLogThread, System.currentTimeMillis() - start, "P2P日志检索失败"); + } + throw ((RestServiceException) e); + } + return serviceLogResponse(auditLogThread, System.currentTimeMillis() - start, request, "P2P日志检索成功", + ntcP2pLogPage, 0); + } /** *判断开始和结束时间是否为null,如果为null则初始化时间 diff --git a/src/main/java/com/nis/web/dao/DfLogSearchDao.xml b/src/main/java/com/nis/web/dao/DfLogSearchDao.xml index 864e989..8e8e91f 100644 --- a/src/main/java/com/nis/web/dao/DfLogSearchDao.xml +++ b/src/main/java/com/nis/web/dao/DfLogSearchDao.xml @@ -814,5 +814,25 @@ - + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/applicationLog-hive.properties b/src/main/resources/applicationLog-hive.properties index 4cf0a80..b456574 100644 --- a/src/main/resources/applicationLog-hive.properties +++ b/src/main/resources/applicationLog-hive.properties @@ -12,6 +12,7 @@ NtcSshLogHiveTable=NTC_SSH_LOG NtcFtpLogHiveTable=NTC_FTP_LOG NtcAppLogHiveTable=NTC_APP_LOG NtcDdosLogHiveTable=NTC_DDOS_LOG +NtcP2pLogHiveTable=NTC_P2P_LOG DkBehaviorLogHiveTable=DK_BEHAVIOR_LOG MmAvIpLogHiveTable=MM_AV_IP_LOG MmAvUrlLogHiveTable=MM_AV_URL_LOG