HTTP配置增加excel导入功能,但导入功能按钮暂时隐藏,待后续完善。
Signed-off-by: zhangwei <zhangwei@intranet.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user