分页调整获取where条件,针对时间类型以及包含空格的搜索条件做了调整,加入了alias一列用来当作表的别名

This commit is contained in:
wangxin
2018-03-09 20:59:13 +08:00
parent f1114d209f
commit fd6425772c
6 changed files with 585 additions and 153 deletions

View File

@@ -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<T> {
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<T> {
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<T> {
e.printStackTrace();
}
}
/**
*
* @Title: getWhere
@@ -141,14 +153,65 @@ public class Page<T> {
* @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<String, String[]> 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&&paramName.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<T> {
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 分页对象
// */

View File

@@ -141,11 +141,19 @@ public class BaseCfg<T> extends BaseEntity<T> {
* 区域生效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<T> extends BaseEntity<T> {
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;
}
}

View File

@@ -61,7 +61,7 @@ public class IpCfgController extends BaseController{
if(!StringUtils.isBlank(tableName)){
logger.info("table name is "+tableName);
ipCfg.setTableName(tableName);
Page<BaseIpCfg> page = ipCfgService.findPage(new Page<BaseIpCfg>(request,response), ipCfg);
Page<BaseIpCfg> page = ipCfgService.findPage(new Page<BaseIpCfg>(request,response,"r"), ipCfg);
model.addAttribute("page", page);
model.addAttribute("action", ipCfg.getAction());
model.addAttribute("tableName", tableName);

View File

@@ -92,13 +92,33 @@
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS
</sql>
<sql id="BaseIpCfg_Column_List_with_id_alias" >
<!-- <sql id="BaseIpCfg_Column_List_with_id_alias" >
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
</sql> -->
<sql id="BaseIpCfg_Column_List_with_id_alias" >
<choose>
<when test="page !=null and page.alias != null and page.alias != ''">
${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
</when>
<otherwise>
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
</otherwise>
</choose>
</sql>
<sql id="BaseIpCfg_Column_List" >
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
</trim>
from ${tableName} r
from ${tableName}
<choose>
<when test="page !=null and page.alias != null and page.alias != ''">
${page.alias}
</when>
<otherwise> r</otherwise>
</choose>
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 @@
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null">
AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="ipType != null">
AND r.IP_TYPE=#{ipType,jdbcType=INTEGER}
</if>
<if test="srcIp != null">
AND r.SRC_IP=#{srcIp,jdbcType=VARCHAR}
</if>
<if test="srcIpMask != null">
AND r.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR}
</if>
<if test="srcPort != null">
AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR}
</if>
<if test="srcPortMask != null">
AND r.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR}
</if>
<if test="dstIp != null">
AND r.DST_IP=#{dstIp,jdbcType=VARCHAR}
</if>
<if test="dstIpMask != null">
AND r.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR}
</if>
<if test="dstPort != null">
AND r.DST_PORT=#{dstPort,jdbcType=VARCHAR}
</if>
<if test="dstPortMask != null">
AND r.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR}
</if>
<if test="direction != null">
AND r.DIRECTION=#{direction,jdbcType=INTEGER}
</if>
<if test="protocol != null">
AND r.PROTOCOL=#{protocol,jdbcType=INTEGER}
</if>
<if test="protocolId != null">
AND r.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER}
</if>
<if test="action != null">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND r.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND r.IS_VALID != -1
</if>
<if test="isAudit != null">
AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="createTime != null">
AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
</if>
<if test="editorName != null">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editTime != null">
AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
</if>
<if test="auditorName != null">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditTime != null">
AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP}
</if>
<if test="serviceId != null">
AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND r.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null">
AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null">
AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null">
AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null">
AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
<choose>
<when test="page !=null and page.alias != null and page.alias != ''">
<if test="cfgId != null and cfgId != ''">
AND ${page.alias}.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND ${page.alias}.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="ipType != null and ipType != ''">
AND ${page.alias}.IP_TYPE=#{ipType,jdbcType=INTEGER}
</if>
<if test="srcIp != null and srcIp != ''">
AND ${page.alias}.SRC_IP=#{srcIp,jdbcType=VARCHAR}
</if>
<if test="srcIpMask != null and srcIpMask != ''">
AND ${page.alias}.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR}
</if>
<if test="srcPort != null and srcPort !=''">
AND ${page.alias}.SRC_PORT=#{srcPort,jdbcType=VARCHAR}
</if>
<if test="srcPortMask != null and srcPortMask !=''">
AND ${page.alias}.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR}
</if>
<if test="dstIp != null and dstIp !=''">
AND ${page.alias}.DST_IP=#{dstIp,jdbcType=VARCHAR}
</if>
<if test="dstIpMask != null and dstIpMask !=''">
AND ${page.alias}.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR}
</if>
<if test="dstPort != null and dstPort !=''">
AND ${page.alias}.DST_PORT=#{dstPort,jdbcType=VARCHAR}
</if>
<if test="dstPortMask != null and dstPortMask !=''">
AND ${page.alias}.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR}
</if>
<if test="direction != null and direction!= ''">
AND ${page.alias}.DIRECTION=#{direction,jdbcType=INTEGER}
</if>
<if test="protocol != null and protocol!=''">
AND ${page.alias}.PROTOCOL=#{protocol,jdbcType=INTEGER}
</if>
<if test="protocolId != null and protocolId !=''">
AND ${page.alias}.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER}
</if>
<if test="action != null and action !=''">
AND ${page.alias}.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null and isValid !=''">
AND ${page.alias}.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null and isValid !=''">
AND ${page.alias}.IS_VALID != -1
</if>
<if test="isAudit != null and isAudit !=''">
AND ${page.alias}.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName !=''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="createTime != null and createTime !=''">
AND ${page.alias}.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
</if>
<if test="editorName != null and editorName !=''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editTime != null and editTime !='' ">
AND ${page.alias}.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
</if>
<if test="auditorName != null and auditorName !=''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditTime != null and auditTime !=''">
AND ${page.alias}.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP}
</if>
<if test="serviceId != null and serviceId !=''">
AND ${page.alias}.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null and requestId !=''">
AND ${page.alias}.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null and compileId !=''">
AND ${page.alias}.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null and isAreaEffective !=''">
AND ${page.alias}.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify !=''">
AND ${page.alias}.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute !=''">
AND ${page.alias}.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable !=''">
AND ${page.alias}.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds !=''">
AND ${page.alias}.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
</when>
<otherwise>
<if test="cfgId != null and cfgId != ''">
AND r.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND r.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="ipType != null and ipType != ''">
AND r.IP_TYPE=#{ipType,jdbcType=INTEGER}
</if>
<if test="srcIp != null and srcIp != ''">
AND r.SRC_IP=#{srcIp,jdbcType=VARCHAR}
</if>
<if test="srcIpMask != null and srcIpMask != ''">
AND r.SRC_IP_MASK=#{srcIpMask,jdbcType=VARCHAR}
</if>
<if test="srcPort != null and srcPort !=''">
AND r.SRC_PORT=#{srcPort,jdbcType=VARCHAR}
</if>
<if test="srcPortMask != null and srcPortMask !=''">
AND r.SRC_PORT_MASK=#{srcPortMask,jdbcType=VARCHAR}
</if>
<if test="dstIp != null and dstIp !=''">
AND r.DST_IP=#{dstIp,jdbcType=VARCHAR}
</if>
<if test="dstIpMask != null and dstIpMask !=''">
AND r.DST_IP_MASK=#{dstIpMask,jdbcType=VARCHAR}
</if>
<if test="dstPort != null and dstPort !=''">
AND r.DST_PORT=#{dstPort,jdbcType=VARCHAR}
</if>
<if test="dstPortMask != null and dstPortMask !=''">
AND r.DST_PORT_MASK=#{dstPortMask,jdbcType=VARCHAR}
</if>
<if test="direction != null and direction!= ''">
AND r.DIRECTION=#{direction,jdbcType=INTEGER}
</if>
<if test="protocol != null and protocol!=''">
AND r.PROTOCOL=#{protocol,jdbcType=INTEGER}
</if>
<if test="protocolId != null and protocolId !=''">
AND r.PROTOCOL_ID=#{protocolId,jdbcType=INTEGER}
</if>
<if test="action != null and action !=''">
AND r.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null and isValid !=''">
AND r.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null and isValid !=''">
AND r.IS_VALID != -1
</if>
<if test="isAudit != null and isAudit !=''">
AND r.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName !=''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="createTime != null and createTime !=''">
AND r.CREATE_TIME=#{createTime,jdbcType=TIMESTAMP}
</if>
<if test="editorName != null and editorName !=''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editTime != null and editTime !='' ">
AND r.EDIT_TIME=#{editTime,jdbcType=TIMESTAMP}
</if>
<if test="auditorName != null and auditorName !=''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditTime != null and auditTime !=''">
AND r.AUDIT_TIME=#{auditTime,jdbcType=TIMESTAMP}
</if>
<if test="serviceId != null and serviceId !=''">
AND r.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null and requestId !=''">
AND r.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null and compileId !=''">
AND r.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null and isAreaEffective !=''">
AND r.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify !=''">
AND r.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute !=''">
AND r.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable !=''">
AND r.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds !=''">
AND r.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
</otherwise>
</choose>
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}
</when>
<otherwise>
ORDER BY CFG_ID desc
ORDER BY r.CFG_ID desc
</otherwise>
</choose>
</select>