HTTP配置增加excel导入功能,但导入功能按钮暂时隐藏,待后续完善。
Signed-off-by: zhangwei <zhangwei@intranet.com>
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
/**
|
||||
*@Title: BaseStringConfig.java
|
||||
*@Package com.nis.domain.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年2月5日 下午5:26:02
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
/**
|
||||
* @Description: excel导入增强字符串类配置
|
||||
*/
|
||||
public class ComplexStringCfgTemplate {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
private String cfgKeywords;
|
||||
private String district;
|
||||
private Integer exprType ;
|
||||
private Integer matchMethod ;
|
||||
private Integer isHexbin;
|
||||
private Long cfgId;
|
||||
private String cfgDesc;
|
||||
private Integer requestId;
|
||||
private String requestName;
|
||||
private Integer isAreaEffective;
|
||||
private String classify;
|
||||
private String attribute;
|
||||
private String lable;
|
||||
private String classifyName;
|
||||
private String attributeName;
|
||||
private String lableName;
|
||||
private String areaEffectiveIds ;
|
||||
|
||||
@ExcelField(title="expression_type",align=2,sort=20)
|
||||
public Integer getExprType() {
|
||||
return exprType;
|
||||
}
|
||||
public void setExprType(Integer exprType) {
|
||||
this.exprType = exprType;
|
||||
}
|
||||
@ExcelField(title="match_method",align=2,sort=30)
|
||||
public Integer getMatchMethod() {
|
||||
return matchMethod;
|
||||
}
|
||||
public void setMatchMethod(Integer matchMethod) {
|
||||
this.matchMethod = matchMethod;
|
||||
}
|
||||
@ExcelField(title="whether_hexbinary",align=2,sort=40)
|
||||
public Integer getIsHexbin() {
|
||||
return isHexbin;
|
||||
}
|
||||
public void setIsHexbin(Integer isHexbin) {
|
||||
this.isHexbin = isHexbin;
|
||||
}
|
||||
@ExcelField(title="keywords",align=2,sort=10)
|
||||
public String getCfgKeywords() {
|
||||
return cfgKeywords;
|
||||
}
|
||||
public void setCfgKeywords(String cfgKeywords) {
|
||||
this.cfgKeywords = cfgKeywords;
|
||||
}
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
@ExcelField(title="config_describe",align=2,sort=12)
|
||||
public String getCfgDesc() {
|
||||
return cfgDesc;
|
||||
}
|
||||
public void setCfgDesc(String cfgDesc) {
|
||||
this.cfgDesc = cfgDesc;
|
||||
}
|
||||
@ExcelField(title="letter",align=2,sort=13)
|
||||
public Integer getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
public void setRequestId(Integer requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
public String getRequestName() {
|
||||
return requestName;
|
||||
}
|
||||
public void setRequestName(String requestName) {
|
||||
this.requestName = requestName;
|
||||
}
|
||||
public Integer getIsAreaEffective() {
|
||||
return isAreaEffective;
|
||||
}
|
||||
public void setIsAreaEffective(Integer isAreaEffective) {
|
||||
this.isAreaEffective = isAreaEffective;
|
||||
}
|
||||
@ExcelField(title="classification",align=2,sort=71)
|
||||
public String getClassify() {
|
||||
return classify;
|
||||
}
|
||||
public void setClassify(String classify) {
|
||||
this.classify = classify;
|
||||
}
|
||||
@ExcelField(title="attribute",align=2,sort=72)
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
@ExcelField(title="label",align=2,sort=73)
|
||||
public String getLable() {
|
||||
return lable;
|
||||
}
|
||||
public void setLable(String lable) {
|
||||
this.lable = lable;
|
||||
}
|
||||
public String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
public void setClassifyName(String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
public String getAttributeName() {
|
||||
return attributeName;
|
||||
}
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
public String getLableName() {
|
||||
return lableName;
|
||||
}
|
||||
public void setLableName(String lableName) {
|
||||
this.lableName = lableName;
|
||||
}
|
||||
// @ExcelField(title="area_effective",align=2,sort=70)
|
||||
public String getAreaEffectiveIds() {
|
||||
return areaEffectiveIds;
|
||||
}
|
||||
public void setAreaEffectiveIds(String areaEffectiveIds) {
|
||||
this.areaEffectiveIds = areaEffectiveIds;
|
||||
}
|
||||
@ExcelField(title="district",align=2,sort=11)
|
||||
public String getDistrict() {
|
||||
return district;
|
||||
}
|
||||
public void setDistrict(String district) {
|
||||
this.district = district;
|
||||
}
|
||||
}
|
||||
195
src/main/java/com/nis/domain/configuration/IpCfgTemplate.java
Normal file
195
src/main/java/com/nis/domain/configuration/IpCfgTemplate.java
Normal file
@@ -0,0 +1,195 @@
|
||||
/**
|
||||
*@Title: BaseStringConfig.java
|
||||
*@Package com.nis.domain.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年2月5日 下午5:26:02
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
/**
|
||||
* @Description: excel导入IP类配置
|
||||
*/
|
||||
public class IpCfgTemplate {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
|
||||
private Long cfgId;
|
||||
private Integer ipType;
|
||||
private Integer ipPattern;
|
||||
private String srcIpAddress;
|
||||
private String destIpAddress;
|
||||
private Integer portPattern;
|
||||
private String srcPort;
|
||||
private String destPort;
|
||||
private Integer protocol;
|
||||
protected Integer direction ;
|
||||
private String cfgDesc;
|
||||
private Integer requestId;
|
||||
private String requestName;
|
||||
private Integer isAreaEffective;
|
||||
private String classify;
|
||||
private String attribute;
|
||||
private String lable;
|
||||
private String classifyName;
|
||||
private String attributeName;
|
||||
private String lableName;
|
||||
private String areaEffectiveIds ;
|
||||
|
||||
@ExcelField(title="ip_type",align=2,sort=1)
|
||||
public Integer getIpType() {
|
||||
return ipType;
|
||||
}
|
||||
public void setIpType(Integer ipType) {
|
||||
this.ipType = ipType;
|
||||
}
|
||||
@ExcelField(title="ip_pattern",align=2,sort=2)
|
||||
public Integer getIpPattern() {
|
||||
return ipPattern;
|
||||
}
|
||||
public void setIpPattern(Integer ipPattern) {
|
||||
this.ipPattern = ipPattern;
|
||||
}
|
||||
@ExcelField(title="client_ip",align=2,sort=3)
|
||||
public String getSrcIpAddress() {
|
||||
return srcIpAddress;
|
||||
}
|
||||
public void setSrcIpAddress(String srcIpAddress) {
|
||||
this.srcIpAddress = srcIpAddress;
|
||||
}
|
||||
@ExcelField(title="server_ip",align=2,sort=4)
|
||||
public String getDestIpAddress() {
|
||||
return destIpAddress;
|
||||
}
|
||||
public void setDestIpAddress(String destIpAddress) {
|
||||
this.destIpAddress = destIpAddress;
|
||||
}
|
||||
@ExcelField(title="port_pattern",align=2,sort=5)
|
||||
public Integer getPortPattern() {
|
||||
return portPattern;
|
||||
}
|
||||
public void setPortPattern(Integer portPattern) {
|
||||
this.portPattern = portPattern;
|
||||
}
|
||||
@ExcelField(title="client_port",align=2,sort=6)
|
||||
public String getSrcPort() {
|
||||
return srcPort;
|
||||
}
|
||||
public void setSrcPort(String srcPort) {
|
||||
this.srcPort = srcPort;
|
||||
}
|
||||
@ExcelField(title="server_port",align=2,sort=7)
|
||||
public String getDestPort() {
|
||||
return destPort;
|
||||
}
|
||||
public void setDestPort(String destPort) {
|
||||
this.destPort = destPort;
|
||||
}
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
@ExcelField(title="direction",align=2,sort=8)
|
||||
public Integer getDirection() {
|
||||
return direction;
|
||||
}
|
||||
public void setDirection(Integer direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
@ExcelField(title="config_describe",align=2,sort=11)
|
||||
public String getCfgDesc() {
|
||||
return cfgDesc;
|
||||
}
|
||||
public void setCfgDesc(String cfgDesc) {
|
||||
this.cfgDesc = cfgDesc;
|
||||
}
|
||||
@ExcelField(title="letter",align=2,sort=13)
|
||||
public Integer getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
public void setRequestId(Integer requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
public String getRequestName() {
|
||||
return requestName;
|
||||
}
|
||||
public void setRequestName(String requestName) {
|
||||
this.requestName = requestName;
|
||||
}
|
||||
public Integer getIsAreaEffective() {
|
||||
return isAreaEffective;
|
||||
}
|
||||
public void setIsAreaEffective(Integer isAreaEffective) {
|
||||
this.isAreaEffective = isAreaEffective;
|
||||
}
|
||||
@ExcelField(title="classification",align=2,sort=71)
|
||||
public String getClassify() {
|
||||
return classify;
|
||||
}
|
||||
public void setClassify(String classify) {
|
||||
this.classify = classify;
|
||||
}
|
||||
@ExcelField(title="attribute",align=2,sort=72)
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
@ExcelField(title="label",align=2,sort=73)
|
||||
public String getLable() {
|
||||
return lable;
|
||||
}
|
||||
public void setLable(String lable) {
|
||||
this.lable = lable;
|
||||
}
|
||||
public String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
public void setClassifyName(String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
public String getAttributeName() {
|
||||
return attributeName;
|
||||
}
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
public String getLableName() {
|
||||
return lableName;
|
||||
}
|
||||
public void setLableName(String lableName) {
|
||||
this.lableName = lableName;
|
||||
}
|
||||
// @ExcelField(title="area_effective",align=2,sort=70)
|
||||
public String getAreaEffectiveIds() {
|
||||
return areaEffectiveIds;
|
||||
}
|
||||
public void setAreaEffectiveIds(String areaEffectiveIds) {
|
||||
this.areaEffectiveIds = areaEffectiveIds;
|
||||
}
|
||||
@ExcelField(title="protocol",align=2,sort=9)
|
||||
public Integer getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
public void setProtocol(Integer protocol) {
|
||||
this.protocol = protocol;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
*@Title: BaseStringConfig.java
|
||||
*@Package com.nis.domain.restful
|
||||
*@Description TODO
|
||||
*@author dell
|
||||
*@date 2018年2月5日 下午5:26:02
|
||||
*@version 版本号
|
||||
*/
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.nis.util.excel.ExcelField;
|
||||
|
||||
/**
|
||||
* @Description: excel导入字符串类配置
|
||||
*/
|
||||
public class StringCfgTemplate {
|
||||
|
||||
/**
|
||||
* @Fields serialVersionUID:TODO(用一句话描述这个变量表示什么)
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
||||
|
||||
private String cfgKeywords;
|
||||
private Integer exprType ;
|
||||
private Integer matchMethod ;
|
||||
private Integer isHexbin;
|
||||
private Long cfgId;
|
||||
private String cfgDesc;
|
||||
private Integer requestId;
|
||||
private String requestName;
|
||||
private Integer isAreaEffective;
|
||||
private String classify;
|
||||
private String attribute;
|
||||
private String lable;
|
||||
private String classifyName;
|
||||
private String attributeName;
|
||||
private String lableName;
|
||||
private String areaEffectiveIds ;
|
||||
|
||||
@ExcelField(title="expression_type",align=2,sort=20)
|
||||
public Integer getExprType() {
|
||||
return exprType;
|
||||
}
|
||||
public void setExprType(Integer exprType) {
|
||||
this.exprType = exprType;
|
||||
}
|
||||
@ExcelField(title="match_method",align=2,sort=30)
|
||||
public Integer getMatchMethod() {
|
||||
return matchMethod;
|
||||
}
|
||||
public void setMatchMethod(Integer matchMethod) {
|
||||
this.matchMethod = matchMethod;
|
||||
}
|
||||
@ExcelField(title="whether_hexbinary",align=2,sort=40)
|
||||
public Integer getIsHexbin() {
|
||||
return isHexbin;
|
||||
}
|
||||
public void setIsHexbin(Integer isHexbin) {
|
||||
this.isHexbin = isHexbin;
|
||||
}
|
||||
@ExcelField(title="keywords",align=2,sort=11)
|
||||
public String getCfgKeywords() {
|
||||
return cfgKeywords;
|
||||
}
|
||||
public void setCfgKeywords(String cfgKeywords) {
|
||||
this.cfgKeywords = cfgKeywords;
|
||||
}
|
||||
public Long getCfgId() {
|
||||
return cfgId;
|
||||
}
|
||||
public void setCfgId(Long cfgId) {
|
||||
this.cfgId = cfgId;
|
||||
}
|
||||
@ExcelField(title="config_describe",align=2,sort=10)
|
||||
public String getCfgDesc() {
|
||||
return cfgDesc;
|
||||
}
|
||||
public void setCfgDesc(String cfgDesc) {
|
||||
this.cfgDesc = cfgDesc;
|
||||
}
|
||||
@ExcelField(title="letter",align=2,sort=12)
|
||||
public Integer getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
public void setRequestId(Integer requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
public String getRequestName() {
|
||||
return requestName;
|
||||
}
|
||||
public void setRequestName(String requestName) {
|
||||
this.requestName = requestName;
|
||||
}
|
||||
public Integer getIsAreaEffective() {
|
||||
return isAreaEffective;
|
||||
}
|
||||
public void setIsAreaEffective(Integer isAreaEffective) {
|
||||
this.isAreaEffective = isAreaEffective;
|
||||
}
|
||||
@ExcelField(title="classification",align=2,sort=71)
|
||||
public String getClassify() {
|
||||
return classify;
|
||||
}
|
||||
public void setClassify(String classify) {
|
||||
this.classify = classify;
|
||||
}
|
||||
@ExcelField(title="attribute",align=2,sort=72)
|
||||
public String getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public void setAttribute(String attribute) {
|
||||
this.attribute = attribute;
|
||||
}
|
||||
@ExcelField(title="label",align=2,sort=73)
|
||||
public String getLable() {
|
||||
return lable;
|
||||
}
|
||||
public void setLable(String lable) {
|
||||
this.lable = lable;
|
||||
}
|
||||
public String getClassifyName() {
|
||||
return classifyName;
|
||||
}
|
||||
public void setClassifyName(String classifyName) {
|
||||
this.classifyName = classifyName;
|
||||
}
|
||||
public String getAttributeName() {
|
||||
return attributeName;
|
||||
}
|
||||
public void setAttributeName(String attributeName) {
|
||||
this.attributeName = attributeName;
|
||||
}
|
||||
public String getLableName() {
|
||||
return lableName;
|
||||
}
|
||||
public void setLableName(String lableName) {
|
||||
this.lableName = lableName;
|
||||
}
|
||||
// @ExcelField(title="area_effective",align=2,sort=70)
|
||||
public String getAreaEffectiveIds() {
|
||||
return areaEffectiveIds;
|
||||
}
|
||||
public void setAreaEffectiveIds(String areaEffectiveIds) {
|
||||
this.areaEffectiveIds = areaEffectiveIds;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public class ExportExcel {
|
||||
t = ss[0];
|
||||
}
|
||||
}
|
||||
headerList.add(msgProp.getProperty(t));
|
||||
headerList.add(msgProp.getProperty(t)==null?t:msgProp.getProperty(t));
|
||||
}
|
||||
initialize(title, headerList);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,12 @@ public class ImportExcel {
|
||||
* @return
|
||||
*/
|
||||
public int getLastDataRowNum(){
|
||||
return this.sheet.getLastRowNum()+headerNum;
|
||||
if(headerNum==0){
|
||||
return this.sheet.getLastRowNum()+getDataRowNum();
|
||||
}else{
|
||||
return this.sheet.getLastRowNum()+headerNum;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.StringEscapeUtils;
|
||||
@@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.ServiceConfigInfo;
|
||||
@@ -36,15 +38,19 @@ import com.nis.domain.configuration.BaseCfg;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.NumBoundaryCfg;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.util.Configurations;
|
||||
//import com.nis.main.ConvertTool;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.excel.ExportExcel;
|
||||
import com.nis.web.service.ArchiveServcie;
|
||||
import com.nis.web.service.AreaService;
|
||||
import com.nis.web.service.DictService;
|
||||
@@ -429,4 +435,36 @@ public class BaseController {
|
||||
}
|
||||
return msgProp;
|
||||
}
|
||||
public void importCfgTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode){
|
||||
Properties msgProp = getMsgProp();
|
||||
try {
|
||||
List<FunctionRegionDict> dictList = DictUtils.getFunctionRegionDictList(functionId);
|
||||
for(FunctionRegionDict dict:dictList){
|
||||
if(dict.getConfigRegionCode()==cfgRegionCode){
|
||||
String fileName = dict.getConfigRegionValue()+".xlsx";
|
||||
if(dict.getRegionType()==1){
|
||||
List<IpCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new IpCfgTemplate());
|
||||
new ExportExcel(msgProp,null, IpCfgTemplate.class, 2).setDataList(list).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==2){
|
||||
List<StringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new StringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, StringCfgTemplate.class, 2).setDataList(list).
|
||||
write(request,response, fileName).dispose();
|
||||
}else if(dict.getRegionType()==3){
|
||||
List<ComplexStringCfgTemplate> list = Lists.newArrayList();
|
||||
list.add(new ComplexStringCfgTemplate());
|
||||
new ExportExcel(msgProp,null, ComplexStringCfgTemplate.class, 2).setDataList(list).
|
||||
write(request,response, fileName).dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
msgProp = null;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,39 +2,38 @@ package com.nis.web.controller.configuration.ntc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
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.beans.BeanUtils;
|
||||
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.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
import com.nis.domain.configuration.CfgIndexInfo;
|
||||
import com.nis.domain.configuration.ComplexkeywordCfg;
|
||||
import com.nis.domain.configuration.DnsDomainCfg;
|
||||
import com.nis.domain.configuration.ComplexStringCfgTemplate;
|
||||
import com.nis.domain.configuration.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
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.SslKeywordCfg;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.DictUtils;
|
||||
import com.nis.util.excel.ImportExcel;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
@@ -364,4 +363,117 @@ public class WebsiteController extends BaseController{
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/website/dnsList?functionId="+functionId;
|
||||
}
|
||||
//下载导入模板
|
||||
@RequestMapping(value = "import/template")
|
||||
public void importFileTemplate(HttpServletRequest request,HttpServletResponse response,
|
||||
RedirectAttributes redirectAttributes,Integer functionId,Integer cfgRegionCode) {
|
||||
this.importCfgTemplate(request, response, redirectAttributes, functionId, cfgRegionCode);
|
||||
}
|
||||
//http配置导入
|
||||
@RequestMapping(value = "importHttp", method=RequestMethod.POST)
|
||||
public String importHttpFile(HttpServletRequest request,Model model,HttpServletResponse response, RedirectAttributes redirectAttributes,
|
||||
@RequestParam("file") MultipartFile file,CfgIndexInfo cfgIndex,Integer protocolId) {
|
||||
try {
|
||||
ImportExcel ei = new ImportExcel(file, 0, 0);
|
||||
if(cfgIndex.getCfgType().equals(Constants.HTTP_IP_REGION)){
|
||||
List<IpCfgTemplate> list = ei.getDataList(IpCfgTemplate.class);
|
||||
for(IpCfgTemplate cfg : list){
|
||||
List<IpPortCfg> ipList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
IpPortCfg ip = new IpPortCfg();
|
||||
BeanUtils.copyProperties(cfg, ip);
|
||||
ip.setProtocolId(protocolId);
|
||||
ip.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
ip.setCfgType(cfgIndex.getCfgType());
|
||||
ipList.add(ip);
|
||||
cfgIndex.setIpPortList(ipList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}else if(cfgIndex.getCfgType().equals(Constants.HTTP_URL_REGION)){
|
||||
List<StringCfgTemplate> list = ei.getDataList(StringCfgTemplate.class);
|
||||
for(StringCfgTemplate cfg : list){
|
||||
List<HttpUrlCfg> urlList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
HttpUrlCfg url = new HttpUrlCfg();
|
||||
BeanUtils.copyProperties(cfg, url);
|
||||
url.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
url.setCfgType(cfgIndex.getCfgType());
|
||||
urlList.add(url);
|
||||
cfgIndex.setHttpUrlList(urlList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}else if(cfgIndex.getCfgType().equals(Constants.HTTP_REQ_HEAD_REGION)){
|
||||
List<ComplexStringCfgTemplate> list = ei.getDataList(ComplexStringCfgTemplate.class);
|
||||
for(ComplexStringCfgTemplate cfg : list){
|
||||
List<HttpReqHeadCfg> headList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
HttpReqHeadCfg head = new HttpReqHeadCfg();
|
||||
BeanUtils.copyProperties(cfg, head);
|
||||
head.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
head.setCfgType(cfgIndex.getCfgType());
|
||||
headList.add(head);
|
||||
cfgIndex.setHttpReqHdrList(headList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}else if(cfgIndex.getCfgType().equals(Constants.HTTP_REQ_BODY_REGION)){
|
||||
List<StringCfgTemplate> list = ei.getDataList(StringCfgTemplate.class);
|
||||
for(StringCfgTemplate cfg : list){
|
||||
List<HttpBodyCfg> bodyList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
HttpBodyCfg body = new HttpBodyCfg();
|
||||
BeanUtils.copyProperties(cfg, body);
|
||||
body.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
body.setCfgType(cfgIndex.getCfgType());
|
||||
bodyList.add(body);
|
||||
cfgIndex.setHttpReqBodyList(bodyList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}else if(cfgIndex.getCfgType().equals(Constants.HTTP_RES_HEAD_REGION)){
|
||||
List<ComplexStringCfgTemplate> list = ei.getDataList(ComplexStringCfgTemplate.class);
|
||||
for(ComplexStringCfgTemplate cfg : list){
|
||||
List<HttpResHeadCfg> headList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
HttpResHeadCfg head = new HttpResHeadCfg();
|
||||
BeanUtils.copyProperties(cfg, head);
|
||||
head.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
head.setCfgType(cfgIndex.getCfgType());
|
||||
headList.add(head);
|
||||
cfgIndex.setHttpResHdrList(headList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}else if(cfgIndex.getCfgType().equals(Constants.HTTP_RES_BODY_REGION)){
|
||||
List<StringCfgTemplate> list = ei.getDataList(StringCfgTemplate.class);
|
||||
for(StringCfgTemplate cfg : list){
|
||||
List<HttpBodyCfg> bodyList = new ArrayList();
|
||||
BeanUtils.copyProperties(cfg, cfgIndex);
|
||||
HttpBodyCfg body = new HttpBodyCfg();
|
||||
BeanUtils.copyProperties(cfg, body);
|
||||
body.setCfgRegionCode(cfgIndex.getCfgRegionCode());
|
||||
body.setCfgType(cfgIndex.getCfgType());
|
||||
bodyList.add(body);
|
||||
cfgIndex.setHttpResBodyList(bodyList);
|
||||
cfgIndex.setIsAreaEffective(0);
|
||||
websiteCfgService.saveHttpCfg(cfgIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
addMessage(redirectAttributes, e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "redirect:" + adminPath +"/ntc/website/httpList?functionId="+cfgIndex.getFunctionId();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,20 +76,177 @@
|
||||
$("#"+openId).show();
|
||||
$("#"+closeId).parent().parent().next("tr").hide();
|
||||
});
|
||||
$(".action").on("change", function() {
|
||||
$("#serviceId").val($(this).attr("serviceId"));
|
||||
$("#protocolId").val($(this).attr("protocolId"));
|
||||
});
|
||||
});
|
||||
|
||||
//导入文件提示框
|
||||
/* function toImport(cfgRegionCode,cfgType){
|
||||
$("#cfgRegionCode").val(cfgRegionCode);
|
||||
$("#cfgType").val(cfgType);
|
||||
$("#import_modal").modal({
|
||||
backdrop:"static",
|
||||
keyboard:false,
|
||||
show:true
|
||||
});
|
||||
}
|
||||
//下载模板
|
||||
function downLoadXLS(){
|
||||
window.location ="${ctx}/ntc/website/import/template?functionId="+$("#functionId").val()+"&cfgRegionCode="+$("#cfgRegionCode").val();
|
||||
}
|
||||
//导入配置
|
||||
function importCfg(){
|
||||
if($("#serviceId").val()==""){
|
||||
alert("请选择action");
|
||||
return ;
|
||||
}
|
||||
var fileName = $(".fileupload-preview", $("#importForm1")).text();
|
||||
var $error = $('.alert-error', $("#importForm1"));
|
||||
if(fileName==""){
|
||||
|
||||
$("span",$error).html("请选择xls或者xlsx格式文件进行导入...");
|
||||
$error.removeClass("hide");
|
||||
$error.addClass("show");
|
||||
return false;
|
||||
|
||||
}else if(fileName.lastIndexOf("\.")==-1||fileName.substring(fileName.lastIndexOf("\.")+1).toLowerCase()!='xls' &&fileName.substring(fileName.lastIndexOf("\.")+1).toLowerCase()!='xlsx'){
|
||||
$("span",$error).html("导入的文件后缀,必须为xls或者xlsx...");
|
||||
$error.removeClass("hide");
|
||||
$error.addClass("show");
|
||||
return false;
|
||||
}
|
||||
$("#import_modal").modal('hide');//导入文件隐藏
|
||||
$("#importForm1").submit();
|
||||
} */
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="page-content">
|
||||
<div class="theme-panel hidden-xs hidden-sm">
|
||||
<%-- <div class="modal fade" id="import_modal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="exampleModalLabel" aria-hidden="true">
|
||||
<form id="importForm1" action="${ctx}/ntc/website/importHttp/"
|
||||
method="post" enctype="multipart/form-data" class="form-horizontal"
|
||||
onsubmit="loading('<spring:message code='loading'/>');">
|
||||
<input type="hidden" id="cfgRegionCode" name="cfgRegionCode"
|
||||
value="" /> <input type="hidden" id="cfgType" name="cfgType"
|
||||
value="" /> <input type="hidden" id="serviceId" name="serviceId"
|
||||
value=""> <input type="hidden" id="protocolId"
|
||||
name="protocolId" value=""> <input type="hidden"
|
||||
id="functionId" name="functionId" value="${cfg.functionId }">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="exampleModalLabel">
|
||||
<spring:message code="import" />
|
||||
</h5>
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="alert alert-error hide">
|
||||
<button class="close" data-dismiss="alert"></button>
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"> <spring:message
|
||||
code="action" />
|
||||
</label>
|
||||
<div class="col-md-6">
|
||||
<c:forEach items="${serviceList}" var="service"
|
||||
varStatus="satus">
|
||||
<label class="radio-inline"> <c:if
|
||||
test="${cfg.functionId eq service.functionId}">
|
||||
<input type="radio" name="action"
|
||||
serviceId="${service.serviceId }"
|
||||
protocolId="${service.protocolId }"
|
||||
value="${service.action }" class="required action">
|
||||
<spring:message code="${service.actionCode }" />
|
||||
</c:if>
|
||||
</label>
|
||||
</c:forEach>
|
||||
</div>
|
||||
<div for="action"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="form-group">
|
||||
<label class="col-md-2 control-label" style="margin-top:5px;"><spring:message
|
||||
code="chooseFile" />:</label>
|
||||
<div class="controls">
|
||||
|
||||
<div class="fileupload fileupload-new"
|
||||
data-provides="fileupload">
|
||||
|
||||
<div class="input-append">
|
||||
|
||||
<div class="uneditable-input">
|
||||
<i class="fa fa-fa fa-file"></i> <span
|
||||
class="fileupload-preview"></span>
|
||||
</div>
|
||||
<span class="btn btn-file ">
|
||||
<button type="button" class="btn fileupload-new">
|
||||
<spring:message code="add" />
|
||||
</button>
|
||||
<button type="button" class="btn fileupload-exists">
|
||||
<spring:message code="edit" />
|
||||
</button> <input type="file" class="default" id="uploadFile"
|
||||
name="file" /> <input type="hidden" name="flag"
|
||||
value="${flag }" />
|
||||
</span>
|
||||
<button type="button" class="btn red fileupload-exists"
|
||||
data-dismiss="fileupload" style="margin-left:-1px;">
|
||||
<spring:message code="remove" />
|
||||
</a>
|
||||
<button type="button" onclick="downLoadXLS()"
|
||||
class="btn black" style="margin-left:-1px">
|
||||
<spring:message code="download" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn red" onclick="importCfg()">
|
||||
<spring:message code="ok" />
|
||||
</button>
|
||||
<button type="button" class="btn" data-dismiss="modal">
|
||||
<spring:message code="close" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div> --%>
|
||||
|
||||
<div class="theme-panel hidden-xs hidden-sm">
|
||||
<shiro:hasPermission name="website:http:config">
|
||||
<button type="button" class="btn btn-primary"
|
||||
onClick="javascript:window.location='${ctx}/ntc/website/httpForm?functionId=${cfg.functionId}'">
|
||||
<i class="fa fa-plus"></i>
|
||||
<spring:message code="add"></spring:message></button>
|
||||
<spring:message code="add"></spring:message></button>
|
||||
<!-- 导入功能按钮 -->
|
||||
<%-- <div class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle green" data-toggle="dropdown">
|
||||
<i class="fa fa-wrench"></i> <spring:message code="import"></spring:message>
|
||||
<i class="fa fa-angle-down"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right">
|
||||
<c:forEach items="${regionList}" var="region" varStatus="status">
|
||||
<li><a href="javascript:;" onClick="toImport('${region.configRegionCode}','${region.configRegionValue}');">
|
||||
<i class="fa fa-upload"></i><spring:message code="${region.configRegionValue}"/></a></li>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</div> --%>
|
||||
</shiro:hasPermission>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
|
||||
$("button[data-dismiss='modal']").click(function (){
|
||||
|
||||
alert("close");
|
||||
|
||||
window.location ="${ctx}/specific/specificServiceHostCfg/list";
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user