缓存策略增加导出excel和csv功能

This commit is contained in:
leijun
2018-12-24 16:05:05 +08:00
parent a4c29ae5fd
commit f9f51b0e14
6 changed files with 487 additions and 207 deletions

View File

@@ -0,0 +1,159 @@
/**
*@Title: HttpDomainConfig.java
*@Package com.nis.domain.restful
*@Description TODO
*@author dell
*@date 2018年2月5日 下午5:33:05
*@version 版本号
*/
package com.nis.domain.configuration;
import java.util.Map;
import com.nis.util.excel.ExcelField;
/**
* @ClassName: HttpDomainConfig.java
* @Description: TODO
* @author (dell)
* @date 2018年2月5日 下午5:33:05
* @version V1.0
*/
public class CachePolicyUserRegion extends BaseCfg<CachePolicyUserRegion> {
private static final long serialVersionUID = -1741829305216502322L;
@ExcelField(title="cache_cookied_cont",dictType="CACHE_COOKIED_CONT",sort=7)
private String cache_cookied_cont;
@ExcelField(title="cache_dyn_url",dictType="CACHE_DYN_URL",sort=6)
private String cache_dyn_url;
@ExcelField(title="force_caching",dictType="FORCE_CACHING",sort=10)
private String force_caching;
@ExcelField(title="ignore_req_nocache",dictType="IGNORE_REQ_NOCACHE",sort=8)
private String ignore_req_nocache;
@ExcelField(title="ignore_res_nocache",dictType="IGNORE_RES_NOCACHE",sort=9)
private String ignore_res_nocache;
@ExcelField(title="inactive_time",sort=14)
private String inactive_time;
@ExcelField(title="max_cache_obj_size",sort=15)
private String max_cache_obj_size;
@ExcelField(title="max_cache_size",sort=13)
private String max_cache_size;
@ExcelField(title="min_use",sort=11)
private String min_use;
@ExcelField(title="no_revalidate",dictType="CACHE_NO_REVALIDATE",sort=5)
private String no_revalidate;
@ExcelField(title="pinning_time",dictType="",sort=12)
private String pinning_time;
@ExcelField(title="ignore_query_string",sort=3)
private String ignore_qs;
@ExcelField(title="include_cookie",sort=4)
private String cookie;
private Map<String,String> cache_key;
private BaseStringCfg strCfg;
@ExcelField(title="action",sort=2)
protected String actionCode;
public String getActionCode() {
return actionCode;
}
public void setActionCode(String actionCode) {
this.actionCode = actionCode;
}
public BaseStringCfg getStrCfg() {
return strCfg;
}
public void setStrCfg(BaseStringCfg strCfg) {
this.strCfg = strCfg;
}
public Map<String, String> getCache_key() {
return cache_key;
}
public void setCache_key(Map<String, String> cache_key) {
this.cache_key = cache_key;
}
public String getIgnore_res_nocache() {
return ignore_res_nocache;
}
public void setIgnore_res_nocache(String ignore_res_nocache) {
this.ignore_res_nocache = ignore_res_nocache;
}
public String getCache_cookied_cont() {
return cache_cookied_cont;
}
public void setCache_cookied_cont(String cache_cookied_cont) {
this.cache_cookied_cont = cache_cookied_cont;
}
public String getCache_dyn_url() {
return cache_dyn_url;
}
public void setCache_dyn_url(String cache_dyn_url) {
this.cache_dyn_url = cache_dyn_url;
}
public String getForce_caching() {
return force_caching;
}
public void setForce_caching(String force_caching) {
this.force_caching = force_caching;
}
public String getIgnore_req_nocache() {
return ignore_req_nocache;
}
public void setIgnore_req_nocache(String ignore_req_nocache) {
this.ignore_req_nocache = ignore_req_nocache;
}
public String getInactive_time() {
return inactive_time;
}
public void setInactive_time(String inactive_time) {
this.inactive_time = inactive_time;
}
public String getMax_cache_obj_size() {
return max_cache_obj_size;
}
public void setMax_cache_obj_size(String max_cache_obj_size) {
this.max_cache_obj_size = max_cache_obj_size;
}
public String getMax_cache_size() {
return max_cache_size;
}
public void setMax_cache_size(String max_cache_size) {
this.max_cache_size = max_cache_size;
}
public String getMin_use() {
return min_use;
}
public void setMin_use(String min_use) {
this.min_use = min_use;
}
public String getNo_revalidate() {
return no_revalidate;
}
public void setNo_revalidate(String no_revalidate) {
this.no_revalidate = no_revalidate;
}
public String getPinning_time() {
return pinning_time;
}
public void setPinning_time(String pinning_time) {
this.pinning_time = pinning_time;
}
public String getIgnore_qs() {
return ignore_qs;
}
public void setIgnore_qs(String ignore_qs) {
this.ignore_qs = ignore_qs;
}
public String getCookie() {
return cookie;
}
public void setCookie(String cookie) {
this.cookie = cookie;
}
}

View File

@@ -3,39 +3,27 @@ package com.nis.web.controller.configuration.proxy;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.callback.ProxyFileStrategyCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CachePolicyUserRegion;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.FileDigestCfg;
import com.nis.domain.configuration.HttpBodyCfg;
import com.nis.domain.configuration.HttpReqHeadCfg;
import com.nis.domain.configuration.HttpResHeadCfg;
import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
@@ -43,7 +31,6 @@ import com.nis.util.StringUtil;
import com.nis.web.controller.BaseController;
import com.nis.web.security.UserUtils;
import jersey.repackaged.com.google.common.collect.Lists;
/**
* http重定向策略
@@ -233,166 +220,90 @@ public class CachePolicyController extends BaseController{
//http配置导出
/*@RequestMapping(value = "exportHttp")
public String exportHttp(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")CfgIndexInfo entity,String ids,RedirectAttributes redirectAttributes){
try {
//export data info
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap=new HashMap<String, String>();
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
//导出选中记录
if(!StringUtil.isEmpty(ids)){
for(String id:ids.split(",")){
Long.parseLong(id);
}
//List<CfgIndexInfo> list=ipCfgService.getListByCfgIdWithName(IpPortCfg.getTablename(), entity.getFunctionId(), ids);
}else{
//条件导出数据大于最大导出数,只导出最大导出条数
Page<CfgIndexInfo> pageInfo=new Page<CfgIndexInfo>(request, response,"a");
if(pageInfo.getCount()>Constants.MAX_EXPORT_SIZE){
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
}else{
pageInfo.setPageNo(1);
pageInfo.setPageSize(-1);
}
Page<CfgIndexInfo> page = cachePolicyService.getCachePolicyList(pageInfo, entity);
Properties prop = getMsgProp();
for (CfgIndexInfo str : page.getList()) {
if(entity.getFunctionId()!=210 && entity.getFunctionId()!=211){
String type="RESPONSE_CODE";
if(entity.getFunctionId()==207){
type="RESPONSE_CODE";
}else if(entity.getFunctionId()==208){
type="REDIRECT_RESPONSE_CODE";
}else if(entity.getFunctionId()==209){
type="CONTROL_REPLACE_ZONE";
}
String dictlabel= DictUtils.getDictLabel(type, str.getUserRegion1());
str.setUserRegion1(prop.getProperty(dictlabel));
if(entity.getFunctionId()==207 || entity.getFunctionId()==208){
if(StringUtil.isEmpty(str.getUserRegion2())){
if(!StringUtil.isEmpty(str.getUserRegion3())){
ProxyFileStrategyCfg file= new ProxyFileStrategyCfg();
file.setCompileId(Integer.valueOf(str.getUserRegion3()));
List<ProxyFileStrategyCfg> allProxyFileStrategys = proxyFileStrategyService.getProxyFileStrategyCfgList(file);
if(allProxyFileStrategys!=null && allProxyFileStrategys.size()>0){
str.setUserRegion2(allProxyFileStrategys.get(0).getCfgDesc());
}
}
}
}
}
}
String cfgIndexInfoNoExport=",policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
if(entity.getFunctionId()==207){
cfgIndexInfoNoExport=",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:response_code-userregion2:response_content-";
}else if(entity.getFunctionId()==208){
cfgIndexInfoNoExport=",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:redirect_response_code-userregion2:redirect_url-";
}else if(entity.getFunctionId()==209){
cfgIndexInfoNoExport=",policy_name,group_name,userregion3,userregion4,userregion5,&userregion1:replace_zone-userregion2:replaced_content-userregion3:replace_content-";
}else if(entity.getFunctionId()==211){
cfgIndexInfoNoExport=",do_log,log_total,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,";
}
String httpUrlCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpReqHeadCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpResHeadCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpReqBodyCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
String httpResBodyCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
String ipPortCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,ir_type,group_name,";
String ntcSubscribeIdCfgNoExport=",do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
List<BaseStringCfg> httpUrlList = new ArrayList<>();
List<ComplexkeywordCfg> httpReqHdrList = new ArrayList<>();
List<ComplexkeywordCfg> httpResHdrList = new ArrayList<>();
List<BaseStringCfg> httpReqBodyList = new ArrayList<>();
List<BaseStringCfg> httpResBodyList = new ArrayList<>();
List<IpPortCfg> ipPortList = new ArrayList<>();
List<BaseStringCfg> subscribeIdList = new ArrayList<>();
for (CfgIndexInfo cfg : page.getList()) {
Map<String, List> maps=cachePolicyService.exportCachePolicy(cfg);
httpUrlList.addAll(maps.get("NTC_HTTP_URL"));
httpReqHdrList.addAll(maps.get("NTC_HTTP_REQ_HDR"));
httpResHdrList.addAll(maps.get("NTC_HTTP_RES_HDR"));
httpReqBodyList.addAll(maps.get("NTC_HTTP_REQ_BODY"));
httpResBodyList.addAll(maps.get("NTC_HTTP_RES_BODY"));
ipPortList.addAll(maps.get("NTC_UNIVERSAL_IP"));
subscribeIdList.addAll(maps.get("NTC_SUBSCRIBE_ID"));
}
httpUrlList=BaseStringCfg.replaceBaseKeyList(httpUrlList);
httpReqHdrList=ComplexkeywordCfg.replaceComplexKeyList(httpReqHdrList);
httpResHdrList=ComplexkeywordCfg.replaceComplexKeyList(httpResHdrList);
httpReqBodyList=BaseStringCfg.replaceBaseKeyList(httpReqBodyList);
httpResBodyList=BaseStringCfg.replaceBaseKeyList(httpResBodyList);
subscribeIdList=BaseStringCfg.baseHexList(subscribeIdList);
titleList.add(entity.getMenuNameCode());
titleList.add("NTC_HTTP_URL");
titleList.add("NTC_HTTP_REQ_HDR");
classMap.put(entity.getMenuNameCode(), CfgIndexInfo.class);
classMap.put("NTC_HTTP_URL", HttpUrlCfg.class);
classMap.put("NTC_HTTP_REQ_HDR", HttpReqHeadCfg.class);
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
noExportMap.put("NTC_HTTP_URL", httpUrlCfgNoExport);
noExportMap.put("NTC_HTTP_REQ_HDR", httpReqHeadCfgNoExport);
dataMap.put(entity.getMenuNameCode(), page.getList());
dataMap.put("NTC_HTTP_URL", httpUrlList);
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
if(entity.getFunctionId()!=208 && entity.getFunctionId()!=211){
titleList.add("NTC_HTTP_RES_BODY");
classMap.put("NTC_HTTP_RES_BODY", HttpBodyCfg.class);
noExportMap.put("NTC_HTTP_RES_BODY", httpResBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
}else if(entity.getFunctionId()!=211){
titleList.add("NTC_HTTP_RES_HDR");
titleList.add("NTC_HTTP_REQ_BODY");
classMap.put("NTC_HTTP_RES_HDR", HttpResHeadCfg.class);
classMap.put("NTC_HTTP_REQ_BODY", HttpBodyCfg.class);
noExportMap.put("NTC_HTTP_RES_HDR", httpResHeadCfgNoExport);
noExportMap.put("NTC_HTTP_REQ_BODY", httpReqBodyCfgNoExport);
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
}
titleList.add("NTC_UNIVERSAL_IP");
titleList.add("NTC_SUBSCRIBE_ID");
classMap.put("NTC_UNIVERSAL_IP", IpPortCfg.class);
classMap.put("NTC_SUBSCRIBE_ID", NtcSubscribeIdCfg.class);
noExportMap.put("NTC_UNIVERSAL_IP", ipPortCfgNoExport);
noExportMap.put("NTC_SUBSCRIBE_ID", ntcSubscribeIdCfgNoExport);
dataMap.put("NTC_UNIVERSAL_IP", ipPortList);
dataMap.put("NTC_SUBSCRIBE_ID",subscribeIdList);
}
this._export(model, request, response, redirectAttributes,entity.getMenuNameCode(),titleList,classMap,dataMap,noExportMap);
} catch (Exception e) {
logger.error("http export failed",e);
addMessage(redirectAttributes, "export_failed");
@RequestMapping(value = "exportCache")
public void exportdomain(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")CachePolicyUserRegion entity,String ids,RedirectAttributes redirectAttributes){
try {
//export data info
List<String> titleList=new ArrayList<String>();
Map<String, Class<?>> classMap=new HashMap<String, Class<?>>();
Map<String, List> dataMap=new HashMap<String, List>();
Map<String, String> noExportMap = new HashMap<String, String>();
List<CachePolicyUserRegion> ipLists = new ArrayList<CachePolicyUserRegion>();
// 导出选中记录
if (!StringUtil.isEmpty(ids)) {
ipLists = cachePolicyService.getCachePolicyByUserRegionList(ids);
} else {
Page<CachePolicyUserRegion> pageInfo=new Page<CachePolicyUserRegion>(request, response,"a");
pageInfo.setPageNo(1);
pageInfo.setPageSize(Constants.MAX_EXPORT_SIZE);
Page<CachePolicyUserRegion> page = cachePolicyService.getCachePolicyUserRegionList(pageInfo, entity);
ipLists = page.getList();
}
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+entity.getFunctionId();
}*/
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
Properties msgProp = getMsgProp();
for (CachePolicyUserRegion cache : ipLists) {
for (FunctionServiceDict service : serviceList) {
if(cache.getAction().intValue()==service.getAction().intValue()){
cache.setActionCode(msgProp.getProperty(service.getActionCode(),service.getActionCode()));
}
}
}
titleList.add(entity.getMenuNameCode());
titleList.add("PXY_CACHE_HTTP_URL");
titleList.add("PXY_CACHE_HTTP_COOKIE");
classMap.put(entity.getMenuNameCode(), CachePolicyUserRegion.class);
classMap.put("PXY_CACHE_HTTP_URL", HttpUrlCfg.class);
classMap.put("PXY_CACHE_HTTP_COOKIE", HttpUrlCfg.class);
String cfgIndexInfoNoExport=",block_type,policy_name,group_name,userregion1,userregion2,userregion3,userregion4,userregion5,&action:block_type-";
String httpUrlInfoNoExport=",block_type,do_log,action,config_describe,valid_identifier,is_audit,creator,creator"
+ ",config_time,editor,edit_time,auditor,audit_time"
+",letter,whether_area_block,classification,attribute,label"
+",userregion1,userregion2,userregion3,userregion4,userregion5,";
// 时间过滤
if (entity.getSearch_create_time_start() == null) {
cfgIndexInfoNoExport = ",config_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_edit_time_start() == null) {
cfgIndexInfoNoExport = ",edit_time" + cfgIndexInfoNoExport;
}
if (entity.getSearch_audit_time_start() == null) {
cfgIndexInfoNoExport = ",audit_time" + cfgIndexInfoNoExport;
}
if (!StringUtil.isEmpty(entity.gethColumns())) {
cfgIndexInfoNoExport = "," + entity.gethColumns() + "," + cfgIndexInfoNoExport;
}
noExportMap.put(entity.getMenuNameCode(),cfgIndexInfoNoExport);
noExportMap.put("PXY_CACHE_HTTP_URL", httpUrlInfoNoExport);
noExportMap.put("PXY_CACHE_HTTP_COOKIE", httpUrlInfoNoExport);
List<BaseStringCfg> urlList=new ArrayList<BaseStringCfg>();
List<BaseStringCfg> cookieList=new ArrayList<BaseStringCfg>();
for (CachePolicyUserRegion cfg : ipLists) {
Map<String, List> maps=cachePolicyService.getExport(Long.valueOf(cfg.getCfgId()));
urlList.addAll(maps.get("PXY_CACHE_HTTP_URL"));
cookieList.addAll(maps.get("PXY_CACHE_HTTP_COOKIE"));
}
urlList=BaseStringCfg.replaceBaseKeyList(urlList);
cookieList=BaseStringCfg.replaceBaseKeyList(cookieList);
dataMap.put(entity.getMenuNameCode(), ipLists);
dataMap.put("PXY_CACHE_HTTP_URL", urlList);
dataMap.put("PXY_CACHE_HTTP_COOKIE", cookieList);
/*}*/
String timeRange = initTimeMap(entity);
noExportMap.put("timeRange", timeRange);
if ("csv".equals(entity.getExType())) {
this._exportCsv(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
} else {
this._export(model, request, response, redirectAttributes, entity.getMenuNameCode(), titleList,
classMap, dataMap, noExportMap);
}
} catch (Exception e) {
logger.error("ip white export failed",e);
addMessage(redirectAttributes,"error", "export_failed");
}
}
}

View File

@@ -1,13 +1,11 @@
package com.nis.web.dao.configuration;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CachePolicyUserRegion;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.IpPortCfg;
@@ -39,4 +37,8 @@ public interface CommonPolicyDao {
public void deleteHttpUrlCfg(@Param("tableName")String tableName,
@Param("entity")BaseCfg baseCfg,
@Param("compileIds")List compileIds);
public List<CachePolicyUserRegion> getCachePolicyUserRegionList(CachePolicyUserRegion entity);
public List<CachePolicyUserRegion> getCachePolicyByUserRegionList(@Param("ids")String ids);
}

View File

@@ -34,6 +34,42 @@
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
</resultMap>
<resultMap id="CacheMap" type="com.nis.domain.configuration.CachePolicyUserRegion" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="action" property="action" jdbcType="INTEGER" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
<result column="is_audit" property="isAudit" jdbcType="INTEGER" />
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
<result column="auditor_id" property="auditorId" jdbcType="INTEGER" />
<result column="audit_time" property="auditTime" jdbcType="TIMESTAMP" />
<result column="service_id" property="serviceId" jdbcType="INTEGER" />
<result column="request_id" property="requestId" jdbcType="INTEGER" />
<result column="compile_id" property="compileId" jdbcType="INTEGER" />
<result column="is_area_effective" property="isAreaEffective" jdbcType="INTEGER" />
<result column="classify" property="classify" jdbcType="VARCHAR" />
<result column="attribute" property="attribute" jdbcType="VARCHAR" />
<result column="lable" property="lable" jdbcType="VARCHAR" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="dns_strategy_id" property="dnsStrategyId" jdbcType="INTEGER" />
<result column="dns_strategy_name" property="dnsStrategyName" jdbcType="VARCHAR" />
<result column="do_log" property="doLog" jdbcType="INTEGER" />
<result column="user_region1" property="userRegion1" jdbcType="VARCHAR" />
<result column="user_region2" property="userRegion2" jdbcType="VARCHAR" />
<result column="user_region3" property="userRegion3" jdbcType="VARCHAR" />
<result column="user_region4" property="userRegion4" jdbcType="VARCHAR" />
<result column="user_region5" property="userRegion5" jdbcType="VARCHAR" />
<result column="source_compile_id" property="sourceCompileId" jdbcType="INTEGER" />
<result column="cancel_request_id" property="cancelRequestId" jdbcType="INTEGER" />
<result column="do_blacklist" property="doBlackList" jdbcType="INTEGER" />
</resultMap>
<resultMap id="ipPortMap" type="com.nis.domain.configuration.IpPortCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
@@ -814,4 +850,119 @@
</foreach>
</where>
</select>
<select id="getCachePolicyUserRegionList" resultMap="CacheMap" parameterType="com.nis.domain.configuration.CachePolicyUserRegion" >
SELECT
<include refid="ConfigIndex_Column" />
<trim prefix="," prefixOverrides=",">
, s.name as creator_name,e.name as editor_name,u.name as auditor_name
,ri.request_title as requestName
</trim>
FROM cfg_index_info a
left join sys_user s on a.creator_id=s.id
left join sys_user e on a.editor_id=e.id
left join sys_user u on a.auditor_id=u.id
left join request_info ri on a.request_id=ri.id
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="page !=null and page.where != null and page.where != ''">
AND ${page.where}
</if>
<if test="cfgId != null">
AND a.CFG_ID=#{cfgId,jdbcType=BIGINT}
</if>
<if test="cfgDesc != null and cfgDesc != ''">
AND a.CFG_DESC like concat(concat('%',#{cfgDesc,jdbcType=VARCHAR}),'%')
</if>
<if test="action != null">
AND a.ACTION=#{action,jdbcType=INTEGER}
</if>
<if test="isValid != null">
AND a.IS_VALID=#{isValid,jdbcType=INTEGER}
</if>
<if test="isValid == null">
AND a.IS_VALID != -1
</if>
<if test="isAudit != null">
AND a.IS_AUDIT=#{isAudit,jdbcType=INTEGER}
</if>
<if test="creatorName != null and creatorName != ''">
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
</if>
<if test="editorName != null and editorName != ''">
AND EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
</if>
<if test="auditorName != null and auditorName != ''">
AND AUDITOR_NAME like concat(concat('%',#{auditorName,jdbcType=VARCHAR}),'%')
</if>
<if test="serviceId != null">
AND a.SERVICE_ID=#{serviceId,jdbcType=INTEGER}
</if>
<if test="requestId != null">
AND a.REQUEST_ID=#{requestId,jdbcType=INTEGER}
</if>
<if test="compileId != null">
AND a.COMPILE_ID=#{compileId,jdbcType=INTEGER}
</if>
<if test="isAreaEffective != null">
AND a.IS_AREA_EFFECTIVE=#{isAreaEffective,jdbcType=INTEGER}
</if>
<if test="classify != null and classify != ''">
AND a.classify like concat(concat('%',#{classify,jdbcType=VARCHAR}),'%')
</if>
<if test="attribute != null and attribute != ''">
AND a.attribute like concat(concat('%',#{attribute,jdbcType=VARCHAR}),'%')
</if>
<if test="lable != null and lable != ''">
AND a.lable like concat(concat('%',#{lable,jdbcType=VARCHAR}),'%')
</if>
<if test="areaEffectiveIds != null and areaEffectiveIds != ''">
AND a.AREA_EFFECTIVE_IDS like concat(concat('%',#{areaEffectiveIds,jdbcType=VARCHAR}),'%')
</if>
<if test="functionId != null">
AND a.function_id=#{functionId,jdbcType=INTEGER}
</if>
<if test="strCfg!=null">
AND a.compile_id in (select f.compile_id from common_keyword_cfg f
<where>
<if test="strCfg.cfgKeywords != null and strCfg.cfgKeywords != ''">
AND REPLACE(f.cfg_keywords,'***and***','|') like concat(concat('%',#{strCfg.cfgKeywords,jdbcType=VARCHAR}),'%')
</if>
</where>
)
</if>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
ORDER BY ${page.orderBy}, a.is_audit,a.CFG_ID desc
</when>
<otherwise>
ORDER BY a.is_audit,a.CFG_ID desc
</otherwise>
</choose>
</select>
<select id="getCachePolicyByUserRegionList" resultMap="CacheMap" parameterType="com.nis.domain.configuration.CachePolicyUserRegion" >
SELECT
<include refid="ConfigIndex_Column" />
<trim prefix="," prefixOverrides=",">
, s.name as creator_name,e.name as editor_name,u.name as auditor_name
,ri.request_title as requestName
</trim>
FROM cfg_index_info a
left join sys_user s on a.creator_id=s.id
left join sys_user e on a.editor_id=e.id
left join sys_user u on a.auditor_id=u.id
left join request_info ri on a.request_id=ri.id
where a.CFG_ID in (${ids})
</select>
</mapper>

View File

@@ -16,9 +16,11 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.Page;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CachePolicyUserRegion;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.CommonStringCfg;
import com.nis.domain.configuration.HttpBodyCfg;
@@ -38,6 +40,7 @@ import com.nis.domain.maat.ToMaatResult;
import com.nis.exceptions.MaatConvertException;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.Constants;
import com.nis.util.DictUtils;
import com.nis.util.StringUtil;
import com.nis.web.dao.configuration.AreaIpCfgDao;
import com.nis.web.dao.configuration.CommonPolicyDao;
@@ -69,26 +72,81 @@ public class CachePolicyService extends CrudService<WebsiteCfgDao,CfgIndexInfo>
return entity;
}
/*public Map<String, List> exportCachePolicy(CfgIndexInfo entity){
public Page<CachePolicyUserRegion> getCachePolicyUserRegionList(Page<CachePolicyUserRegion> page, CachePolicyUserRegion entity){
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
entity.setPage(page);
List<CachePolicyUserRegion> list = commonPolicyDao.getCachePolicyUserRegionList(entity);
for (CachePolicyUserRegion c : list) {
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
c.setCache_cookied_cont(stu.getCache_cookied_cont());
c.setCache_dyn_url(stu.getCache_dyn_url());
c.setForce_caching(stu.getForce_caching());
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
c.setInactive_time(stu.getInactive_time());
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
c.setMax_cache_size(stu.getMax_cache_size());
c.setMin_use(stu.getMin_use());
c.setNo_revalidate(stu.getNo_revalidate());
c.setPinning_time(stu.getPinning_time());
if(stu.getCache_key()!=null){
String ignore=String.valueOf(stu.getCache_key().get("ignore_qs"));
String cookie=String.valueOf(stu.getCache_key().get("cookie"));
if(!ignore.equals("null") && ignore!=null){
c.setIgnore_qs(ignore);
}
if(!cookie.equals("null") && cookie!=null){
c.setCookie(cookie);
}
}
}
page.setList(list);
return page;
}
public List<CachePolicyUserRegion> getCachePolicyByUserRegionList(String ids){
List<CachePolicyUserRegion> list = commonPolicyDao.getCachePolicyByUserRegionList(ids);
for (CachePolicyUserRegion c : list) {
JSONObject jsonObject=JSONObject.fromObject(c.getUserRegion1());
CachePolicyUserRegion stu=(CachePolicyUserRegion)JSONObject.toBean(jsonObject, CachePolicyUserRegion.class);
c.setCache_cookied_cont(stu.getCache_cookied_cont());
c.setCache_dyn_url(stu.getCache_dyn_url());
c.setForce_caching(stu.getForce_caching());
c.setIgnore_req_nocache(stu.getIgnore_req_nocache());
c.setIgnore_res_nocache(stu.getIgnore_res_nocache());
c.setInactive_time(stu.getInactive_time());
c.setMax_cache_obj_size(stu.getMax_cache_obj_size());
c.setMax_cache_size(stu.getMax_cache_size());
c.setMin_use(stu.getMin_use());
c.setNo_revalidate(stu.getNo_revalidate());
c.setPinning_time(stu.getPinning_time());
if(stu.getCache_key()!=null){
String ignore=String.valueOf(stu.getCache_key().get("ignore_qs"));
String cookie=String.valueOf(stu.getCache_key().get("cookie"));
if(!ignore.equals("null") && ignore!=null){
c.setIgnore_qs(ignore);
}
if(!cookie.equals("null") && cookie!=null){
c.setCookie(cookie);
}
}
}
return list;
}
public Map<String, List> getExport(Long cfgId){
Map<String, List> dataMap=new HashMap<String, List>();
List<HttpUrlCfg> httpUrlList = commonPolicyDao.getHttpUrlList(entity);
List<HttpReqHeadCfg> httpReqHdrList = commonPolicyDao.getHttpReqHdrList(entity);
List<HttpResHeadCfg> httpResHdrList = commonPolicyDao.getHttpResHdrList(entity);
List<IpPortCfg> ipPortCfgList = commonPolicyDao.getIpPortList(entity);
entity.setCfgType(Constants.HTTP_REDIRECT_REQ_BODY_REGION);
List<HttpBodyCfg> httpReqBodyList = commonPolicyDao.getHttpReqBodyList(entity);
entity.setCfgType(Constants.HTTP_REDIRECT_RES_BODY_REGION);
List<HttpBodyCfg> httpResBodyList = commonPolicyDao.getHttpResBodyList(entity);
List<NtcSubscribeIdCfg> subscribeIdList = stringCfgDao.findSubscribeIdCfgListByCfgIndexInfo(entity);
dataMap.put("NTC_UNIVERSAL_IP", ipPortCfgList);
dataMap.put("NTC_CACHE_URL", httpUrlList);
dataMap.put("NTC_HTTP_REQ_HDR", httpReqHdrList);
dataMap.put("NTC_HTTP_RES_HDR", httpResHdrList);
dataMap.put("NTC_HTTP_REQ_BODY", httpReqBodyList);
dataMap.put("NTC_HTTP_RES_BODY", httpResBodyList);
dataMap.put("NTC_SUBSCRIBE_ID", subscribeIdList);
CfgIndexInfo entity = commonPolicyDao.getPolicyById(cfgId);
entity.setCfgType("PXY_CACHE_HTTP_URL");
List<BaseStringCfg> urlList = commonPolicyDao.getCommonStringList(entity);
entity.setCfgType("PXY_CACHE_HTTP_COOKIE");
List<BaseStringCfg> cookieList = commonPolicyDao.getCommonStringList(entity);
dataMap.put("PXY_CACHE_HTTP_URL", urlList);
dataMap.put("PXY_CACHE_HTTP_COOKIE", cookieList);
return dataMap;
}*/
}
public Page<CfgIndexInfo> getCachePolicyList(Page<CfgIndexInfo> page, CfgIndexInfo entity){
// 生成数据权限过滤条件dsf为dataScopeFilter的简写在xml中使用 ${sqlMap.dsf}调用权限SQL

View File

@@ -180,19 +180,18 @@
<shiro:hasPermission name="${configPermissionName }">
<sys:delRow url="${ctx}/proxy/cache/form" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/proxy/cache/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<%-- <sys:delRow url="${ctx}/proxy/cache/exportHttp?functionId=${cfg.functionId }" id="contentTable" searchUrl="${actionPath }" label="export"></sys:delRow> --%>
</shiro:hasPermission>
<!-- <div class="btn-group"> -->
<!-- <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> -->
<%-- <i class="fa fa-wrench"></i> <spring:message code="export"></spring:message> --%>
<!-- <i class="fa fa-angle-down"></i> -->
<!-- </button> -->
<!-- <ul class="dropdown-menu pull-right" style="min-width: 110px;" > -->
<%-- <li><sys:delRow url="${ctx}/proxy/cache/exportHttp?functionId=${cfg.functionId }&exType=excel" id="contentTable" searchUrl="${actionPath }" label="cfg_excel"></sys:delRow></li> --%>
<%-- <li><sys:delRow url="${ctx}/proxy/cache/exportHttp?functionId=${cfg.functionId }&exType=csv" id="contentTable" searchUrl="${actionPath }" label="cfg_csv"></sys:delRow></li> --%>
<!-- </ul> -->
<!-- </div> -->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-wrench"></i> <spring:message code="export"></spring:message>
<i class="fa fa-angle-down"></i>
</button>
<ul class="dropdown-menu pull-right" style="min-width: 110px;" >
<li><sys:delRow url="${ctx}/proxy/cache/exportCache?functionId=${cfg.functionId }&exType=excel" id="contentTable" searchUrl="${actionPath }" label="cfg_excel"></sys:delRow></li>
<li><sys:delRow url="${ctx}/proxy/cache/exportCache?functionId=${cfg.functionId }&exType=csv" id="contentTable" searchUrl="${actionPath }" label="cfg_csv"></sys:delRow></li>
</ul>
</div>
<shiro:hasPermission name="${confirmPermissionName }">
<div class="btn-group">