diff --git a/src/main/java/com/nis/domain/LogEntity.java b/src/main/java/com/nis/domain/LogEntity.java index 64d3860..a2f048e 100644 --- a/src/main/java/com/nis/domain/LogEntity.java +++ b/src/main/java/com/nis/domain/LogEntity.java @@ -109,6 +109,26 @@ public abstract class LogEntity implements Serializable { protected String searchCapIp;//处理机IP protected String searchFoundStartTime;//开始发现时间 protected String searchFoundEndTime;//结束发现时间 + + //add by dxy 2019-01-05 仅限于NtcConnRecordLog需求,考虑以后可能会放开其他日志查询,所以放到公共类 + protected String searchServerLocate;//serverLocate + protected String searchClientLocate;//clientLocate + + public String getSearchServerLocate() { + return searchServerLocate; + } + + public void setSearchServerLocate(String searchServerLocate) { + this.searchServerLocate = searchServerLocate; + } + + public String getSearchClientLocate() { + return searchClientLocate; + } + + public void setSearchClientLocate(String searchClientLocate) { + this.searchClientLocate = searchClientLocate; + } /** * 当前实体分页对象 diff --git a/src/main/java/com/nis/domain/restful/NtcConnRecordLog.java b/src/main/java/com/nis/domain/restful/NtcConnRecordLog.java index 56935a5..551d2f4 100644 --- a/src/main/java/com/nis/domain/restful/NtcConnRecordLog.java +++ b/src/main/java/com/nis/domain/restful/NtcConnRecordLog.java @@ -1,5 +1,6 @@ package com.nis.domain.restful; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.nis.domain.LogEntity; import com.wordnik.swagger.annotations.ApiModelProperty; @@ -28,7 +29,23 @@ public class NtcConnRecordLog extends LogEntity { protected String c2sByteNum; @ApiModelProperty(value = "", required = true) protected String s2cByteNum; + + @ApiModelProperty(value = "", required = true) + protected Long protoId; + @ApiModelProperty(value = "", required = true) + protected Long appId; + @ApiModelProperty(value = "", required = true) + protected Long webId; + protected String searchSAsn;//sAsn + protected String searchDAsn;//dAsn + protected String searchAppId;//app + protected String searchWebId;//web + protected String searchProtoId;//proto + //protected String searchServerLocate;//serverLocate + //protected String searchClientLocate;//clientLocate + + @JsonIgnore public String getAppLabel() { return appLabel; } @@ -69,4 +86,76 @@ public class NtcConnRecordLog extends LogEntity { this.s2cByteNum = s2cByteNum; } + public Long getProtoId() { + return protoId; + } + + public void setProtoId(Long protoId) { + this.protoId = protoId; + } + + public Long getAppId() { + return appId; + } + + public void setAppId(Long appId) { + this.appId = appId; + } + + public Long getWebId() { + return webId; + } + + public void setWebId(Long webId) { + this.webId = webId; + } + + + @JsonIgnore + public String getSearchSAsn() { + return searchSAsn; + } + + public void setSearchSAsn(String searchSAsn) { + this.searchSAsn = searchSAsn; + } + + @JsonIgnore + public String getSearchDAsn() { + return searchDAsn; + } + + public void setSearchDAsn(String searchDAsn) { + this.searchDAsn = searchDAsn; + } + + @JsonIgnore + public String getSearchAppId() { + return searchAppId; + } + + public void setSearchAppId(String searchAppId) { + this.searchAppId = searchAppId; + } + + @JsonIgnore + public String getSearchWebId() { + return searchWebId; + } + + public void setSearchWebId(String searchWebId) { + this.searchWebId = searchWebId; + } + + @JsonIgnore + public String getSearchProtoId() { + return searchProtoId; + } + + public void setSearchProtoId(String searchProtoId) { + this.searchProtoId = searchProtoId; + } + + + } 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 5a8a2dc..f2dbc2c 100644 --- a/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java +++ b/src/main/java/com/nis/web/controller/restful/NtcLogSearchController.java @@ -696,6 +696,7 @@ public class NtcLogSearchController extends BaseRestController { ntcConnRecordLog.setSearchFoundEndTime(map.get("endTime")); } ntcLogService.queryConditionCheck(auditLogThread, start, ntcConnRecordLog, NtcConnRecordLog.class, page); + ntcLogService.ntcConnRecordLogsQueryConditionCheck(auditLogThread, start, ntcConnRecordLog, NtcConnRecordLog.class, page); logDataService.getData(page, ntcConnRecordLog); } catch (Exception e) { auditLogThread.setExceptionInfo("通联关系日志检索失败:" + e.getMessage()); diff --git a/src/main/java/com/nis/web/dao/DfLogSearchDao.xml b/src/main/java/com/nis/web/dao/DfLogSearchDao.xml index 2f4314e..2782054 100644 --- a/src/main/java/com/nis/web/dao/DfLogSearchDao.xml +++ b/src/main/java/com/nis/web/dao/DfLogSearchDao.xml @@ -1523,6 +1523,15 @@ + + + + + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/LogDataService.java b/src/main/java/com/nis/web/service/LogDataService.java index 6f00d91..837384f 100644 --- a/src/main/java/com/nis/web/service/LogDataService.java +++ b/src/main/java/com/nis/web/service/LogDataService.java @@ -251,13 +251,15 @@ public class LogDataService { if (type.equals("java.lang.String")) { if (field.equals("url") || field.equals("website")) { whereSB.append(" and " + field + " like '" + StringEscapeUtils.unescapeHtml4(value.toString().trim()) + "%'"); + } else if (field.equals("client_locate") || field.equals("server_locate") ) { + whereSB.append(" and " + field + " like '%" + StringEscapeUtils.unescapeHtml4(value.toString().trim()) + "%'"); } else { whereSB.append(" and " + field + "='" + StringEscapeUtils.unescapeHtml4(value.toString().trim()) + "'"); } } else if (type.equals("java.lang.Integer") || type.equals("int") || type.equals("java.lang.Long") || type.equals("long")) { - if(field.equals("cfg_id")) { + if(field.equals("cfg_id") || field.equals("web_id") || field.equals("app_id") || field.equals("proto_id")) { whereSB.append(" and " + filedAndColumnMap.get(key).toLowerCase() + " in(" + value.toString().trim()+")"); }else { diff --git a/src/main/java/com/nis/web/service/restful/NtcLogService.java b/src/main/java/com/nis/web/service/restful/NtcLogService.java index 898e9f1..bcfb3f6 100644 --- a/src/main/java/com/nis/web/service/restful/NtcLogService.java +++ b/src/main/java/com/nis/web/service/restful/NtcLogService.java @@ -1,8 +1,16 @@ package com.nis.web.service.restful; + + import org.springframework.stereotype.Service; +import com.nis.domain.Page; +import com.nis.domain.restful.NtcConnRecordLog; +import com.nis.restful.RestBusinessCode; +import com.nis.restful.RestServiceException; +import com.nis.web.service.AuditLogThread; import com.nis.web.service.BaseLogService; +import com.zdjizhi.utils.StringUtil; /** * @Description:TODO(这里用一句话描述这个类的作用) @@ -13,4 +21,85 @@ import com.nis.web.service.BaseLogService; @Service public class NtcLogService extends BaseLogService { + /** + * 验证日志查询条件格式是否正确 + * + * @param thread + * @param start + * @param entity + * @param clazz + * @param page + */ + public void ntcConnRecordLogsQueryConditionCheck(AuditLogThread thread, long start, NtcConnRecordLog entity, Class clazz, Page page) { + logger.info("ntcConnRecordLogsQueryConditionCheck start----" + System.currentTimeMillis()); + + //app protocol website + if (!StringUtil.isBlank(entity.getSearchAppId())) { + String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchAppId(), ","); + if (split.length > 10) { + throw new RestServiceException("searchAppId max(10)", + RestBusinessCode.param_formate_error.getValue()); + } + for (String appId : split) { + try { + Long.parseLong(appId); + } catch (Exception e) { + throw new RestServiceException("searchAppId error", RestBusinessCode.param_formate_error.getValue()); + } + + } + } + if (!StringUtil.isBlank(entity.getSearchProtoId())) { + String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchProtoId(), ","); + if (split.length > 10) { + throw new RestServiceException("searchProtoId max(10)", + RestBusinessCode.param_formate_error.getValue()); + } + for (String protoId : split) { + try { + Long.parseLong(protoId); + } catch (Exception e) { + throw new RestServiceException("searchAppId error", RestBusinessCode.param_formate_error.getValue()); + } + + } + } + if (!StringUtil.isBlank(entity.getSearchWebId())) { + String[] split = org.apache.commons.lang.StringUtils.split(entity.getSearchWebId(), ","); + if (split.length > 10) { + throw new RestServiceException("searchWebId max(10)", + RestBusinessCode.param_formate_error.getValue()); + } + for (String appId : split) { + try { + Long.parseLong(appId); + } catch (Exception e) { + throw new RestServiceException("searchWebId 参数错误", RestBusinessCode.param_formate_error.getValue()); + } + + } + } + + try { + if (!StringUtil.isBlank(entity.getSearchDirection())) { + Integer.parseInt(entity.getSearchDirection()); + } + } catch (NumberFormatException e) { + throw new RestServiceException("getSearchDirection参数格式错误", RestBusinessCode.param_formate_error.getValue()); + } catch (Exception e) { + throw new RestServiceException("getSearchDirection参数错误", RestBusinessCode.param_formate_error.getValue()); + } + + try { + if (!StringUtil.isBlank(entity.getSearchEntranceId())) { + Long.parseLong(entity.getSearchEntranceId()); + } + } catch (NumberFormatException e) { + throw new RestServiceException("searchEntranceId参数格式错误", RestBusinessCode.param_formate_error.getValue()); + } catch (Exception e) { + throw new RestServiceException("searchEntranceId参数错误", RestBusinessCode.param_formate_error.getValue()); + } + logger.info("ntcConnRecordLogsQueryConditionCheck end----" + System.currentTimeMillis()); + + } }