(1)细化IPV4掩码范围验证的提示

(2)IP不能为xxxx的提示前方加入空格
(3)DNS响应策略导入模板,导入功能提交
This commit is contained in:
wangxin
2018-11-02 14:53:51 +08:00
parent 6ab181c329
commit e063194254
11 changed files with 307 additions and 131 deletions

View File

@@ -32,7 +32,19 @@ public class DnsResStrategy extends BaseCfg<DnsResStrategy> {
private String group1Name;
@ExcelField(title="min_ttl",sort=4)
private String miTtlmax;
//仅作导入使用
private String ttl;
public String getTtl() {
return ttl;
}
public void setTtl(String ttl) {
this.ttl = ttl;
}
@Override
public void initDefaultValue() {
this.resGroup2Id=0;

View File

@@ -0,0 +1,38 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
public class DnsResStrategyTemplate {
@ExcelField(title="policy_name",align=2,sort=1)
private String cfgDesc;
@ExcelField(title="group",align=2,sort=2)
private Integer resGroup1Id;
@ExcelField(title="res_group_num",align=2,sort=3)
private Integer resGroup1Num;
@ExcelField(title="min_ttl",align=2,sort=4)
private String ttl;
public String getCfgDesc() {
return cfgDesc;
}
public void setCfgDesc(String cfgDesc) {
this.cfgDesc = cfgDesc;
}
public Integer getResGroup1Id() {
return resGroup1Id;
}
public void setResGroup1Id(Integer resGroup1Id) {
this.resGroup1Id = resGroup1Id;
}
public Integer getResGroup1Num() {
return resGroup1Num;
}
public void setResGroup1Num(Integer resGroup1Num) {
this.resGroup1Num = resGroup1Num;
}
public String getTtl() {
return ttl;
}
public void setTtl(String ttl) {
this.ttl = ttl;
}
}

View File

@@ -60,6 +60,7 @@ public final class Constants {
* IP验证正则
*/
public static final String IPV4_IP_SUBNET_REGEXP=Configurations.getStringProperty("ipv4_ip_subnet_regexp", "*");
public static final String IPV4_IP_SUBNET_REGEXP_ORIGINAL=Configurations.getStringProperty("ipv4_ip_subnet_regexp_original", "*");
public static final String IPV6_IP_SUBNET_REGEXP=Configurations.getStringProperty("ipv6_ip_subnet_regexp", "*");
public static final String IPV4_IP_RANGE_REGEXP=Configurations.getStringProperty("ipv4_ip_range_regexp", "*");
//0.0.0.1-2这种格式

View File

@@ -3,7 +3,6 @@
*/
package com.nis.util.excel;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -16,7 +15,6 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -29,7 +27,6 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
@@ -41,7 +38,6 @@ import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Lists;
import com.nis.domain.FunctionRegionDict;
@@ -56,15 +52,10 @@ import com.nis.util.DictUtils;
import com.nis.util.Encodes;
import com.nis.util.Reflections;
import com.nis.util.StringUtil;
import com.nis.web.dao.FunctionServiceDictDao;
import com.nis.web.dao.basics.PolicyGroupInfoDao;
import com.nis.web.dao.basics.SysDictInfoDao;
import com.nis.web.dao.configuration.DnsResStrategyDao;
import com.nis.web.service.SpringContextHolder;
import com.nis.web.service.configuration.DnsResStrategyService;
import com.sun.xml.internal.rngom.ast.builder.CommentList;
import sun.util.logging.resources.logging;
/**
* 导出Excel文件导出“XLSX”格式支持大数据量导出 @see org.apache.poi.ss.SpreadsheetVersion
@@ -262,35 +253,36 @@ public class ExportExcel {
index++;
}
if("policy_name".equals(headerStr)){
if(service.getAction().equals(1)){
headerStr="";
commentStr="";
}else{
List<DnsResStrategy> resStrategys=dnsResStrategyDao.findList(null, 1,1);
commentStr=commentStr+"0"+""+msgProp.getProperty("no_strategy")+"\n";
index++;
defaultValue="0";
if(!StringUtil.isEmpty(resStrategys)){
for (DnsResStrategy dnsResStrategy : resStrategys) {
commentStr=commentStr+dnsResStrategy.getCfgId()+""+dnsResStrategy.getCfgDesc()+"\n";
index++;
if(region.getFunctionId().intValue()!=400) {//400 policy_name为DNS响应策略
if(service.getAction().equals(1)){
headerStr="";
commentStr="";
}else{
List<DnsResStrategy> resStrategys=dnsResStrategyDao.findList(null, 1,1);
commentStr=commentStr+"0"+""+msgProp.getProperty("no_strategy")+"\n";
index++;
defaultValue="0";
if(!StringUtil.isEmpty(resStrategys)){
for (DnsResStrategy dnsResStrategy : resStrategys) {
commentStr=commentStr+dnsResStrategy.getCfgId()+""+dnsResStrategy.getCfgDesc()+"\n";
index++;
}
}
}
}
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
if(!StringUtil.isEmpty(defaultValue)){
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
if(StringUtil.isEmpty(headerStr)){
headerStr="";
commentStr="";
}else{
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
if(!StringUtil.isEmpty(defaultValue)){
//2、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
}
}
}
}
@@ -1157,6 +1149,31 @@ public class ExportExcel {
index++;
}
}
}else if(region.getRegionType().equals(6)) {
if(region.getFunctionId().equals(400)) {
if("group".equals(headerStr)){
commentStr="";
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(1);
if(!StringUtil.isEmpty(list)){
for (PolicyGroupInfo policyGroupInfo : list) {
commentStr=commentStr+policyGroupInfo.getGroupId()+""+policyGroupInfo.getGroupName()+"\n";
index++;
}
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
}
if("res_group_num".equals(headerStr)) {
commentStr=msgProp.getProperty("input_integer")+":\n"+commentStr;
index++;
}
if("min_ttl".equals(headerStr)) {
commentStr="1-2";
index++;
commentStr=msgProp.getProperty("example_tip")+":\n"+commentStr;
index++;
}
}
}
titleInfo[0]=headerStr;
titleInfo[1]=commentStr;

View File

@@ -60,6 +60,7 @@ import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate;
import com.nis.domain.configuration.template.DnsComplexStringTemplate;
import com.nis.domain.configuration.template.DnsIpTemplate;
import com.nis.domain.configuration.template.DnsResStrategyTemplate;
import com.nis.domain.configuration.template.IpAllTemplate;
import com.nis.domain.configuration.template.IpCfgTemplate;
import com.nis.domain.configuration.template.IpPayloadTemplate;
@@ -79,6 +80,7 @@ import com.nis.util.DateUtils;
import com.nis.util.DictUtils;
import com.nis.util.JsonMapper;
import com.nis.util.StringUtil;
import com.nis.util.excel.ExcelField;
import com.nis.util.excel.ExportExcel;
import com.nis.util.excel.ImportExcel;
import com.nis.web.dao.configuration.IpCfgDao;
@@ -1064,7 +1066,7 @@ public class BaseController {
}
return stringList;
}
public List<ComplexkeywordCfg> checkComplexStringCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict,
List<?> list) throws ServiceException {
List<ComplexkeywordCfg> stringList = new ArrayList<ComplexkeywordCfg>();
@@ -1622,7 +1624,7 @@ public class BaseController {
baseIpCfg.setIpPattern(2);
if (baseIpCfg.getSrcIpAddress()
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
errInfo.append(prop.getProperty("client_ip")
errInfo.append(prop.getProperty("client_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
+ ";");
@@ -1634,7 +1636,7 @@ public class BaseController {
if (baseIpCfg.getSrcIpAddress()
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
errInfo.append(
prop.getProperty("client_ip")
prop.getProperty("client_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
+ ";");
@@ -1644,7 +1646,7 @@ public class BaseController {
baseIpCfg.setDestIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
baseIpCfg.setIpPattern(3);
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
errInfo.append(prop.getProperty("client_ip") + String.format(
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
}
}
@@ -1657,7 +1659,7 @@ public class BaseController {
baseIpCfg.setIpPattern(2);
if (baseIpCfg.getSrcIpAddress()
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
errInfo.append(prop.getProperty("client_ip")
errInfo.append(prop.getProperty("client_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
+ ";");
@@ -1669,7 +1671,7 @@ public class BaseController {
if (baseIpCfg.getSrcIpAddress()
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
errInfo.append(
prop.getProperty("client_ip")
prop.getProperty("client_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
+ ";");
@@ -1679,7 +1681,7 @@ public class BaseController {
baseIpCfg.setDestIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
baseIpCfg.setIpPattern(3);
if (baseIpCfg.getSrcIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
errInfo.append(prop.getProperty("client_ip") + String.format(
errInfo.append(prop.getProperty("client_ip")+" " + String.format(
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
}
}
@@ -1727,7 +1729,7 @@ public class BaseController {
baseIpCfg.setIpPattern(2);
if (baseIpCfg.getDestIpAddress()
.startsWith(Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
errInfo.append(prop.getProperty("server_ip")
errInfo.append(prop.getProperty("server_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV6_DEFAULT_IP_RANGE_VALUE.split("-")[0])
+ ";");
@@ -1739,7 +1741,7 @@ public class BaseController {
if (baseIpCfg.getDestIpAddress()
.startsWith(Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
errInfo.append(
prop.getProperty("server_ip")
prop.getProperty("server_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV6_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
+ ";");
@@ -1749,7 +1751,7 @@ public class BaseController {
baseIpCfg.setSrcIpAddress(Constants.IPV6_DEFAULT_IP_VALUE);
baseIpCfg.setIpPattern(3);
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV6_DEFAULT_IP_VALUE)) {
errInfo.append(prop.getProperty("server_ip") + String.format(
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
prop.getProperty("can_not_be"), Constants.IPV6_DEFAULT_IP_VALUE) + ";");
}
}
@@ -1764,7 +1766,7 @@ public class BaseController {
baseIpCfg.setIpPattern(2);
if (baseIpCfg.getDestIpAddress()
.startsWith(Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])) {
errInfo.append(prop.getProperty("server_ip")
errInfo.append(prop.getProperty("server_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV4_DEFAULT_IP_RANGE_VALUE.split("-")[0])
+ ";");
@@ -1776,7 +1778,7 @@ public class BaseController {
if (baseIpCfg.getDestIpAddress()
.startsWith(Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])) {
errInfo.append(
prop.getProperty("server_ip")
prop.getProperty("server_ip")+" "
+ String.format(prop.getProperty("can_not_be"),
Constants.IPV4_DEFAULT_IP_SUBNET_VALUE.split("/")[0])
+ ";");
@@ -1786,7 +1788,7 @@ public class BaseController {
baseIpCfg.setSrcIpAddress(Constants.IPV4_DEFAULT_IP_VALUE);
baseIpCfg.setIpPattern(3);
if (baseIpCfg.getDestIpAddress().equals(Constants.IPV4_DEFAULT_IP_VALUE)) {
errInfo.append(prop.getProperty("server_ip") + String.format(
errInfo.append(prop.getProperty("server_ip")+" " + String.format(
prop.getProperty("can_not_be"), Constants.IPV4_DEFAULT_IP_VALUE) + ";");
}
}
@@ -1924,7 +1926,85 @@ public class BaseController {
}
return ipList;
}
public List<DnsResStrategy> checkDnsResStrategyCfg(FunctionServiceDict serviceDict, FunctionRegionDict regionDict, List<?> list)
throws ServiceException {
List<DnsResStrategy> dnsResStrategies=Lists.newArrayList();
Properties prop = this.getMsgProp();
StringBuffer errTip = new StringBuffer();
for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer();
DnsResStrategy dnsResStrategy=new DnsResStrategy();
BeanUtils.copyProperties(list.get(i), dnsResStrategy);
String groupName=dnsResStrategy.getCfgDesc();
if(StringUtils.isBlank(groupName)) {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("policy_name")) + ";");
}
Integer resGroup1Id=dnsResStrategy.getResGroup1Id();
if(resGroup1Id==null) {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("group")) + ";");
}else {
PolicyGroupInfo info=policyGroupInfoService.getById(resGroup1Id);
if(info==null) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("group")) + ";");
}
}
Integer resGroup1Num=dnsResStrategy.getResGroup1Num();
if(resGroup1Num==null) {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("res_group_num")) + ";");
}
String ttl=dnsResStrategy.getTtl();
if(StringUtils.isBlank(ttl)) {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("min_ttl")) + ";");
}else {
Pattern p=Pattern.compile("\\d+\\-\\d+");
Matcher m=p.matcher(ttl);
if(!m.matches()) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("min_ttl")) + ";");
}else {
String minTtl=ttl.split("-")[0];
String maxTtl=ttl.split("-")[1];
Integer min=null,max=null;
try {
min=Integer.parseInt(minTtl);
} catch (Exception e) {
// TODO: handle exception
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("min_ttl")) + ";");
}
try {
max=Integer.parseInt(maxTtl);
} catch (Exception e) {
// TODO: handle exception
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("min_ttl")) + ";");
}
if(min.intValue()>max.intValue())
{errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("min_ttl")) + ";");
}else {
dnsResStrategy.setMinTtl(min);
dnsResStrategy.setMaxTtl(max);
}
}
}
if (errInfo.toString().length() > 0) {//
errTip.append(String.format(prop.getProperty("line"), i + 2) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}
dnsResStrategies.add(dnsResStrategy);
}
if (errTip.toString().length() > 0) {
throw new ServiceException(errTip.toString());
}
return dnsResStrategies;
}
/**
* 协议与端口验证规则
*
@@ -2261,6 +2341,7 @@ public class BaseController {
throws ServiceException {
Properties prop = this.getMsgProp();
String matchType = "";
Pattern ipv4IpSubnetOriginalRegexp = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP_ORIGINAL);
Pattern ipv4IpSubnetRegexp = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
Pattern ipv6IpSubnetRegexp = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
Pattern ipv4IpRangeRegexp = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
@@ -2291,9 +2372,14 @@ public class BaseController {
if (matcher.matches()) {
matchType = "IPV6_IP_RANGE";
} else {
errInfo.append(
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(ipName))
+ ";");
matcher = ipv4IpSubnetOriginalRegexp.matcher(ip);
if(matcher.matches()) {
errInfo.append(prop.getProperty(ipName)+" "+prop.getProperty("ipv4_mask_range_tip")+ ";");
}else {
errInfo.append(
String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty(ipName))
+ ";");
}
}
}
}
@@ -2763,68 +2849,7 @@ public class BaseController {
* @exception @since
* 1.0.0
*/
public static String checkIP(Properties prop, String ipName, String ip, String ipType, String ipPattern) {
StringBuffer msg = new StringBuffer();
if (StringUtils.isBlank(ip)) {
msg.append(String.format(prop.getProperty("can_not_null"), ipName) + ";");
} else {
if ("ipv4".equals(ipType)) {
if ("ip_subnet".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV4_IP_SUBNET_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
} else if ("ip_range".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV4_IP_RANGE_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
} else if ("ip".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV4_IP_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
} else if ("ipv6".equals(ipType)) {
if ("ip_subnet".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV6_IP_SUBNET_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
} else if ("ip_range".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV6_IP_RANGE_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
} else if ("ip".equals(ipPattern)) {
Pattern pattern = Pattern.compile(Constants.IPV6_IP_REGEXP);
Matcher matcher = pattern.matcher(ip);
if (!matcher.matches()) {// 完全匹配
msg.append(String.format(prop.getProperty("is_in_wrong_format"), ipName) + ";");
}
}
}
}
return msg.toString();
}
/**
*
* checkIP(IP格式验证) (这里描述这个方法适用条件 可选)
*
* @param ipName
* @param ip
* @param ipType
* @param ipPattern
* @return String
* @exception @since
* 1.0.0
*/
@Deprecated
public static String checkIP(Properties prop, String ipName, String ip, Integer ipType, Integer ipPattern) {
StringBuffer msg = new StringBuffer();
if (StringUtils.isBlank(ip)) {
@@ -2874,7 +2899,7 @@ public class BaseController {
}
return msg.toString();
}
@Deprecated
public static String checkIp(Properties prop, String srcIpName, String srcIp, String destIpName, String destIp,
Integer ipType, Integer ipPattern) {
StringBuffer msg = new StringBuffer();
@@ -3176,6 +3201,7 @@ public class BaseController {
List<ComplexkeywordCfg> complexkeywordCfgs = new ArrayList<ComplexkeywordCfg>();
List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>();
List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>();
List<DnsResStrategy> dnsResStrategies=Lists.newArrayList();
FunctionRegionDict appRegion = null;
if(serviceDict!=null) {
String regionCode = serviceDict.getRegionCode();
@@ -3253,6 +3279,12 @@ public class BaseController {
complexkeywordCfgs = this.checkComplexStringCfg(serviceDict, regionDict, list);
}
}else if (regionDict.getRegionType().equals(6)) {// 回调类
if (regionDict.getFunctionId().equals(400)) {
List<DnsResStrategyTemplate> list = ei.getDataList(DnsResStrategyTemplate.class,
this.getMsgProp(),regionDict);
dnsResStrategies = this.checkDnsResStrategyCfg(serviceDict, regionDict, list);
}
}
Date date = new Date();
String specServiceId = request.getParameter("appId");
@@ -3542,6 +3574,42 @@ public class BaseController {
if(regionDict.getDictId().intValue()==11) {
websiteCfgService.saveHttpResHeadCfg(complexkeywordCfgs);
}
}else if(regionDict.getRegionType().equals(6)) {
if(regionDict.getFunctionId().equals(400)) {
List<Integer> compileIds=Lists.newArrayList();
try {
compileIds = ConfigServiceUtil.getId(1,dnsResStrategies.size());
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int ind=0;
for(DnsResStrategy cfg:dnsResStrategies) {
cfg.setAction(serviceDict.getAction());
cfg.setAuditorId(UserUtils.getUser().getId());
cfg.setAuditTime(date);
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
cfg.setDoLog(1);
cfg.setFunctionId(regionDict.getFunctionId());
cfg.setIsAudit(0);
cfg.setIsValid(0);
cfg.setIsAreaEffective(0);
cfg.setAttribute("0");
cfg.setClassify("0");
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setServiceId(serviceDict.getServiceId());
cfg.setCompileId(compileIds.get(ind));
ind++;
}
if(dnsResStrategies.size()>0) {
dnsResStrategyService.saveDnsResStrategies(dnsResStrategies);
}
}
}
if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) {
ipCfgService.saveCfgIndexOf(cfgIndexInfos);

View File

@@ -33,6 +33,7 @@ import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate;
import com.nis.domain.configuration.template.DnsComplexStringTemplate;
import com.nis.domain.configuration.template.DnsIpTemplate;
import com.nis.domain.configuration.template.DnsResStrategyTemplate;
import com.nis.domain.configuration.template.IpAllTemplate;
import com.nis.domain.configuration.template.IpPayloadTemplate;
import com.nis.domain.configuration.template.IpRateLimitTemplate;
@@ -330,6 +331,14 @@ public class IpController extends BaseController{
write(request,response, fileName).dispose();
}
}
if(regionDict.getRegionType().equals(6)){
if(regionDict.getFunctionId().equals(400)){
List<DnsResStrategyTemplate> classList=new ArrayList<DnsResStrategyTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, DnsResStrategyTemplate.class, 2);
excel.setDataList(this.getMsgProp(),classList,null).
write(request,response, fileName).dispose();
}
}
}
//ip配置导入

View File

@@ -64,6 +64,12 @@ public class DnsResStrategyService extends BaseService{
return dnsResStrategy;
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveDnsResStrategies(List<DnsResStrategy> cfgs) {
for(DnsResStrategy cfg: cfgs) {
saveOrUpdate(cfg);
}
}
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdate(DnsResStrategy entity){
Date createTime=new Date();
setAreaEffectiveIds(entity);
@@ -78,17 +84,19 @@ public class DnsResStrategyService extends BaseService{
entity.setCreateTime(createTime);
entity.setIsValid(0);
entity.setIsAudit(0);
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
if(entity.getCompileId()==null||entity.getCompileId().intValue()==0) {
//调用服务接口获取compileId
List<Integer> compileIds = new ArrayList<Integer>();
try {
compileIds = ConfigServiceUtil.getId(1,1);
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
if(compileIds != null && compileIds.size() >0 && compileIds.get(0) != 0){
entity.setCompileId(compileIds.get(0));
}
}
dnsResStrategyDao.insert(entity);
//修改