缓存策略配置提交

Signed-off-by: zhangwei <zhangwei2@iie.ac.cn>
This commit is contained in:
zhangwei
2018-11-12 18:39:57 +08:00
parent b915a53f9b
commit 644570ccc4
16 changed files with 5335 additions and 2222 deletions

View File

@@ -9,6 +9,9 @@
package com.nis.domain.configuration;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.cache.CacheKey;
import com.nis.domain.basics.AsnIpCfg;
import com.nis.util.excel.ExcelField;
@@ -60,6 +63,8 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
private List<InterceptPktBin> interceptPktBinList;
private AvContUrlCfg avContUrlCfg;
private List<AvContUrlCfg> avContUrlCfgList;
private BaseStringCfg strCfg;
private ComplexkeywordCfg complexCfg;
private Long dnsStrategyId;
@ExcelField(title="policy_name",sort=21)
@@ -74,6 +79,18 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
private Integer sourceCompileId;
private String searchKeywords;// 列表关键字查询字段
private Map<String,Object> userRegion;
/*private CachePolicyUserRegion cachePolicyUserRegion;//缓存策略用户自定义域参数
public static class CachePolicyUserRegion{
private CacheKey cache_key;
public static class CecheKey{
}
}*/
public Integer getSourceCompileId() {
return sourceCompileId;
}
@@ -331,5 +348,24 @@ public class CfgIndexInfo extends BaseCfg<CfgIndexInfo> {
public void setSearchKeywords(String searchKeywords) {
this.searchKeywords = searchKeywords;
}
public Map<String, Object> getUserRegion() {
return userRegion;
}
public void setUserRegion(Map<String, Object> userRegion) {
this.userRegion = userRegion;
}
public BaseStringCfg getStrCfg() {
return strCfg;
}
public void setStrCfg(BaseStringCfg strCfg) {
this.strCfg = strCfg;
}
public ComplexkeywordCfg getComplexCfg() {
return complexCfg;
}
public void setComplexCfg(ComplexkeywordCfg complexCfg) {
this.complexCfg = complexCfg;
}
}

View File

@@ -0,0 +1,46 @@
/**
*@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;
/**
* @ClassName: CommonStringConfig.java
* @Description: 通用字符串配置对象类[后期业务扩展使用]
* @author (zhangwei)
* @date 2018年11月8日 下午1:58:05
* @version V1.0
*/
public class CommonStringCfg extends BaseStringCfg<CommonStringCfg> {
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么 *
* @since 1.0.0
*/
private static final long serialVersionUID = -5912532490412412005L;
private static final String tableName="common_keyword_cfg";
/* (non-Javadoc)
* @see com.nis.domain.configuration.BaseStringCfg#initDefaultValue()
*/
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.matchMethod=0;
}
public static String getTablename() {
return tableName;
}
private String replaceContent;
public String getReplaceContent() {
return replaceContent;
}
public void setReplaceContent(String replaceContent) {
this.replaceContent = replaceContent;
}
}

View File

@@ -0,0 +1,41 @@
/**
*@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;
/**
* @ClassName: ComplexStringCfg.java
* @Description: 通用增强字符串类配置[后期业务扩展使用]
* @author (zhangwei)
* @date 2018年11月8日 下午2:00:52
* @version V1.0
*/
public class ComplexStringCfg extends ComplexkeywordCfg {
/**
* @Fields serialVersionUID:TODO用一句话描述这个变量表示什么
*
* @since 1.0.0
*/
private static final long serialVersionUID = -2248641720522865575L;
private static final String tableName="complex_keyword_cfg";
/* (non-Javadoc)
* @see com.nis.domain.configuration.ComplexkeywordCfg#initDefaultValue()
*/
@Override
public void initDefaultValue() {
// TODO Auto-generated method stub
super.initDefaultValue();
this.exprType=0;
this.matchMethod=0;
this.isHexbin=0;
}
public static String getTablename() {
return tableName;
}
}

View File

@@ -113,6 +113,7 @@ import com.nis.web.service.configuration.AsnPolicyCfgService;
import com.nis.web.service.configuration.AvCfgService;
import com.nis.web.service.configuration.AvContentCfgService;
import com.nis.web.service.configuration.BgpCfgService;
import com.nis.web.service.configuration.CachePolicyService;
import com.nis.web.service.configuration.ComplexStringCfgService;
import com.nis.web.service.configuration.ControlPolicyService;
import com.nis.web.service.configuration.DdosCfgService;
@@ -248,6 +249,8 @@ public class BaseController {
protected GroupAreaService groupAreaService;// 分组区域管理 service
//@Autowired
//protected ConfigGroupInfoService configGroupInfoService;
@Autowired
protected CachePolicyService cachePolicyService;
/**
* 管理基础路径
*/

View File

@@ -0,0 +1,367 @@
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.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.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;
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重定向策略
* @author zhangwei
*
*/
@Controller
@RequestMapping("${adminPath}/proxy/cache")
public class CachePolicyController extends BaseController{
@RequestMapping(value = {"list"})
public String list(Model model,HttpServletRequest request,HttpServletResponse response,@ModelAttribute("cfg")CfgIndexInfo cfg){
Page<CfgIndexInfo> searchPage=new Page<CfgIndexInfo>(request,response,"a");
Page<CfgIndexInfo> page = cachePolicyService.getCachePolicyList(searchPage, cfg);
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/proxy/cache/list";
}
@RequestMapping(value = {"form"})
@RequiresPermissions(value={"cache:policy:config"})
public String form(Model model,HttpServletRequest request,HttpServletResponse response,String ids,CfgIndexInfo entity){
if(StringUtils.isNotBlank(ids)){
entity = cachePolicyService.getCachePolicy(Long.parseLong(ids));
initUpdateFormCondition(model,entity);
}else{
initFormCondition(model,entity);
}
model.addAttribute("_cfg", entity);
return "/cfg/proxy/cache/form";
}
@RequestMapping(value = {"saveOrUpdate"})
@RequiresPermissions(value={"cache:policy:config"})
public String saveOrUpdate(Model model,HttpServletRequest request,HttpServletResponse response,
@ModelAttribute("cfg")CfgIndexInfo cfg,RedirectAttributes redirectAttributes){
try{
if(cfg.getAction().equals(128)){//不为白名单时保存自定义域
cfg.setUserRegion(null);
}else{
String ignore_qs = request.getParameter("ignore_qs").trim();
String hdrs = request.getParameter("hdrs").trim();
String cookie = request.getParameter("cookie").trim();
Map<String,Object> map = new HashMap();
if(!StringUtil.isBlank(ignore_qs)){
map.put("ignore_qs", ignore_qs.split(","));
}
if(!StringUtil.isBlank(hdrs)){
map.put("hdrs",hdrs);
}
if(!StringUtil.isBlank(cookie)){
map.put("cookie", cookie);
}
cfg.getUserRegion().put("cache_key", map);
if(!StringUtil.isEmpty(cfg.getUserRegion().get("min_use"))){
cfg.getUserRegion().put("min_use",Integer.parseInt(cfg.getUserRegion().get("no_revalidate").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("cache_dyn_url"))){
cfg.getUserRegion().put("cache_dyn_url",Integer.parseInt(cfg.getUserRegion().get("cache_dyn_url").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("cache_cookied_cont"))){
cfg.getUserRegion().put("cache_cookied_cont",Integer.parseInt(cfg.getUserRegion().get("cache_cookied_cont").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("ignore_req_nocache"))){
cfg.getUserRegion().put("ignore_req_nocache",Integer.parseInt(cfg.getUserRegion().get("ignore_req_nocache").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("ignore_res_nocache"))){
cfg.getUserRegion().put("ignore_res_nocache",Integer.parseInt(cfg.getUserRegion().get("ignore_res_nocache").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("force_caching"))){
cfg.getUserRegion().put("force_caching",Integer.parseInt(cfg.getUserRegion().get("force_caching").toString()));
}
if(!StringUtil.isEmpty(cfg.getUserRegion().get("min_use"))){
cfg.getUserRegion().put("min_use",Integer.parseInt(cfg.getUserRegion().get("min_use").toString()));
}
}
cachePolicyService.saveCachePolicy(cfg);
addMessage(redirectAttributes,"success","save_success");
}catch(Exception e){
logger.error("信息保存失败",e);
e.printStackTrace();
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
}else {
addMessage(redirectAttributes,"error","save_failed");
}
}
return "redirect:" + adminPath +"/proxy/cache/list?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"ajaxCacheSubList"})
public String ajaxCacheSubList(Model model,Long cfgId,Integer index) {
CfgIndexInfo cfg = cachePolicyService.getCachePolicy(cfgId);
List<String[]> tabList = new ArrayList();
if(cfg.getIpPortList()!=null){
String cfgType = null;
for(IpPortCfg ip:cfg.getIpPortList()){
if(!ip.getCfgType().equals(cfgType)){
tabList.add(new String[]{"1",ip.getCfgType()});
cfgType = ip.getCfgType();
}
}
}
if(cfg.getComplexList()!=null){
String cfgType = null;
for(ComplexkeywordCfg keyword:cfg.getComplexList()){
if(!keyword.getCfgType().equals(cfgType)){
tabList.add(new String[]{"3",keyword.getCfgType()});
cfgType = keyword.getCfgType();
}
}
}
if(cfg.getStringList()!=null){
String cfgType = null;
for(BaseStringCfg strCfg:cfg.getStringList()){
if(!strCfg.getCfgType().equals(cfgType)){
tabList.add(new String[]{"2",strCfg.getCfgType()});
cfgType = strCfg.getCfgType();
}
}
}
model.addAttribute("_cfg", cfg);
model.addAttribute("index", index);
model.addAttribute("tabList", tabList);
return "/cfg/proxy/cache/cachePolicySubList";
}
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"cache:policy:config"})
public String delete(Integer isAudit,Integer isValid,String ids,Integer functionId){
cachePolicyService.updateCachePolicyValid(isValid,ids,functionId);
return "redirect:" + adminPath +"/proxy/cache/list?functionId="+functionId;
}
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"cache:policy:confirm"})
public String audit(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes) {
CfgIndexInfo entity = new CfgIndexInfo();
String[] idArray = ids.split(",");
for(String id :idArray){
entity = cachePolicyService.getCachePolicy(Long.parseLong(id));
entity.setIsAudit(isAudit);
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
entity.setFunctionId(functionId);
try {
cachePolicyService.auditCachePolicy(entity,isAudit);
} catch ( Exception e) {
e.printStackTrace();
logger.info("代理缓存策略下发失败:"+e.getMessage());
if(e instanceof MaatConvertException) {
addMessage(redirectAttributes,"error","request_service_failed");
}else {
addMessage(redirectAttributes,"error","audit_failed");
}
}
}
return "redirect:" + adminPath +"/proxy/cache/list?functionId="+functionId;
}
//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");
}
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+entity.getFunctionId();
}*/
}

View File

@@ -0,0 +1,31 @@
package com.nis.web.dao.configuration;
import java.util.List;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.web.dao.MyBatisDao;
@MyBatisDao
public interface CommonPolicyDao {
public List<CfgIndexInfo> getPolicyList(CfgIndexInfo entity);
public CfgIndexInfo getPolicyById(Long cfgId);
public List<IpPortCfg> getIpPortList(CfgIndexInfo entity);
public List<BaseStringCfg> getCommonStringList(CfgIndexInfo entity);
public List<ComplexkeywordCfg> getComplexStringList(CfgIndexInfo entity);
public void saveCfgIndex(CfgIndexInfo entity);
public void saveIpPortCfg(IpPortCfg entity);
public void saveCommonStringCfg(BaseStringCfg entity);
public void saveComplexStringCfg(ComplexkeywordCfg entity);
public void updateCfgIndex(CfgIndexInfo entity);
public void deleteIpPortCfg(CfgIndexInfo entity);
public void deleteCommonStringCfg(CfgIndexInfo entity);
public void deleteComplexStringCfg(CfgIndexInfo entity);
public void updateCfgValid(BaseCfg entity);
public void auditCfg(BaseCfg entity);
}

View File

@@ -0,0 +1,736 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.nis.web.dao.configuration.CommonPolicyDao" >
<resultMap id="CfgIndexInfoMap" type="com.nis.domain.configuration.CfgIndexInfo" >
<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" />
</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" />
<result column="ip_type" property="ipType" jdbcType="INTEGER" />
<result column="ip_pattern" property="ipPattern" jdbcType="INTEGER" />
<result column="dest_ip_address" property="destIpAddress" jdbcType="VARCHAR" />
<result column="src_ip_address" property="srcIpAddress" jdbcType="VARCHAR" />
<result column="dest_port" property="destPort" jdbcType="VARCHAR" />
<result column="src_port" property="srcPort" jdbcType="VARCHAR" />
<result column="port_pattern" property="portPattern" jdbcType="INTEGER" />
<result column="direction" property="direction" jdbcType="INTEGER" />
<result column="protocol" property="protocol" jdbcType="INTEGER" />
<result column="protocol_id" property="protocolId" jdbcType="INTEGER" />
<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="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="stringCfgMap" type="com.nis.domain.configuration.BaseStringCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" 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="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="complexCfgMap" type="com.nis.domain.configuration.ComplexkeywordCfg" >
<id column="cfg_id" property="cfgId" jdbcType="BIGINT" />
<result column="cfg_desc" property="cfgDesc" jdbcType="VARCHAR" />
<result column="cfg_keywords" property="cfgKeywords" jdbcType="VARCHAR" />
<result column="district" property="district" jdbcType="VARCHAR" />
<result column="cfg_type" property="cfgType" 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="expr_type " property="exprType" jdbcType="INTEGER" />
<result column="match_method" property="matchMethod" jdbcType="INTEGER" />
<result column="is_hexbin" property="isHexbin" jdbcType="INTEGER" />
<result column="area_effective_ids" property="areaEffectiveIds" jdbcType="VARCHAR" />
<result column="function_id" property="functionId" jdbcType="INTEGER" />
<result column="cfg_region_code" property="cfgRegionCode" jdbcType="INTEGER" />
<result column="cfg_type" property="cfgType" jdbcType="VARCHAR" />
</resultMap>
<sql id="ConfigIndex_Column" >
a.CFG_ID,a.CFG_DESC,a.ACTION,a.IS_VALID,a.IS_AUDIT,
a.CREATOR_ID,a.CREATE_TIME,a.EDITOR_ID,a.EDIT_TIME,a.AUDITOR_ID,a.AUDIT_TIME,
a.SERVICE_ID,a.REQUEST_ID,a.COMPILE_ID,a.IS_AREA_EFFECTIVE,a.CLASSIFY,
a.ATTRIBUTE,a.LABLE,a.AREA_EFFECTIVE_IDS,a.function_id,a.dns_strategy_id,a.user_region1,
a.user_region2,a.user_region3,a.user_region4,a.user_region5,a.do_log,a.source_compile_id,a.cancel_request_id
</sql>
<sql id="IpCfg_Column" >
a.cfg_id,a.cfg_desc,a.ip_type,a.src_ip_address,a.ip_pattern,a.port_pattern,a.src_port
,a.protocol,a.protocol_id,a.direction,a.cfg_type,a.action,a.dest_port,a.dest_ip_address
,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id
,a.edit_time,a.auditor_id,a.audit_time,a.service_id,a.request_id,
a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable
,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="StrCfg_Column" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<sql id="ComplexCfg_Column" >
a.cfg_id,a.cfg_desc,a.cfg_keywords,a.cfg_type,a.district,
a.action,a.is_valid,a.is_audit,a.creator_id,a.create_time,a.editor_id,a.edit_time, a.auditor_id,
a.audit_time,a.service_id,a.request_id,a.compile_id,a.is_area_effective,a.classify,a.attribute,a.lable,
a.expr_type,a.match_method,a.is_hexbin,a.area_effective_ids,a.function_id,a.cfg_region_code
</sql>
<select id="getPolicyList" resultMap="CfgIndexInfoMap" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
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="ipPort!=null">
AND a.compile_id in (select t.compile_id from ip_port_cfg t
<where>
<if test="functionId != null">
AND t.function_id=#{functionId,jdbcType=INTEGER}
</if>
<if test="ipPort.srcIpAddress != null and ipPort.srcIpAddress != ''">
and t.src_ip_address =#{ipPort.srcIpAddress,jdbcType=VARCHAR}
</if>
<if test="ipPort.srcPort != null and ipPort.srcPort != ''">
and t.src_port =#{ipPort.srcPort,jdbcType=VARCHAR}
</if>
<if test="ipPort.destIpAddress != null and ipPort.destIpAddress != ''">
and t.dest_ip_address =#{ipPort.destIpAddress,jdbcType=VARCHAR}
</if>
<if test="ipPort.destPort != null and ipPort.destPort != ''">
and t.dest_port =#{ipPort.destPort,jdbcType=VARCHAR}
</if>
</where>
)
</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>
<if test="complexCfg!=null">
AND a.compile_id in (select f.compile_id from complex_keyword_cfg f
<where>
<if test="complexCfg.cfgKeywords != null and complexCfg.cfgKeywords != ''">
AND REPLACE(f.cfg_keywords,'***and***','|') like concat(concat('%',#{complexCfg.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}
</when>
<otherwise>
ORDER BY a.CFG_ID desc
</otherwise>
</choose>
</select>
<select id="getPolicyById" resultMap="CfgIndexInfoMap" parameterType="java.lang.Long">
SELECT
<include refid="ConfigIndex_Column" />
FROM cfg_index_info a where cfg_id=#{cfgId}
</select>
<!-- <select id="getCfgIndexList" resultMap="CfgIndexInfoMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="ConfigIndex_Column" />
FROM cfg_index_info a
<where>
<if test="cfgId != null">
and cfg_id=#{cfgId}
</if>
<if test="compileId != null">
and compileId=#{compileId}
</if>
<if test="functionId != null">
and function_id=#{functionId}
</if>
</where>
</select> -->
<select id="getIpPortList" resultMap="ipPortMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="IpCfg_Column" />
FROM ip_port_cfg a where compile_id=#{compileId} and function_id=#{functionId}
</select>
<select id="getCommonStringList" resultMap="stringCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="StrCfg_Column" />
FROM common_keyword_cfg a
<where>
<if test="compileId != null">
AND a.compile_id =#{compileId}
</if>
<if test="functionId != null">
AND a.function_id =#{functionId}
</if>
<if test="cfgType != null and cfgType !='' ">
AND a.cfg_type =#{cfgType}
</if>
</where>
</select>
<select id="getComplexStringList" resultMap="complexCfgMap" parameterType="com.nis.domain.configuration.CfgIndexInfo">
SELECT
<include refid="ComplexCfg_Column" />
FROM complex_keyword_cfg a
<where>
<if test="compileId != null">
AND a.compile_id =#{compileId}
</if>
<if test="functionId != null">
AND a.function_id =#{functionId}
</if>
<if test="cfgType != null and cfgType !='' ">
AND a.cfg_type =#{cfgType}
</if>
</where>
</select>
<insert id="saveCfgIndex" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into cfg_index_info(
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
dns_strategy_id,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5,
do_log,
source_compile_id
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{dnsStrategyId,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR},
#{doLog,jdbcType=INTEGER},
#{sourceCompileId,jdbcType=INTEGER}
)
</insert>
<!-- insert ip_port_cfg表信息 -->
<insert id="saveIpPortCfg" parameterType="com.nis.domain.configuration.IpPortCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into ip_port_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
ip_type,
src_ip_address,
ip_pattern,
port_pattern,
src_port,
protocol,
protocol_id,
direction,
dest_port,
dest_ip_address,
cfg_type,
cfg_region_code,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{ipType,jdbcType=INTEGER},
#{srcIpAddress,jdbcType=VARCHAR},
#{ipPattern,jdbcType=INTEGER},
#{portPattern,jdbcType=INTEGER},
#{srcPort,jdbcType=VARCHAR},
#{protocol,jdbcType=INTEGER},
#{protocolId,jdbcType=INTEGER},
#{direction,jdbcType=INTEGER},
#{destPort,jdbcType=VARCHAR},
#{destIpAddress,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<insert id="saveCommonStringCfg" parameterType="com.nis.domain.configuration.CommonStringCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into common_keyword_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<!-- insert http_res_hdr_cfg表信息 -->
<insert id="saveComplexStringCfg" parameterType="com.nis.domain.configuration.ComplexStringCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">
SELECT LAST_INSERT_ID()
</selectKey>
insert into complex_keyword_cfg (
CFG_DESC,
ACTION,
IS_VALID,
IS_AUDIT,
CREATOR_ID,
CREATE_TIME,
EDITOR_ID,
EDIT_TIME,
AUDITOR_ID,
AUDIT_TIME,
SERVICE_ID,
REQUEST_ID,
COMPILE_ID,
IS_AREA_EFFECTIVE,
CLASSIFY,
ATTRIBUTE,
LABLE,
AREA_EFFECTIVE_IDS,
function_id,
district,
cfg_keywords,
cfg_type,
cfg_region_code,
expr_type,
match_method,
is_hexbin,
user_region1,
user_region2,
user_region3,
user_region4,
user_region5
)values (
#{cfgDesc,jdbcType=VARCHAR},
#{action,jdbcType=INTEGER},
0,
0,
#{creatorId,jdbcType=INTEGER},
#{createTime,jdbcType=TIMESTAMP},
#{editorId,jdbcType=INTEGER},
#{editTime,jdbcType=TIMESTAMP},
#{auditorId,jdbcType=INTEGER},
#{auditTime,jdbcType=TIMESTAMP},
#{serviceId,jdbcType=INTEGER},
#{requestId,jdbcType=INTEGER},
#{compileId,jdbcType=INTEGER},
#{isAreaEffective,jdbcType=INTEGER},
#{classify,jdbcType=VARCHAR},
#{attribute,jdbcType=VARCHAR},
#{lable,jdbcType=VARCHAR},
#{areaEffectiveIds,jdbcType=VARCHAR},
#{functionId,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},
#{cfgKeywords,jdbcType=VARCHAR},
#{cfgType,jdbcType=VARCHAR},
#{cfgRegionCode,jdbcType=INTEGER},
#{exprType,jdbcType=INTEGER},
#{matchMethod,jdbcType=INTEGER},
#{isHexbin,jdbcType=INTEGER},
#{userRegion1,jdbcType=VARCHAR},
#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},
#{userRegion4,jdbcType=VARCHAR},
#{userRegion5,jdbcType=VARCHAR}
)
</insert>
<update id="updateCfgIndex" parameterType="com.nis.domain.configuration.CfgIndexInfo" >
update cfg_index_info
<set >
<trim suffixOverrides=",">
<if test="cfgDesc != null and cfgDesc != ''" >
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
</if>
<if test="action != null" >
action = #{action,jdbcType=INTEGER},
</if>
<if test="doLog != null" >
do_log = #{doLog,jdbcType=INTEGER},
</if>
<if test="isValid != null" >
is_valid = #{isValid,jdbcType=INTEGER},
</if>
<if test="isAudit != null" >
is_audit = #{isAudit,jdbcType=INTEGER},
</if>
<if test="creatorId != null" >
creator_id = #{creatorId,jdbcType=INTEGER},
</if>
<if test="createTime != null and createTime != ''" >
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="editorId != null" >
editor_id = #{editorId,jdbcType=INTEGER},
</if>
edit_time = #{editTime,jdbcType=TIMESTAMP},
<if test="serviceId != null" >
service_id = #{serviceId,jdbcType=INTEGER},
</if>
<if test="requestId != null" >
request_id = #{requestId,jdbcType=INTEGER},
</if>
<if test="isAreaEffective != null" >
is_area_effective = #{isAreaEffective,jdbcType=INTEGER},
</if>
<if test="classify != null and classify != ''" >
classify = #{classify,jdbcType=VARCHAR},
</if>
<if test="attribute != null and attribute != ''" >
attribute = #{attribute,jdbcType=VARCHAR},
</if>
<if test="lable != null and lable != ''" >
lable = #{lable,jdbcType=VARCHAR},
</if>
<if test="areaEffectiveIds != null" >
area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR},
</if>
<if test="functionId != null" >
function_id = #{functionId,jdbcType=INTEGER},
</if>
user_region1 = #{userRegion1,jdbcType=VARCHAR},
user_region2 = #{userRegion2,jdbcType=VARCHAR},
user_region3 = #{userRegion3,jdbcType=VARCHAR},
user_region4 = #{userRegion4,jdbcType=VARCHAR},
user_region5 = #{userRegion5,jdbcType=VARCHAR},
</trim>
</set>
where cfg_id = #{cfgId,jdbcType=BIGINT}
</update>
<!-- 删除子配置 -->
<delete id="deleteIpPortCfg" >
delete from ip_port_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="deleteCommonStringCfg">
delete from common_keyword_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<delete id="deleteComplexStringCfg">
delete from complex_keyword_cfg where compile_id=#{compileId} and function_id=#{functionId}
</delete>
<update id="updateCfgValid" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_valid = #{isValid,jdbcType=INTEGER},
editor_id = #{editorId,jdbcType=INTEGER} ,
edit_time = #{editTime,jdbcType=TIMESTAMP}
<if test="isAudit !=null ">
,is_audit = #{isAudit,jdbcType=BIGINT}
</if>
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
<update id="auditCfg" parameterType="com.nis.domain.configuration.BaseCfg">
update ${tableName} set is_audit = #{isAudit,jdbcType=INTEGER},
auditor_id = #{auditorId,jdbcType=INTEGER},
audit_time = #{auditTime,jdbcType=TIMESTAMP}
<if test="isValid != null" >
,is_valid = #{isValid,jdbcType=INTEGER}
</if>
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
and function_id=#{functionId,jdbcType=INTEGER}
</trim>
</update>
</mapper>

View File

@@ -1,10 +1,13 @@
package com.nis.web.service;
import java.io.IOException;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -20,6 +23,12 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.TypeAdapter;
import com.google.gson.internal.LinkedTreeMap;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
import com.google.gson.stream.JsonWriter;
import com.googlecode.ipv6.IPv6Address;
import com.googlecode.ipv6.IPv6Network;
import com.nis.domain.SysRole;
@@ -248,7 +257,66 @@ public abstract class BaseService {
return Configurations.getStringProperty(tableName, null);
}
public static class MapTypeAdapter extends TypeAdapter<Object> {
@Override
public Object read(JsonReader in) throws IOException {
JsonToken token = in.peek();
switch (token) {
case BEGIN_ARRAY:
List<Object> list = new ArrayList<Object>();
in.beginArray();
while (in.hasNext()) {
list.add(read(in));
}
in.endArray();
return list;
case BEGIN_OBJECT:
Map<String, Object> map = new LinkedTreeMap<String, Object>();
in.beginObject();
while (in.hasNext()) {
map.put(in.nextName(), read(in));
}
in.endObject();
return map;
case STRING:
return in.nextString();
case NUMBER:
String temp = in.nextString();
BigDecimal dbNum = new BigDecimal(temp);
BigDecimal maxLong = new BigDecimal(Long.MAX_VALUE);
BigDecimal maxInteger = new BigDecimal(Integer.MAX_VALUE);
// 数字超过long的最大值返回BigDecimal类型
if (dbNum.compareTo(maxLong)==1) {
return dbNum;
}else if(dbNum.compareTo(maxInteger)==1){
long lngNum = Long.parseLong(temp);
return lngNum;
}else{
int lngNum = Integer.parseInt(temp);
return lngNum;
}
case BOOLEAN:
return in.nextBoolean();
case NULL:
in.nextNull();
return null;
default:
throw new IllegalStateException();
}
}
@Override
public void write(JsonWriter out, Object value) throws IOException {
// 序列化无需实现
}
}
/**
* 转换成字符串
* @param obj
@@ -269,6 +337,19 @@ public abstract class BaseService {
}).create();
return gson.toJson(obj);
}
/**
* 字符串转成对象
* @param jsonString
* @param cls
* @return
*/
public static <T> T gsonFromJson(String jsonString,Class<T> cls){
Gson gson = new GsonBuilder()
.registerTypeAdapter(new TypeToken<Map>() {}.getType(), new MapTypeAdapter())
.registerTypeAdapter(new TypeToken<List>() {}.getType(), new MapTypeAdapter())
.create();
return gson.fromJson(jsonString, cls);
}
/**
* 界面配置list转换为服务接口端的list
* @param <T>

View File

@@ -0,0 +1,339 @@
package com.nis.web.service.configuration;
import java.lang.reflect.Field;
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 net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.nis.domain.Page;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.CommonStringCfg;
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.domain.maat.MaatCfg;
import com.nis.domain.maat.MaatCfg.DigestCfg;
import com.nis.domain.maat.MaatCfg.GroupCfg;
import com.nis.domain.maat.MaatCfg.IpCfg;
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
import com.nis.domain.maat.MaatCfg.StringCfg;
import com.nis.domain.maat.ToMaatBean;
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.StringUtil;
import com.nis.web.dao.configuration.AreaIpCfgDao;
import com.nis.web.dao.configuration.CommonPolicyDao;
import com.nis.web.dao.configuration.StringCfgDao;
import com.nis.web.dao.configuration.WebsiteCfgDao;
import com.nis.web.security.UserUtils;
import com.nis.web.service.BaseService;
import com.nis.web.service.CrudService;
/**
* 代理缓存相关配置事务类
* @author zhangwei
*
*/
@Service
public class CachePolicyService extends CrudService<WebsiteCfgDao,CfgIndexInfo> {
@Autowired
protected CommonPolicyDao commonPolicyDao;
@Autowired
protected AreaIpCfgDao areaIpCfgDao;
@Autowired
protected StringCfgDao stringCfgDao;
public CfgIndexInfo getCachePolicy(Long cfgId){
CfgIndexInfo entity = commonPolicyDao.getPolicyById(cfgId);
entity.setUserRegion((Map<String,Object>)this.gsonFromJson(entity.getUserRegion1(),Map.class));
List<BaseStringCfg> stringList = commonPolicyDao.getCommonStringList(entity);
entity.setStringList(stringList);
return entity;
}
/*public Map<String, List> exportCachePolicy(CfgIndexInfo entity){
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);
return dataMap;
}*/
public Page<CfgIndexInfo> getCachePolicyList(Page<CfgIndexInfo> page, CfgIndexInfo entity){
// 生成数据权限过滤条件dsf为dataScopeFilter的简写在xml中使用 ${sqlMap.dsf}调用权限SQL
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"a"));
entity.setPage(page);
List<CfgIndexInfo> list = commonPolicyDao.getPolicyList(entity);
for(CfgIndexInfo c:list){
c.setUserRegion((Map<String,Object>)this.gsonFromJson(c.getUserRegion1(),Map.class));
}
page.setList(list);
return page;
}
public void saveCachePolicy(CfgIndexInfo entity){
//设置区域运营商信息
setAreaEffectiveIds(entity);
if(entity.getCfgId()==null){
Integer compileId = 0;
try {
//处理复杂用户自定义域
if(!StringUtil.isEmpty(entity.getUserRegion())){
entity.setUserRegion1(gsonToJson(entity.getUserRegion()));
}
System.out.println(entity.getUserRegion1());
List<Integer> idList = ConfigServiceUtil.getId(1, 1);
if(idList!=null && idList.size()>0){
compileId = idList.get(0);
}
entity.setCompileId(compileId);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
commonPolicyDao.saveCfgIndex(entity);
if(entity.getStringList()!=null){
for(BaseStringCfg cfg:entity.getStringList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
commonPolicyDao.saveCommonStringCfg(cfg);
}
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("数据保存出错");
throw e;
}
}else{
//处理复杂用户自定义域
if(!StringUtil.isEmpty(entity.getUserRegion())){
entity.setUserRegion1(gsonToJson(entity.getUserRegion()));
}
System.out.println(entity.getUserRegion1());
// 审核未通过状态的配置 修改后状态改为未审核
entity.setIsValid(0);
entity.setIsAudit(0);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
commonPolicyDao.updateCfgIndex(entity);
//无效子配置后,再新增子配置
commonPolicyDao.deleteCommonStringCfg(entity);
AreaIpCfg area = new AreaIpCfg();
area.setCompileId(entity.getCompileId());
area.setFunctionId(entity.getFunctionId());
areaIpCfgDao.deleteAreaIpCfg(area);
entity.setCreateTime(new Date());
entity.setCreatorId(entity.getCurrentUser().getId());
if(entity.getStringList()!=null){
for(BaseStringCfg cfg:entity.getStringList()){
if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
commonPolicyDao.saveCommonStringCfg(cfg);
}
}
}
//保存区域IP信息
if(entity.getAreaCfg()!=null){
for(AreaIpCfg cfg:entity.getAreaCfg()){
cfg.initDefaultValue();
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"});
areaIpCfgDao.saveAreaIpCfg(cfg);
}
}
}
}
public void updateCachePolicyValid(Integer isValid,String ids,Integer functionId){
String[] idArray = ids.split(",");
for(String id :idArray){
CfgIndexInfo entity = new CfgIndexInfo();
entity.setCfgId(Long.parseLong(id));
entity.setIsValid(isValid);
entity.setEditorId(UserUtils.getUser().getId());
entity.setEditTime(new Date());
entity.setTableName(CfgIndexInfo.getTablename());
entity.setFunctionId(functionId);
commonPolicyDao.updateCfgValid(entity);
//查询子配置
entity = this.getCachePolicy(Long.parseLong(id));
if(entity.getStringList()!=null && entity.getStringList().size()>0){
CommonStringCfg cfg = new CommonStringCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(CommonStringCfg.getTablename());
commonPolicyDao.updateCfgValid(cfg);
}
//保存区域IP信息
if(entity.getAreaCfg()!=null && entity.getAreaCfg().size()>0){
AreaIpCfg cfg = new AreaIpCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AreaIpCfg.getTablename());
commonPolicyDao.updateCfgValid(cfg);
}
}
}
public void auditCachePolicy(CfgIndexInfo entity,Integer isAudit) throws MaatConvertException{
//修改数据库审核状态信息
entity.setTableName(CfgIndexInfo.getTablename());
commonPolicyDao.auditCfg(entity);
ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg();
List<MaatCfg> configCompileList = new ArrayList();
List<GroupCfg> groupRelationList = new ArrayList();
List<IpCfg> ipRegionList = new ArrayList();
List<StringCfg> strRegionList = new ArrayList();
List<NumBoundaryCfg> numRegionList = new ArrayList();
List<DigestCfg> digestRegionList = new ArrayList();
List<IpCfg> areaIpRegionList = new ArrayList();
//查询子配置并修改审核状态
entity = this.getCachePolicy(entity.getCfgId());
if(entity.getIpPortList()!=null && entity.getIpPortList().size()>0){
IpPortCfg cfg = new IpPortCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(IpPortCfg.getTablename());
commonPolicyDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(ipRegionList,entity.getIpPortList(),1,entity,groupRelationList);
groupRelationList=map.get("groupList");
ipRegionList=map.get("dstList");
if(map.get("numRegionList")!=null){
numRegionList.addAll(map.get("numRegionList"));
}
}
}
if(entity.getStringList()!=null && entity.getStringList().size()>0){
CommonStringCfg cfg = new CommonStringCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(CommonStringCfg.getTablename());
commonPolicyDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(strRegionList,entity.getStringList(),2,entity,groupRelationList);
groupRelationList=map.get("groupList");
strRegionList=map.get("dstList");
}
}
//保存区域IP信息
List<AreaIpCfg> areaIpCfgList=areaIpCfgDao.getByCompileId(entity.getCompileId());
if(!StringUtil.isEmpty(areaIpCfgList)){
AreaIpCfg cfg = new AreaIpCfg();
BeanUtils.copyProperties(entity, cfg, new String[]{"cfgId"});
cfg.setTableName(AreaIpCfg.getTablename());
commonPolicyDao.auditCfg(cfg);
if(isAudit==1){
Map<String,List> map = cfgConvert(areaIpRegionList,areaIpCfgList,1,entity,groupRelationList);
groupRelationList=map.get("groupList");
areaIpRegionList=map.get("dstList");
}
}
//构造提交综合服务参数格式,一条配置提交一次综合服务
if(isAudit==1){
maatCfg.initDefaultValue();
BeanUtils.copyProperties(entity, maatCfg);
maatCfg.setAction(entity.getAction());
maatCfg.setAuditTime(entity.getAuditTime());
maatCfg.setIpRegionList(ipRegionList);
maatCfg.setStrRegionList(strRegionList);
maatCfg.setNumRegionList(numRegionList);
maatCfg.setDigestRegionList(digestRegionList);
maatCfg.setGroupRelationList(groupRelationList);
maatCfg.setGroupNum(groupRelationList.size());
maatCfg.setAreaIpRegionList(areaIpRegionList);
maatCfg.setIsValid(entity.getIsValid());
//判断代理缓存策略是否需要设置自定义域参数
/*String userRegion = "";
userRegion=Constants.REPLACE_ZONE_KEY+"="+entity.getUserRegion1();
String substitute="";
String userRegion2=StringUtil.isEmpty(entity.getUserRegion2()) ? "":entity.getUserRegion2();
substitute="/";
userRegion2 = BaseService.replaceContentEscape(userRegion2);
substitute=substitute+userRegion2;
String userRegion3=StringUtil.isEmpty(entity.getUserRegion3()) ? "":entity.getUserRegion3();
userRegion3 = BaseService.replaceContentEscape(userRegion3);
substitute=substitute+"/"+userRegion3;
userRegion=userRegion+";"+Constants.REPLACE_SUBSTITUTE_KEY+"="+substitute;
if(StringUtil.isEmpty(userRegion)){
userRegion=Constants.USER_REGION_PLACEHOLDER;
}*/
maatCfg.setUserRegion(entity.getUserRegion1());
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.INSERT_ACTION);
//调用服务接口下发配置数据
String json=gsonToJson(maatBean);
logger.info("代理缓存策略下发配置参数:"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
logger.info("代理缓存策略下发响应信息:"+result.getMsg());
}else if(isAudit==3){
maatCfg.setCompileId(entity.getCompileId());
maatCfg.setServiceId(entity.getServiceId());
maatCfg.setIsValid(0);//无效
configCompileList.add(maatCfg);
maatBean.setConfigCompileList(configCompileList);
maatBean.setAuditTime(entity.getAuditTime());
maatBean.setCreatorName(entity.getCurrentUser().getName());
maatBean.setVersion(Constants.MAAT_VERSION);
maatBean.setOpAction(Constants.UPDATE_ACTION);
//调用服务接口取消配置
String json=gsonToJson(maatBean);
logger.info("代理缓存策略下发配置参数:"+json);
//调用服务接口下发配置
ToMaatResult result = ConfigServiceUtil.put(json,1);
logger.info("代理缓存策略取消配置响应信息:"+result.getMsg());
}
}
}