From 35fc8862ca630894fc0d317c16e5b44f8008b660 Mon Sep 17 00:00:00 2001 From: wangxin Date: Thu, 21 Jun 2018 13:55:17 +0800 Subject: [PATCH] =?UTF-8?q?IP=E6=8B=A6=E6=88=AA=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../proxy/InterceptController.java | 131 +++++++ .../webapp/WEB-INF/views/cfg/iplist/form.jsp | 24 +- .../webapp/WEB-INF/views/cfg/iplist/list.jsp | 5 - .../webapp/WEB-INF/views/cfg/proxy/ipForm.jsp | 171 +++++++++ .../webapp/WEB-INF/views/cfg/proxy/ipList.jsp | 336 ++++++++++++++++++ .../WEB-INF/views/cfg/whitelist/ipForm.jsp | 6 +- 6 files changed, 663 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java create mode 100644 src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp create mode 100644 src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp diff --git a/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java new file mode 100644 index 000000000..a2175041b --- /dev/null +++ b/src/main/java/com/nis/web/controller/configuration/proxy/InterceptController.java @@ -0,0 +1,131 @@ +package com.nis.web.controller.configuration.proxy; + +import java.util.Date; +import java.util.List; + +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.servlet.mvc.support.RedirectAttributes; + +import com.nis.domain.Page; +import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseIpCfg; +import com.nis.domain.configuration.BaseStringCfg; +import com.nis.domain.configuration.HttpUrlCfg; +import com.nis.domain.configuration.IpPortCfg; +import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; +import com.nis.web.controller.BaseController; + +/** + * IP相关配置控制类 + * @author dell + * + */ +@Controller +@RequestMapping("${adminPath}/proxy/intercept") +public class InterceptController extends BaseController{ + @RequestMapping(value = {"/ip/list"}) + @RequiresPermissions(value={"intercept:ip:config","intercept:ip:audit"},logical=Logical.OR) + public String ipList(Model model,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) { + cfg.setTableName(IpPortCfg.getTablename()); + Page searchPage=new Page(request,response,"r"); + Page page = ipCfgService.findPage(searchPage, cfg); + model.addAttribute("page", page); + initPageCondition(model,cfg); + return "/cfg/proxy/ipList"; + } + @RequestMapping(value = {"/ip/form"}) + @RequiresPermissions(value={"intercept:ip:config"}) + public String ipForm(Model model,String ids,BaseIpCfg entity) { + if(StringUtils.isNotBlank(ids)){ + entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids)); + } + if(entity.getCfgId()!=null){ + List areaCfg=ipCfgService.getListByComileId(AreaIpCfg.getTablename(), String.valueOf(entity.getCompileId())); + model.addAttribute("areaCfgs", areaCfg); + model.addAttribute("_cfg", entity); + initUpdateFormCondition(model,entity); + }else{ + IpPortCfg cfg=new IpPortCfg(); + cfg.initDefaultValueImpl(); + cfg.setFunctionId(entity.getFunctionId()); + cfg.setProtocolId(entity.getProtocolId()); + model.addAttribute("_cfg", cfg); + initFormCondition(model,entity); + } + + return "/cfg/proxy/ipForm"; + } + @RequestMapping(value = {"/ip/saveOrUpdate"}) + public String saveOrUpdateIp(RedirectAttributes model, IpPortCfg cfg) { + Date date=new Date(); + cfg.setTableName(IpPortCfg.getTablename()); + logger.info("saveOrUpdateIp loaded"); + try{ + cfg.setIsValid(Constants.VALID_NO); + cfg.setIsAudit(Constants.AUDIT_NOT_YET); + if(cfg.getCfgId()==null){//新增 + cfg.setCreatorId(cfg.getCurrentUser().getId()); + cfg.setCreateTime(date); + ipCfgService.addIpCfg(cfg); + }else{//修改 + cfg.setEditorId(cfg.getCurrentUser().getId()); + cfg.setEditTime(new Date()); + ipCfgService.updateIpCfg(cfg); + } + addMessage(model,"save_success"); + }catch(Exception e){ + logger.error("保存失败",e); + addMessage(model,"save_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId(); + } + @RequestMapping(value = {"/ip/delete"}) + @RequiresPermissions("iplist:config") + public String deleteIp(String ids,String compileIds,Integer functionId,RedirectAttributes model) { + try{ + ipCfgService.deleteIp(ids,compileIds,functionId.intValue()); + addMessage(model,"delete_success"); + }catch(Exception e){ + logger.error("删除失败", e); + addMessage(model,"delete_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+functionId; + } + @RequestMapping(value = {"/ip/audit"}) +// @RequiresPermissions("intercept:ip:audit") + public String auditIp(String ids,IpPortCfg cfg,RedirectAttributes redirectAttributes) { + try{ + for(String id:ids.split(",")){ + Long.parseLong(id); + } + List beans=ipCfgService.getListByCfgId(IpPortCfg.getTablename(),ids); + Date date=new Date(); + for(BaseIpCfg bean:beans){ + bean.setTableName(IpPortCfg.getTablename()); + bean.setAuditorId(bean.getCurrentUser().getId()); + bean.setAuditTime(date); + bean.setIsAudit(cfg.getIsAudit()); + bean.setIsValid(cfg.getIsValid()); + ipCfgService.audit(bean); + } + addMessage(redirectAttributes,"audit_success"); + }catch(MaatConvertException e){ + logger.error("审核失败", e); + addMessage(redirectAttributes, e.getMessage()); + }catch(Exception e){ + logger.error("审核失败", e); + addMessage(redirectAttributes, "audit_failed"); + } + return "redirect:" + adminPath +"/proxy/intercept/ip/list?functionId="+cfg.getFunctionId(); + } +} diff --git a/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp b/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp index c2e4f0196..2998888ba 100644 --- a/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/iplist/form.jsp @@ -32,8 +32,10 @@ $(function(){ } }); - $("#serviceId").val($(".action:checked").attr("serviceId")); - $("#protocolId").val($(".action:checked").attr("protocolId")); + if('${fn:length(serviceList)}'>1){ + $("#serviceId").val($(".action:checked").attr("serviceId")); + $("#protocolId").val($(".action:checked").attr("protocolId")); + } $("#ipCfgFrom").validate({ errorPlacement: function(error,element){ $(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error); @@ -70,9 +72,19 @@ $(function(){ - + + + + + + + + + + + @@ -110,7 +122,11 @@ $(function(){ protocolId="${service.protocolId }" value="${service.action }" class="required action" checked> - + + + + + diff --git a/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp b/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp index 9bef658a1..d6e008c54 100644 --- a/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/iplist/list.jsp @@ -14,11 +14,6 @@ data.obj=$(this) GetLogTotal('${ctx}',data); }); - //$("#loadingModal").modal("show"); - //setTimeout(function(){ - // $("#loadingModal").modal("hide"); - //},1000); - //$("#loadingModal").modal({backdrop:'static',keybord:false}); //搜索框提示语初始化 if("${cfg.srcIpAddress}"){ $("#intype").val("${cfg.srcIpAddress}"); diff --git a/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp new file mode 100644 index 000000000..18bd242ae --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/proxy/ipForm.jsp @@ -0,0 +1,171 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="ip_intercept"></spring:message> + + + +
+

+ +

+
+
+
+
+
+ + + +
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + + +
+
+
+
+
+
+ + + + + + + <%@include file="/WEB-INF/include/form/ipInfo.jsp" %> + <%@include file="/WEB-INF/include/form/areaInfo.jsp" %> + <%@include file="/WEB-INF/include/form/basicInfo.jsp" %> +
+
+
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp b/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp new file mode 100644 index 000000000..a8fd29272 --- /dev/null +++ b/src/main/webapp/WEB-INF/views/cfg/proxy/ipList.jsp @@ -0,0 +1,336 @@ +<%@ page contentType="text/html;charset=UTF-8"%> +<%@ include file="/WEB-INF/include/taglib.jsp"%> + + +<spring:message code="ip_intercept"></spring:message> + + + + +
+ +

+ + +

+ +
+
+
+
+
+ + + + + + + + +
+
+ + + + + + +
+
+ +
+
+ + + + + + + + + +
+ + + +
+
+
+ + + +
+
+ + + + + +
+ + +
+
+ + href="javascript:;"> + + +
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ + " onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/> + +
+
+
+
+ +
+
+
+ + + + + + <%-- --%> + + + + + + + + + + + + + + + + + + + + + + + + <%-- --%> + + + + + + + <%-- --%> + + + + + + + + + + + + + + + <%-- --%> + + + + + + + + + + + + +
ip
${status.index+1 }${cfg.cfgDesc } + ${ipType.itemValue} + ${cfg.srcIpAddress }${cfg.srcPort }${cfg.destIpAddress }${cfg.destPort } + + + + + + + + + + + + + + + + + + + ${cfg.requestName } + + + + ${fl.itemValue}, + + + + + + + ${xz.itemValue}, + + + + + + ${lable.itemValue}, + + + ${cfg.areaEffectiveIds } + + + + + + + + + + +
${cfg.creatorName }${cfg.editorName }${cfg.auditorName }
+
${page}
+
+ +
+
+
+ + \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp index a7b77d615..afb81986e 100644 --- a/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/whitelist/ipForm.jsp @@ -216,7 +216,11 @@ $(function(){ checked> - + + + + +