diff --git a/src/main/java/com/nis/domain/Page.java b/src/main/java/com/nis/domain/Page.java index 0586434ac..e3055a5a5 100644 --- a/src/main/java/com/nis/domain/Page.java +++ b/src/main/java/com/nis/domain/Page.java @@ -3,8 +3,9 @@ */ package com.nis.domain; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.regex.Pattern; @@ -16,8 +17,8 @@ import org.apache.commons.lang3.StringUtils; import com.fasterxml.jackson.annotation.JsonIgnore; import com.nis.util.Configurations; +import com.nis.util.Constants; import com.nis.util.CookieUtil; -import com.nis.util.StringUtil; /** * 分页类 @@ -50,7 +51,7 @@ public class Page { private String fields;//制定资源的字段 private String where; - + private String alias; private String funcName = "page"; // 设置点击页码调用的js函数名称,默认为page,在一页有多个分页对象时使用。 private String funcParam = ""; // 函数的附加参数,第三个参数值。 @@ -71,8 +72,20 @@ public class Page { this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30))); } - + public Page(HttpServletRequest request, HttpServletResponse response,String alias){ + + this(request, response, Integer.valueOf(Configurations.getIntProperty("page.pageSize", 30)),alias); + + } + + public Page(HttpServletRequest request, HttpServletResponse response, int defaultPageSize,String alias){ + this.setAlias(alias); + this.initPage(request, response, defaultPageSize); + } public Page(HttpServletRequest request, HttpServletResponse response, int defaultPageSize){ + this.initPage(request, response, defaultPageSize); + } + private void initPage(HttpServletRequest request, HttpServletResponse response, int defaultPageSize){ try { // 设置页码参数(传递repage参数,来记住页码) String no = request.getParameter("pageNo"); @@ -129,7 +142,6 @@ public class Page { e.printStackTrace(); } } - /** * * @Title: getWhere @@ -141,14 +153,65 @@ public class Page { * @throws * @date 2016年8月17日 上午9:28:21 * @version V1.0 + * wx:日期格式的数据用日期格式化函数格式化,带空格的数据加上引号 */ private String getWhere(HttpServletRequest request) { + String format=Constants.SEARCH_DATEFORMAT; + SimpleDateFormat sdf=new SimpleDateFormat(format); Map requestMap = request.getParameterMap(); StringBuilder whereBuilder = new StringBuilder(512); for(String paramName : request.getParameterMap().keySet()) { - if (paramName.startsWith("search")) { - whereBuilder.append(paramName.substring("search_".length())) - .append("=").append(requestMap.get(paramName)[0]).append(" and "); + if (requestMap.get(paramName)!=null&¶mName.startsWith("search_")&&StringUtils.isNotBlank(requestMap.get(paramName)[0])) { + String clomn=paramName.substring("search_".length()); + String value=requestMap.get(paramName)[0].trim(); + boolean isDate=false; + try { + sdf.parse(value); + isDate=true; + } catch (ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + if(clomn.endsWith("_start")){ + clomn=clomn.substring(0,clomn.lastIndexOf("_start")); + if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+"."); + whereBuilder.append(clomn).append(">="); + if(isDate){ + whereBuilder.append("date_format('") + .append(value).append("','%Y-%m-%d %H:%i:%S')"); + }else if(value.indexOf(" ")>-1){ + whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'"); + }else{ + whereBuilder.append(requestMap.get(paramName)[0]); + } + whereBuilder.append(" and "); + }else if(clomn.endsWith("_end")){ + clomn=clomn.substring(0,clomn.lastIndexOf("_end")); + if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+"."); + whereBuilder.append(clomn).append("<="); + if(isDate){ + whereBuilder.append("DATE_FORMAT('") + .append(value).append("','%Y-%m-%d %H:%i:%S')"); + }else if(value.indexOf(" ")>-1){ + whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'"); + }else{ + whereBuilder.append(requestMap.get(paramName)[0]); + } + whereBuilder.append(" and "); + }else{ + if(StringUtils.isNotBlank(alias)) whereBuilder.append(alias.trim()+"."); + whereBuilder.append(clomn).append("="); + if(isDate){ + whereBuilder.append("date_format('") + .append(value).append("','%Y-%m-%d %H:%i:%S')"); + }else if(value.indexOf(" ")>-1){ + whereBuilder.append("'").append(requestMap.get(paramName)[0]).append("'"); + }else{ + whereBuilder.append(requestMap.get(paramName)[0]); + } + whereBuilder.append(" and "); + } + } } if (whereBuilder.length() > 0) { @@ -624,6 +687,22 @@ public class Page { return getPageSize(); } + /** + * alias + * @return alias + */ + + public String getAlias() { + return alias; + } + + /** + * @param alias the alias to set + */ + public void setAlias(String alias) { + this.alias = alias; + } + // /** // * 获取 Spring data JPA 分页对象 // */ diff --git a/src/main/java/com/nis/domain/configuration/BaseCfg.java b/src/main/java/com/nis/domain/configuration/BaseCfg.java index e02483662..511d91acb 100644 --- a/src/main/java/com/nis/domain/configuration/BaseCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseCfg.java @@ -141,11 +141,19 @@ public class BaseCfg extends BaseEntity { * 区域生效id */ protected String areaEffectiveIds ; + /** + * 界面搜索时间条件 + */ + protected Date search_create_time_start; + protected Date search_create_time_end; + protected Date search_edit_time_start; + protected Date search_edit_time_end; + protected Date search_audit_time_start; + protected Date search_audit_time_end; /** * cfgId * @return cfgId */ - public Long getCfgId() { return cfgId; } @@ -538,5 +546,90 @@ public class BaseCfg extends BaseEntity { public void setMaatTable(String maatTable) { this.maatTable = maatTable; } + /** + * search_create_time_start + * @return search_create_time_start + */ + + public Date getSearch_create_time_start() { + return search_create_time_start; + } + /** + * @param search_create_time_start the search_create_time_start to set + */ + public void setSearch_create_time_start(Date search_create_time_start) { + this.search_create_time_start = search_create_time_start; + } + /** + * search_create_time_end + * @return search_create_time_end + */ + + public Date getSearch_create_time_end() { + return search_create_time_end; + } + /** + * @param search_create_time_end the search_create_time_end to set + */ + public void setSearch_create_time_end(Date search_create_time_end) { + this.search_create_time_end = search_create_time_end; + } + /** + * search_edit_time_start + * @return search_edit_time_start + */ + + public Date getSearch_edit_time_start() { + return search_edit_time_start; + } + /** + * @param search_edit_time_start the search_edit_time_start to set + */ + public void setSearch_edit_time_start(Date search_edit_time_start) { + this.search_edit_time_start = search_edit_time_start; + } + /** + * search_edit_time_end + * @return search_edit_time_end + */ + + public Date getSearch_edit_time_end() { + return search_edit_time_end; + } + /** + * @param search_edit_time_end the search_edit_time_end to set + */ + public void setSearch_edit_time_end(Date search_edit_time_end) { + this.search_edit_time_end = search_edit_time_end; + } + /** + * search_audit_time_start + * @return search_audit_time_start + */ + + public Date getSearch_audit_time_start() { + return search_audit_time_start; + } + /** + * @param search_audit_time_start the search_audit_time_start to set + */ + public void setSearch_audit_time_start(Date search_audit_time_start) { + this.search_audit_time_start = search_audit_time_start; + } + /** + * search_audit_time_end + * @return search_audit_time_end + */ + + public Date getSearch_audit_time_end() { + return search_audit_time_end; + } + /** + * @param search_audit_time_end the search_audit_time_end to set + */ + public void setSearch_audit_time_end(Date search_audit_time_end) { + this.search_audit_time_end = search_audit_time_end; + } + } diff --git a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java index f27551554..179088d42 100644 --- a/src/main/java/com/nis/web/controller/configuration/IpCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/IpCfgController.java @@ -61,7 +61,7 @@ public class IpCfgController extends BaseController{ if(!StringUtils.isBlank(tableName)){ logger.info("table name is "+tableName); ipCfg.setTableName(tableName); - Page page = ipCfgService.findPage(new Page(request,response), ipCfg); + Page page = ipCfgService.findPage(new Page(request,response,"r"), ipCfg); model.addAttribute("page", page); model.addAttribute("action", ipCfg.getAction()); model.addAttribute("tableName", tableName); diff --git a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml index 378602ec9..c616369e8 100644 --- a/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/IpCfgDao.xml @@ -92,13 +92,33 @@ SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY, ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS - + + + + + ${page.alias}.CFG_ID as cfgId, ${page.alias}.CFG_DESC as cfgDesc, ${page.alias}.IP_TYPE as ipType, ${page.alias}.SRC_IP as srcIp, ${page.alias}.SRC_IP_MASK as srcIpMask, ${page.alias}.SRC_PORT as srcPort, + ${page.alias}.SRC_PORT_MASK as srcPortMask ,${page.alias}.DST_IP as dstIp,${page.alias}.DST_IP_MASK as dstIpMask, ${page.alias}.DST_PORT as dstPort, ${page.alias}.DST_PORT_MASK as dstPortMask, + ${page.alias}.DIRECTION as direction,${page.alias}.PROTOCOL as protocol,${page.alias}.PROTOCOL_ID as protocolId,${page.alias}.ACTION as action,${page.alias}.IS_VALID as isValid,${page.alias}.IS_AUDIT as isAudit, + ${page.alias}.CREATOR_ID as creatorId,${page.alias}.CREATE_TIME AS createTime,${page.alias}.EDITOR_ID as editorId,${page.alias}.EDIT_TIME AS editTime,${page.alias}.AUDITOR_ID as auditorId,${page.alias}.AUDIT_TIME AS auditTime, + ${page.alias}.SERVICE_ID as serviceId,${page.alias}.REQUEST_ID AS requestId,${page.alias}.COMPILE_ID AS compileId,${page.alias}.IS_AREA_EFFECTIVE as isAreaEffective,${page.alias}.classify, + ${page.alias}.ATTRIBUTE AS attribute,${page.alias}.LABLE AS lable,${page.alias}.AREA_EFFECTIVE_IDS AS areaEffectiveIds + + + r.CFG_ID as cfgId, r.CFG_DESC as cfgDesc, r.IP_TYPE as ipType, r.SRC_IP as srcIp, r.SRC_IP_MASK as srcIpMask, r.SRC_PORT as srcPort, + r.SRC_PORT_MASK as srcPortMask ,r.DST_IP as dstIp,r.DST_IP_MASK as dstIpMask, r.DST_PORT as dstPort, r.DST_PORT_MASK as dstPortMask, + r.DIRECTION as direction,r.PROTOCOL as protocol,r.PROTOCOL_ID as protocolId,r.ACTION as action,r.IS_VALID as isValid,r.IS_AUDIT as isAudit, + r.CREATOR_ID as creatorId,r.CREATE_TIME AS createTime,r.EDITOR_ID as editorId,r.EDIT_TIME AS editTime,r.AUDITOR_ID as auditorId,r.AUDIT_TIME AS auditTime, + r.SERVICE_ID as serviceId,r.REQUEST_ID AS requestId,r.COMPILE_ID AS compileId,r.IS_AREA_EFFECTIVE as isAreaEffective,r.classify, + r.ATTRIBUTE AS attribute,r.LABLE AS lable,r.AREA_EFFECTIVE_IDS AS areaEffectiveIds + + CFG_DESC, IP_TYPE, SRC_IP, SRC_IP_MASK, SRC_PORT, @@ -241,7 +261,13 @@ , s.name as creator_name,e.name as editor_name,u.name as auditor_name ,ri.request_title as requestName - from ${tableName} r + from ${tableName} + + + ${page.alias} + + r + left join sys_user s on r.creator_id=s.id left join sys_user e on r.editor_id=e.id left join sys_user u on r.auditor_id=u.id @@ -254,109 +280,212 @@ AND ${page.where} - - AND r.CFG_ID=#{cfgId,jdbcType=BIGINT} - - - AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%') - - - AND r.IP_TYPE=#{ipType,jdbcType=INTEGER} - - - AND r.SRC_IP=#{srcIp,jdbcType=VARCHAR} - - - AND r.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR} - - - AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR} - - - AND r.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR} - - - AND r.DST_IP=#{dstIp,jdbcType=VARCHAR} - - - AND r.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR} - - - AND r.DST_PORT=#{dstPort,jdbcType=VARCHAR} - - - AND r.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR} - - - AND r.DIRECTION=#{direction,jdbcType=INTEGER} - - - AND r.PROTOCOL=#{protocol,jdbcType=INTEGER} - - - AND r.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER} - - - AND r.ACTION=#{action,jdbcType=INTEGER} - - - AND r.IS_VALID=#{isValid,jdbcType=INTEGER} - - - AND r.IS_VALID != -1 - - - AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER} - - - AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%') - - - AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP} - - - AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%') - - - AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP} - - - AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%') - - - AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP} - - - AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER} - - - AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER} - - - AND r.COMPILE_ID=#{compileId,jdbcType=INTEGER} - - - AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER} - - - AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%') - - - AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%') - - - AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%') - - - AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%') - + + + + AND ${page.alias}.CFG_ID=#{cfgId,jdbcType=BIGINT} + + + AND ${page.alias}.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.IP_TYPE=#{ipType,jdbcType=INTEGER} + + + AND ${page.alias}.SRC_IP=#{srcIp,jdbcType=VARCHAR} + + + AND ${page.alias}.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR} + + + AND ${page.alias}.SRC_PORT=#{srcPort,jdbcType=VARCHAR} + + + AND ${page.alias}.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR} + + + AND ${page.alias}.DST_IP=#{dstIp,jdbcType=VARCHAR} + + + AND ${page.alias}.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR} + + + AND ${page.alias}.DST_PORT=#{dstPort,jdbcType=VARCHAR} + + + AND ${page.alias}.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR} + + + AND ${page.alias}.DIRECTION=#{direction,jdbcType=INTEGER} + + + AND ${page.alias}.PROTOCOL=#{protocol,jdbcType=INTEGER} + + + AND ${page.alias}.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER} + + + AND ${page.alias}.ACTION=#{action,jdbcType=INTEGER} + + + AND ${page.alias}.IS_VALID=#{isValid,jdbcType=INTEGER} + + + AND ${page.alias}.IS_VALID != -1 + + + AND ${page.alias}.IS_AUDIT=#{isAudit,jdbcType=INTEGER} + + + AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP} + + + AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP} + + + AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP} + + + AND ${page.alias}.SERVICE_ID=#{serviceId,jdbcType=INTEGER} + + + AND ${page.alias}.REQUEST_ID=#{requestId,jdbcType=INTEGER} + + + AND ${page.alias}.COMPILE_ID=#{compileId,jdbcType=INTEGER} + + + AND ${page.alias}.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER} + + + AND ${page.alias}.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%') + + + AND ${page.alias}.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%') + + + + + AND r.CFG_ID=#{cfgId,jdbcType=BIGINT} + + + AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%') + + + AND r.IP_TYPE=#{ipType,jdbcType=INTEGER} + + + AND r.SRC_IP=#{srcIp,jdbcType=VARCHAR} + + + AND r.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR} + + + AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR} + + + AND r.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR} + + + AND r.DST_IP=#{dstIp,jdbcType=VARCHAR} + + + AND r.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR} + + + AND r.DST_PORT=#{dstPort,jdbcType=VARCHAR} + + + AND r.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR} + + + AND r.DIRECTION=#{direction,jdbcType=INTEGER} + + + AND r.PROTOCOL=#{protocol,jdbcType=INTEGER} + + + AND r.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER} + + + AND r.ACTION=#{action,jdbcType=INTEGER} + + + AND r.IS_VALID=#{isValid,jdbcType=INTEGER} + + + AND r.IS_VALID != -1 + + + AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER} + + + AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%') + + + AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP} + + + AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%') + + + AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP} + + + AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%') + + + AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP} + + + AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER} + + + AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER} + + + AND r.COMPILE_ID=#{compileId,jdbcType=INTEGER} + + + AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER} + + + AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%') + + + AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%') + + + AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%') + + + AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%') + + + + ORDER BY ${page.orderBy} - ORDER BY CFG_ID desc + ORDER BY r.CFG_ID desc diff --git a/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp index db8be853d..d4d441021 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipCfgList.jsp @@ -20,10 +20,20 @@