IP白名单增删改查提交

This commit is contained in:
wangxin
2018-05-21 19:42:24 +08:00
parent 947a21c9f0
commit 43337bf51c
9 changed files with 713 additions and 102 deletions

View File

@@ -34,6 +34,11 @@ public class IpPortCfg extends BaseIpCfg {
super.initDefaultValue();
this.protocolId = 0;
}
public void initDefaultValueImpl(){
initDefaultValue();
this.portPattern=1;
this.port="0/0";
}
/**
* 此表固定写0
*/

View File

@@ -256,6 +256,20 @@ public class BaseController {
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
model.addAttribute("lables", lables);
}
protected void initPageCondition(Model model,BaseCfg cfg){
List<RequestInfo> requestInfos=requestInfoService.getAllRequestInfo();
model.addAttribute("requestInfos", requestInfos);
List<ServiceDictInfo> fls=serviceDictInfoService.findAllFlDict();
model.addAttribute("fls", fls);
List<ServiceDictInfo> xzs=serviceDictInfoService.findAllXzDict();
model.addAttribute("xzs", xzs);
List<ServiceDictInfo> lables=serviceDictInfoService.findAllLableDict();
model.addAttribute("lables", lables);
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(cfg.getFunctionId());
model.addAttribute("regionList", regionList);
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(cfg.getFunctionId());
model.addAttribute("serviceList", serviceList);
}
protected void initFormCondition(Model model){
List<RequestInfo> requestInfos=requestInfoService.getValidRequestInfo();
model.addAttribute("requestInfos", requestInfos);

View File

@@ -0,0 +1,140 @@
package com.nis.web.controller.configuration.ntc;
import java.util.ArrayList;
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 com.nis.domain.Page;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.main.ConvertTool;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController;
/**
* 白名单
* @author dell
*
*/
@Controller
@RequestMapping("${adminPath}/ntc/whitelist")
public class WhiteListController extends BaseController{
@RequestMapping(value = {"ipList"})
@RequiresPermissions(value={"whitelist:config","whitelist:audit"},logical=Logical.OR)
public String ipList(Model model,String cfgName,@ModelAttribute("cfg")IpPortCfg cfg,HttpServletRequest request,HttpServletResponse response) {
model.addAttribute("cfgName", cfgName);
cfg.setTableName(IpPortCfg.getTablename());
Page<BaseIpCfg> searchPage=new Page<BaseIpCfg>(request,response,"r");
Page<BaseIpCfg> page = ipCfgService.findPage(searchPage, cfg);
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/whitelist/ipList";
}
@RequestMapping(value = {"ipForm"})
@RequiresPermissions(value={"whitelist:config"})
public String ipForm(Model model,String ids,BaseIpCfg entity) {
if(StringUtils.isNotBlank(ids)){
entity = ipCfgService.getIpCfgById(IpPortCfg.getTablename(),Long.parseLong(ids));
}
initFormCondition(model,entity);
if(entity.getCfgId()!=null){
model.addAttribute("_cfg", entity);
}else{
IpPortCfg cfg=new IpPortCfg();
cfg.initDefaultValueImpl();
cfg.setFunctionId(entity.getFunctionId());
model.addAttribute("_cfg", cfg);
}
return "/cfg/whitelist/ipForm";
}
@RequestMapping(value = {"saveOrUpdateIp"})
public String saveOrUpdateIp(Model model, IpPortCfg cfg) {
cfg.setTableName(IpPortCfg.getTablename());
logger.info("saveOrUpdateIp loaded");
try{
if(cfg.getCompileId()==null){
int compileId=0;
cfg.setCompileId(compileId);
}
Date date=new Date();
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((BaseIpCfg)cfg,null);
}else{//修改
cfg.setEditorId(cfg.getCurrentUser().getId());
cfg.setEditTime(new Date());
ipCfgService.updateIpCfg((BaseIpCfg)cfg,null,null,null);
}
addMessage(model,"save_success");
}catch(Exception e){
logger.error("保存失败",e);
addMessage(model,"save_failed");
}
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+cfg.getFunctionId();
}
@RequestMapping(value = {"deleteIp"})
@RequiresPermissions("whitelist:config")
public String deleteIp(Integer isAudit,Integer isValid,String ids,Integer functionId,Model model) {
try{
List<BaseIpCfg> ipCfgs=new ArrayList<BaseIpCfg>();
Date date =new Date();
if(StringUtils.isNotBlank(ids)){
for(String idStr:ids.split(",")){
if(StringUtils.isNotBlank(idStr)){
BaseIpCfg cfg=new BaseIpCfg();
cfg.setCfgId(Long.parseLong(idStr));
cfg.setTableName(IpPortCfg.getTablename());
cfg.setEditorId(cfg.getCurrentUser().getId());
cfg.setEditTime(date);
cfg.setIsValid(Constants.VALID_DEL);
ipCfgs.add(cfg);
}
}
}
ipCfgService.deleteIpCfg(ipCfgs,null);
addMessage(model,"delete_success");
}catch(Exception e){
logger.error("删除失败", e);
addMessage(model,"delete_failed");
}
return "redirect:" + adminPath +"/ntc/whitelist/ipList?functionId="+functionId;
}
/**
*
* getCompileId(获取编译ID)
* (这里描述这个方法适用条件 可选)
* @return
*long
* @exception
* @since 1.0.0
*/
protected long getCompileId(BaseIpCfg cfg){
long compileId=0l;
try {
compileId = cfg.getCompileId()==null?new ConvertTool().getCompileId():cfg.getCompileId();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return compileId;
}
}

View File

@@ -338,6 +338,8 @@
</if>
</otherwise>
</choose>
<!-- 数据范围过滤 -->
${sqlMap.dsf}
</trim>
<choose>
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
@@ -391,25 +393,25 @@
cfg_desc = #{cfgDesc,jdbcType=VARCHAR},
</if>
<if test="cfgRegionCode != null">
CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER}
CFG_REGION_CODE=#{cfgRegionCode,jdbcType=INTEGER},
</if>
<if test="cfgType != null and cfgType != ''">
CFG_TYPE =#{CFG_TYPE,jdbcType=VARCHAR}
CFG_TYPE =#{cfgType,jdbcType=VARCHAR},
</if>
<if test="ipType != null" >
ip_type = #{ipType,jdbcType=INTEGER},
IP_TYPE = #{ipType,jdbcType=INTEGER},
</if>
<if test="ipPattern != null">
IP_PATTERN=#{ipPattern,jdbcType=INTEGER}
IP_PATTERN=#{ipPattern,jdbcType=INTEGER},
</if>
<if test="ipAddress != null and ipAddress != ''">
IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR}
IP_ADDRESS=#{ipAddress,jdbcType=VARCHAR},
</if>
<if test="portPattern != null">
PORT_PATTERN=#{portPattern,jdbcType=INTEGER}
PORT_PATTERN=#{portPattern,jdbcType=INTEGER},
</if>
<if test="port != null and port !=''">
PORT=#{port,jdbcType=VARCHAR}
PORT=#{port,jdbcType=VARCHAR},
</if>
<if test="direction != null" >
direction = #{direction,jdbcType=INTEGER},

View File

@@ -78,6 +78,7 @@ public abstract class CrudService<D extends CrudDao<T>, T extends BaseEntity<T>>
* @return
*/
public Page<T> findPage(Page<T> page, T entity) {
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
entity.setPage(page);
page.setList(dao.findList(entity));
return page;

View File

@@ -114,8 +114,8 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void deleteIpCfg(List<BaseIpCfg> baseIpCfg, List<AreaIpCfg> areaCfg){
List<BaseIpCfg> cfgs=new ArrayList<>();
cfgs.addAll(areaCfg);
if(areaCfg!=null&&areaCfg.size()>0){
cfgs.addAll(areaCfg);
this.deleteBatch(cfgs,IpCfgDao.class);
}
if(baseIpCfg!=null&&baseIpCfg.size()>0){
@@ -137,6 +137,9 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
public BaseIpCfg getIpCfgById(BaseIpCfg baseIpCfg){
return ipCfgDao.getById(baseIpCfg.getTableName(), baseIpCfg.getCfgId());
}
public BaseIpCfg getIpCfgById(String tableName,long id){
return ipCfgDao.getById(tableName, id);
}
public Integer getIsValid(BaseIpCfg baseIpCfg){
return ipCfgDao.getIsValid(baseIpCfg);
}

View File

@@ -6,12 +6,12 @@
<script>
$(document).ready(function() {
//搜索框提示语初始化
if("${ipCfg.srcIp}"){
$("#intype").val("${ipCfg.srcIp}");
} else if("${ipCfg.dstIp}"){
$("#intype").val("${ipCfg.dstIp}");
} else if("${ipCfg.cfgDesc}"){
$("#intype").val("${ipCfg.cfgDesc}");
if("${cfg.ipAddress}"){
$("#intype").val("${cfg.ipAddress}");
} else if("${cfg.port}"){
$("#intype").val("${cfg.port}");
} else if("${cfg.cfgDesc}"){
$("#intype").val("${cfg.cfgDesc}");
} else{
$("#intype").attr("placeholder","<spring:message code='input'/> "+$("#seltype").find("option:selected").text());
}
@@ -55,12 +55,10 @@
<div class="theme-panel hidden-xs hidden-sm">
<%-- <button type="button" class="btn btn-default" onclick="location='${ctx}/cfg/ip/list?serviceId=${serviceId}&action=${action}&cfgName=${cfgName}&audit=${audit}'"><spring:message code="refresh"></spring:message></button> --%>
<c:if test="${audit==0}">
<shiro:hasPermission name="cfg:ip:add">
<button type="button" class="btn btn-primary"
onClick="javascript:window.location='${ctx}/cfg/ip/form?serviceId=${serviceId}&action=${action}&cfgName=${cfgName}&audit=${audit}'">
onClick="javascript:window.location='${ctx}/ntc/whitelist/form?audit=${audit}&cfgName=${cfgName}'">
<i class="fa fa-plus"></i>
<spring:message code="add"></spring:message></button>
</shiro:hasPermission>
</c:if>
</div>
<h3 class="page-title">
@@ -73,7 +71,7 @@
<div class="portlet">
<div class="portlet-body">
<div class="row" >
<form:form id="searchForm" modelAttribute="ipCfg" action="${ctx}/cfg/ip/list" method="post" class="form-search">
<form:form id="searchForm" modelAttribute="cfg" action="${ctx}/cfg/ip/list" method="post" class="form-search">
<input id="cfgName" name="cfgName" type="hidden" value="${cfgName}"/>
<input id="action" name="action" type="hidden" value="${action}"/>
<input id="serviceId" name="serviceId" type="hidden" value="${serviceId}"/>
@@ -83,7 +81,7 @@
<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}"
callback="page();" />
<!-- 筛选按钮展开状态-->
<input id="isFilterAction" name="isFilterAction" type="hidden" value="${ipCfg.isFilterAction }"/>
<input id="isFilterAction" name="isFilterAction" type="hidden" value="${cfg.isFilterAction }"/>
<!-- 搜索内容与操作按钮栏 -->
<div class="col-md-12">
<div class="pull-left">
@@ -225,7 +223,7 @@
<div class="form-group">
<label><spring:message code="config_time"/></label>
<input name="search_create_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value='${ipCfg.search_create_time_start}' pattern='yyyy-MM-dd HH:mm:ss'/>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value='${cfg.search_create_time_start}' pattern='yyyy-MM-dd HH:mm:ss'/>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -233,7 +231,7 @@
<div class="form-group">
<label>&nbsp;</label>
<input name="search_create_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${ipCfg.search_create_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value="${cfg.search_create_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -241,7 +239,7 @@
<div class="form-group">
<label><spring:message code="edit_time"/></label>
<input name="search_edit_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${ipCfg.search_edit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value="${cfg.search_edit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -249,7 +247,7 @@
<div class="form-group">
<label>&nbsp;</label>
<input name="search_edit_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${ipCfg.search_edit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value="${cfg.search_edit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -257,7 +255,7 @@
<div class="form-group">
<label><spring:message code="audit_time"/></label>
<input name="search_audit_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${ipCfg.search_audit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value="${cfg.search_audit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -265,7 +263,7 @@
<div class="form-group">
<label>&nbsp;</label>
<input name="search_audit_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${ipCfg.search_audit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
value="<fmt:formatDate value="${cfg.search_audit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
@@ -320,59 +318,59 @@
</tr>
</thead>
<tbody>
<c:forEach items="${page.list }" var="ipCfg" varStatus="status" step="1">
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr pId="${status.index}">
<td><input type="checkbox" class="i-checks" id="${ipCfg.compileId}" value="${ipCfg.isAudit}"></td>
<td><input type="checkbox" class="i-checks" id="${cfg.compileId}" value="${cfg.isAudit}"></td>
<%-- <td>${status.index+1 }</td> --%>
<td>${ipCfg.cfgDesc }</td>
<td>V${ipCfg.ipType }</td>
<td>${ipCfg.srcIp }</td>
<td>${ipCfg.srcIpMask }</td>
<td>${ipCfg.srcPort }</td>
<td>${ipCfg.srcPortMask }</td>
<td>${ipCfg.dstIp }</td>
<td>${ipCfg.dstIpMask }</td>
<td>${ipCfg.dstPort }</td>
<td>${ipCfg.dstPortMask }</td>
<td>${cfg.cfgDesc }</td>
<td>V${cfg.ipType }</td>
<td>${cfg.srcIp }</td>
<td>${cfg.srcIpMask }</td>
<td>${cfg.srcPort }</td>
<td>${cfg.srcPortMask }</td>
<td>${cfg.dstIp }</td>
<td>${cfg.dstIpMask }</td>
<td>${cfg.dstPort }</td>
<td>${cfg.dstPortMask }</td>
<td>
<c:if test="${1 eq ipCfg.action }"><spring:message code="block"/></c:if>
<c:if test="${2 eq ipCfg.action }"><spring:message code="monitor"/></c:if>
<c:if test="${5 eq ipCfg.action }"><spring:message code="block_white_list"/></c:if>
<c:if test="${6 eq ipCfg.action }"><spring:message code="monitor_white_list"/></c:if>
<c:if test="${7 eq ipCfg.action }"><spring:message code="block_monitor_white_list"/></c:if>
<c:if test="${8 eq ipCfg.action }"><spring:message code="grey_list"/></c:if>
<c:if test="${1 eq cfg.action }"><spring:message code="block"/></c:if>
<c:if test="${2 eq cfg.action }"><spring:message code="monitor"/></c:if>
<c:if test="${5 eq cfg.action }"><spring:message code="block_white_list"/></c:if>
<c:if test="${6 eq cfg.action }"><spring:message code="monitor_white_list"/></c:if>
<c:if test="${7 eq cfg.action }"><spring:message code="block_monitor_white_list"/></c:if>
<c:if test="${8 eq cfg.action }"><spring:message code="grey_list"/></c:if>
</td>
<c:choose>
<c:when test="${action==5}">
</c:when>
<c:when test="${action==8}">
<td>
<c:if test="${ipCfg.direction==0}"><spring:message code="twoway"/></c:if>
<c:if test="${ipCfg.direction==1}"><spring:message code="oneway"/></c:if>
<c:if test="${cfg.direction==0}"><spring:message code="twoway"/></c:if>
<c:if test="${cfg.direction==1}"><spring:message code="oneway"/></c:if>
</td>
<td>
<c:if test="${ipCfg.protocol==6}"><spring:message code="TCP"/></c:if>
<c:if test="${ipCfg.protocol==17}"><spring:message code="UDP"/></c:if>
<c:if test="${ipCfg.protocol==0}"><spring:message code="arbitrary"/></c:if>
<c:if test="${cfg.protocol==6}"><spring:message code="TCP"/></c:if>
<c:if test="${cfg.protocol==17}"><spring:message code="UDP"/></c:if>
<c:if test="${cfg.protocol==0}"><spring:message code="arbitrary"/></c:if>
</td>
</c:when>
<c:otherwise>
<td>
<c:if test="${ipCfg.direction==0}"><spring:message code="twoway"/></c:if>
<c:if test="${ipCfg.direction==1}"><spring:message code="oneway"/></c:if>
<c:if test="${cfg.direction==0}"><spring:message code="twoway"/></c:if>
<c:if test="${cfg.direction==1}"><spring:message code="oneway"/></c:if>
</td>
<td>
<c:if test="${ipCfg.protocol==6}"><spring:message code="TCP"/></c:if>
<c:if test="${ipCfg.protocol==17}"><spring:message code="UDP"/></c:if>
<c:if test="${ipCfg.protocol==0}"><spring:message code="arbitrary"/></c:if>
<c:if test="${cfg.protocol==6}"><spring:message code="TCP"/></c:if>
<c:if test="${cfg.protocol==17}"><spring:message code="UDP"/></c:if>
<c:if test="${cfg.protocol==0}"><spring:message code="arbitrary"/></c:if>
</td>
<td>
<c:if test="${ipCfg.isAreaEffective==0}"><spring:message code="no"/></c:if>
<c:if test="${ipCfg.isAreaEffective==1}"><spring:message code="yes"/></c:if>
<c:if test="${cfg.isAreaEffective==0}"><spring:message code="no"/></c:if>
<c:if test="${cfg.isAreaEffective==1}"><spring:message code="yes"/></c:if>
</td>
<td>${ipCfg.requestName }</td>
<td>${cfg.requestName }</td>
<td>
<c:forEach items="${fn:split(ipCfg.classify,',')}" var="classifyId">
<c:forEach items="${fn:split(cfg.classify,',')}" var="classifyId">
<c:forEach items="${fls}" var="fl">
<c:if test="${fn:trim(fl.serviceDictId) eq classifyId}">
${fl.itemValue},
@@ -382,14 +380,14 @@
${classifyName[status]}
</td>
<td>
<c:forEach items="${fn:split(ipCfg.attribute,',')}" var="attributeId">
<c:forEach items="${fn:split(cfg.attribute,',')}" var="attributeId">
<c:forEach items="${xzs}" var="xz">
<c:if test="${fn:trim(xz.serviceDictId) eq attributeId}">${xz.itemValue},</c:if>
</c:forEach>
</c:forEach>
</td>
<td>
<c:forEach items="${fn:split(ipCfg.lable,',')}" var="lableId">
<c:forEach items="${fn:split(cfg.lable,',')}" var="lableId">
<c:forEach items="${lables}" var="lable">
<c:if test="${fn:trim(lable.serviceDictId) eq lableId}">${lable.itemValue},</c:if>
</c:forEach>
@@ -397,55 +395,26 @@
</td>
</c:otherwise>
</c:choose>
<%-- <td>${ipCfg.areaEffectiveIds }</td> --%>
<%-- <td>${cfg.areaEffectiveIds }</td> --%>
<td>
<c:if test="${ipCfg.isValid==0}"><spring:message code="no"/></c:if>
<c:if test="${ipCfg.isValid==1}"><spring:message code="yes"/></c:if>
<c:if test="${ipCfg.isValid==-1}"><spring:message code="deleted"/></c:if>
<c:if test="${cfg.isValid==0}"><spring:message code="no"/></c:if>
<c:if test="${cfg.isValid==1}"><spring:message code="yes"/></c:if>
<c:if test="${cfg.isValid==-1}"><spring:message code="deleted"/></c:if>
</td>
<td>
<c:choose>
<c:when test="${ipCfg.isAudit eq '0'}"><span class="label label-danger"><spring:message code="created"></spring:message></span></c:when>
<c:when test="${ipCfg.isAudit eq '1'}"><span class="label label-success"><spring:message code="approved"></spring:message></span></c:when>
<c:when test="${ipCfg.isAudit eq '2'}"><span class="label label-warning"><spring:message code="unapproved"></spring:message></span></c:when>
<c:when test="${ipCfg.isAudit eq '3'}"><span class="label label-warning"><spring:message code="cancel_approved"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '0'}"><span class="label label-danger"><spring:message code="created"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '1'}"><span class="label label-success"><spring:message code="approved"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '2'}"><span class="label label-warning"><spring:message code="unapproved"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '3'}"><span class="label label-warning"><spring:message code="cancel_approved"></spring:message></span></c:when>
</c:choose>
</td>
<td>${ipCfg.creatorName }</td>
<td><fmt:formatDate value="${ipCfg.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${ipCfg.editorName }</td>
<td><fmt:formatDate value="${ipCfg.editTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${ipCfg.auditorName }</td>
<td><fmt:formatDate value="${ipCfg.auditTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<%-- <td>
<div class="btn-group btn-xs">
<a class="btn btn-primary btn-xs dropdown-toggle" data-toggle="dropdown" href="#"><spring:message code="operation"></spring:message><span class="caret"></span></a>
<ul class="dropdown-menu btn-xs">
<c:if test="${audit==0}">
<c:choose>
<c:when test="${ipCfg.isAudit eq '2'}">
<li><a href="${ctx}/cfg/ip/updateForm?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}" onclick="javascript:return confirm('sure', this.href)"><spring:message code="edit"></spring:message></a></li>
</c:when>
<c:when test="${ipCfg.isAudit eq '0'}">
<li><a href="${ctx}/cfg/ip/updateForm?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}" onclick="javascript:return confirm('sure', this.href)"><spring:message code="edit"></spring:message></a></li>
<li><a href="${ctx}/cfg/ip/delete?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&cfgName=${cfgName}&compileId=${ipCfg.compileId}" onclick="return confirm('sure', this.href)"><spring:message code="delete"></spring:message></a></li>
</c:when>
</c:choose>
</c:if>
<c:if test="${audit==1}">
<c:choose>
<c:when test="${ipCfg.isAudit eq '1'}">
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=3&cfgName=${cfgName}" onclick="return confirm('sure', this.href)"><spring:message code="cancel"></spring:message></a></li>
</c:when>
<c:when test="${ipCfg.isAudit eq '0'}">
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=1&cfgName=${cfgName}" onclick="return confirm('sure', this.href)"><spring:message code="approved"></spring:message></a></li>
<li><a href="${ctx}/cfg/ip/audit?serviceId=${ipCfg.serviceId}&action=${ipCfg.action}&tableName=${ipCfg.tableName}&cfgId=${ipCfg.cfgId}&isAudit=2&cfgName=${cfgName}" onclick="return confirm('sure', this.href)"><spring:message code="unapproved"></spring:message></a></li>
</c:when>
</c:choose>
</c:if>
</ul>
</div>
</td> --%>
<td>${cfg.creatorName }</td>
<td><fmt:formatDate value="${cfg.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${cfg.editorName }</td>
<td><fmt:formatDate value="${cfg.editTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${cfg.auditorName }</td>
<td><fmt:formatDate value="${cfg.auditTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
</tr>
</c:forEach>
</tbody>

View File

@@ -0,0 +1,211 @@
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<html>
<head>
<title><spring:message code="${cfgName}"></spring:message></title>
<script type="text/javascript">
$(function(){
switchIpType($("select[name$='ipType']"));
$("input[name='isAreaEffective']").on('change',function(){
var val=$(this).val();
if(val==1){
$(".areaType").removeClass("hidden");
if($("input[name='areaType']:checked").val()==1){//areaISP
$("#areaIsp").removeClass("hidden");
}else if($("input[name='areaType']:checked").val()==0){//areaIp
$("#areaIp").removeClass("hidden");
}
}else{
$(".areaType").addClass("hidden");
$("#areaIp").addClass("hidden");
$("#areaIsp").addClass("hidden");
}
});
$("input[name='areaType']").on('change',function(){
var val=$(this).val();
if($(this).is(":visible")){
if(val==0){
$("#areaIp").removeClass("hidden");
$("#areaIsp").addClass("hidden");
}else{
$("#areaIsp").removeClass("hidden");
$("#areaIp").addClass("hidden");
}
}else{
$("#areaIsp").addClass("hidden");
$("#areaIp").addClass("hidden");
}
});
$("#cancel").on("click",function(){
window.history.back();
});
$("select[name$='ipType']").on("change",function(){
switchIpType($(this));
});
$(".action").on("change",function(){
$("#serviceId").val($(this).attr("serviceId"));
});
$("#ipCfgFrom").validate({
errorPlacement: function(error,element){
$(element).parents(".form-group").find("div[for='"+element.attr("name")+"']").append(error);
},
submitHandler: function(form){
//loading('onloading...');
form.submit();
},
errorContainer: "#messageBox",
});
});
</script>
</head>
<body>
<div class="page-content">
<h3 class="page-title">
<spring:message code="${cfgName}"></spring:message>
</h3>
<div class="row">
<div class="col-md-12">
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-gift"></i>
<c:if test="${empty _cfg.cfgId}"><spring:message code="add"></spring:message></c:if>
<c:if test="${not empty _cfg.cfgId}"><spring:message code="edit"></spring:message></c:if>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form id="ipCfgFrom" action="${ctx}/ntc/whitelist/saveOrUpdateIp" method="post" class="form-horizontal">
<div class="form-body">
<input type="hidden" name="cfgId" value="${_cfg.cfgId}">
<input type="hidden" name="compileId" value="${_cfg.compileId}">
<input type="hidden" name="protocolId" value="${_cfg.protocolId}">
<input type="hidden" name=requestId value="0">
<input type="hidden" name="functionId" value="${_cfg.functionId}">
<input type="hidden" id="serviceId" name="serviceId" value="${_cfg.serviceId}">
<input type="hidden" name="protocol" value="0">
<input type="hidden" name="direction" value="0">
<input type="hidden" name="isAreaEffective" value="0">
<!-- 配置域类型 -->
<c:forEach items="${regionList}" var="region">
<c:if test="${_cfg.functionId eq region.functionId}">
<input type="hidden" name="cfgType" value="${region.configRegionValue}">
<input type="hidden" name="cfgRegionCode" value="${region.configRegionCode}">
</c:if>
</c:forEach>
<h3 class="form-section"><spring:message code="block_config"/></h3>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><spring:message code="config_describe"/></label>
<div class="col-md-6">
<input class="form-control" type="text" id="cfgDesc" name="cfgDesc" value="${_cfg.cfgDesc}">
</div>
<div for="cfgDesc"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_type"/></label>
<div class="col-md-6">
<select name="ipType" class="selectpicker show-tick form-control required">
<option value="4" <c:if test="${_cfg.ipType==4}">selected</c:if> >V4</option>
<option value="6" <c:if test="${_cfg.ipType==6}">selected</c:if>>V6</option>
</select>
</div>
<div for="ipType"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<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">
<label class="radio-inline">
<c:if test="${_cfg.functionId eq service.functionId}">
<input type="radio" name="action" serviceId="${service.serviceId }" value="${service.action }" class="required action"
<c:if test="${_cfg.action==service.action}">checked</c:if>>
<spring:message code="${service.actionCode }"/>
</c:if>
</label>
</c:forEach>
</div>
<div for="action"></div>
</div>
</div>
</div>
<div class="row ip">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_pattern"/></label>
<div class="col-md-6">
<select name="ipPattern" class="selectpicker show-tick form-control required">
<option value="1" <c:if test="${_cfg.ipPattern==1}">selected</c:if> ><spring:message code="subnet"/></option>
<option value="2" <c:if test="${_cfg.ipPattern==2}">selected</c:if>><spring:message code="ip_range"/></option>
</select>
<!-- <input class="form-control" type="text" value="${_cfg.ipType}">-->
</div>
<div for="ipPattern"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="ip_address"/></label>
<div class="col-md-6">
<input class="form-control required" type="text" name="ipAddress" value="${_cfg.ipAddress}">
</div>
<div for="ipAddress"></div>
</div>
</div>
</div>
<div class="row hidden disabled port">
<div class="col-md-6">
<div class="form-group">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="port_pattern"/></label>
<div class="col-md-6">
<select name="portPattern" class="selectpicker show-tick form-control required">
<option value="1" <c:if test="${_cfg.portPattern==1}">selected</c:if> ><spring:message code="subnet"/></option>
<option value="2" <c:if test="${_cfg.portPattern==2}">selected</c:if>><spring:message code="port_range"/></option>
</select>
</div>
<div for="portPattern"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group ">
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="port"/></label>
<div class="col-md-6">
<input class="form-control required" type="text" name="port" value="${_cfg.port}">
</div>
<div for="port"></div>
</div>
</div>
</div>
<div class="row">
<button type="button" class="btn btn-red-hollow center-block" onClick="more(this);" data-click-times="0"><spring:message code="show_more"/></button>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-6">
<div class="row">
<div class="col-md-offset-3 col-md-8">
<button id="save" type="submit" class="btn green"><spring:message code="submit"/></button>
<button id="cancel" type="button" class="btn default"><spring:message code="cancel"/></button>
</div>
</div>
</div>
<div class="col-md-6"> </div>
</div>
</div>
</form>
<!-- END FORM-->
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,266 @@
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/include/taglib.jsp"%>
<html>
<head>
<title><spring:message code="${cfgName}"></spring:message></title>
<script>
$(document).ready(function() {
//搜索框提示语初始化
if("${cfg.ipAddress}"){
$("#intype").val("${cfg.ipAddress}");
} else if("${cfg.port}"){
$("#intype").val("${cfg.port}");
} else if("${cfg.cfgDesc}"){
$("#intype").val("${cfg.cfgDesc}");
} else{
$("#intype").attr("placeholder","<spring:message code='input'/> "+$("#seltype").find("option:selected").text());
}
$("#seltype").change(function(){
$("#intype").attr("placeholder","<spring:message code='input'/> "+$(this).find("option:selected").text());
});
//筛选功能初始化
filterActionInit();
$("#isAudit").change(function(){
page();
});
//reset
$("#resetBtn").on("click",function(){
$("select.selectpicker").each(function(){
$(this).selectpicker('val',$(this).find('option:first').val());
$(this).find("option").attr("selected",false);
$(this).find("option:first").attr("selected",true);
});
$(".Wdate").attr("value",'');
$("#searchForm")[0].reset();
});
});
var edit=function(url){
var cked = $('tbody tr td input.i-checks:checkbox:checked');
if(cked.val()==1){
top.$.jBox.tip("<spring:message code='has_approved'/>", "<spring:message code='info'/>");
return;
}
if(cked.length==1){
window.location = url+"&compileId="+cked.attr("id");
}else{
top.$.jBox.tip("<spring:message code='check_one'/>", "<spring:message code='info'/>");
return;
}
}
</script>
</head>
<body>
<div class="page-content">
<div class="theme-panel hidden-xs hidden-sm">
<%-- <button type="button" class="btn btn-default" onclick="location='${ctx}/cfg/ip/list?serviceId=${serviceId}&action=${action}&cfgName=${cfgName}&audit=${audit}'"><spring:message code="refresh"></spring:message></button> --%>
<shiro:hasPermission name="whitelist:config">
<button type="button" class="btn btn-primary"
onClick="javascript:window.location='${ctx}/ntc/whitelist/ipForm?functionId=${cfg.functionId}'">
<i class="fa fa-plus"></i>
<spring:message code="add"></spring:message></button>
</shiro:hasPermission>
</div>
<h3 class="page-title">
<spring:message code="${cfgName}"></spring:message>
<small><spring:message code="date_list"/></small>
</h3>
<h5 class="page-header"></h5>
<div class="row">
<div class="col-md-12">
<div class="portlet">
<div class="portlet-body">
<div class="row" >
<form:form id="searchForm" modelAttribute="cfg" action="${ctx}/ntc/whitelist/ipList" method="post" class="form-search">
<input id="functionId" name="functionId" type="hidden" value="${cfg.functionId}"/>
<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}"
callback="page();" />
<!-- 筛选按钮展开状态-->
<input id="isFilterAction" name="isFilterAction" type="hidden" value="${cfg.isFilterAction }"/>
<!-- 搜索内容与操作按钮栏 -->
<div class="col-md-12">
<div class="pull-left">
<form:select path="isAudit" class="selectpicker select2 input-small">
<form:option value=""><spring:message code="all_states"/></form:option>
<form:option value="0"><spring:message code="created"></spring:message></form:option>
<form:option value="1"><spring:message code="approved"></spring:message></form:option>
<form:option value="2"><spring:message code="unapproved"></spring:message></form:option>
<form:option value="3"><spring:message code="cancel_approved"></spring:message></form:option>
</form:select>
</div>
<div class="pull-left">
<div class="input-group">
<div class="input-group-btn">
<form:select path="seltype" class="selectpicker select2 input-small" >
<form:option value="ipAddress"><spring:message code="ip_address"></spring:message></form:option>
<form:option value="port"><spring:message code="port"></spring:message></form:option>
<form:option value="cfgDesc"><spring:message code="config_describe"></spring:message></form:option>
</form:select>
</div>
<input id="intype" class="form-control input-medium" type="text" value="">
</div>
</div>
<div class="pull-left">
<button type="button" class="btn blue" onClick="return page()"> <i class="fa fa-search"></i> <spring:message code="search"/> </button>
<button type="button" class="btn btn-default" id="resetBtn" > <i class="fa fa-refresh"></i> <spring:message code="reset"/> </button>
<button type="button" class="btn btn-default" id="filter-btn"> <spring:message code="filter"/><i class="fa fa-angle-double-down"></i></button>
</div>
<div class="pull-right">
<shiro:hasPermission name="whitelist:config">
<sys:delRow url="${ctx}/ntc/whitelist/ipForm" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/ntc/whitelist/deleteIp?isValid=-1&functionId=${cfg.functionId}" id="contentTable" label="delete"></sys:delRow>
</shiro:hasPermission>
<shiro:hasPermission name="whitelist:audit">
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-wrench"></i> <spring:message code="examine"></spring:message>
<i class="fa fa-angle-down"></i>
</button>
<ul class="dropdown-menu pull-right">
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=1&isValid=1" id="contentTable" label="approved"></sys:delRow></li>
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=2&isValid=0" id="contentTable" label="unapproved"></sys:delRow></li>
<li><sys:delRow url="${ctx}/ntc/whitelist/auditIp?isAudit=3&isValid=0" id="contentTable" label="cancelPass"></sys:delRow></li>
</ul>
</div>
</shiro:hasPermission>
<a class="btn btn-icon-only btn-default setfields tooltips"
data-container="body" data-placement="top" data-original-title=<spring:message code="custom_columns"/> href="javascript:;">
<i class="icon-wrench"></i>
</a>
</div>
</div>
<!-- 搜索内容与操作按钮栏 -->
<!-- 筛选搜索内容栏默认隐藏-->
<div class="col-md-12 filter-action-select-panle hide" >
<div class="row">
<div class="col-md-2">
<div class="form-group">
<label><spring:message code="config_time"/></label>
<input name="search_create_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value='${cfg.search_create_time_start}' pattern='yyyy-MM-dd HH:mm:ss'/>" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>&nbsp;</label>
<input name="search_create_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${cfg.search_create_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label><spring:message code="edit_time"/></label>
<input name="search_edit_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${cfg.search_edit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>&nbsp;</label>
<input name="search_edit_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${cfg.search_edit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label><spring:message code="audit_time"/></label>
<input name="search_audit_time_start" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${cfg.search_audit_time_start}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>&nbsp;</label>
<input name="search_audit_time_end" type="text" readonly="readonly" maxlength="20" class="form-control Wdate"
value="<fmt:formatDate value="${cfg.search_audit_time_end}" pattern="yyyy-MM-dd HH:mm:ss"/>" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
</div>
</div>
</div>
</div>
<!-- /筛选搜索内容栏 结束-->
</form:form>
</div>
<div class="table-responsive">
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
<thead>
<tr>
<th><input type="checkbox" class="i-checks" id="checkAll"></th>
<%-- <th><spring:message code="seq"/></th> --%>
<th><spring:message code="config_describe"/></th>
<th>ip<spring:message code="type"/></th>
<th><spring:message code="ip"/></th>
<th><spring:message code="port"/></th>
<th><spring:message code="block_type"/></th>
<th><spring:message code="valid_identifier"/></th>
<th><spring:message code="is_audit"/></th>
<th><spring:message code="creator"/></th>
<th class="sort-column r.create_time"><spring:message code="config_time"/></th>
<th><spring:message code="editor"/></th>
<th class="sort-column r.edit_time"><spring:message code="edit_time"/></th>
<th><spring:message code="auditor"/></th>
<th class="sort-column r.audit_time"><spring:message code="audit_time"/></th>
<%-- <th><spring:message code="operation"></spring:message></th> --%>
</tr>
</thead>
<tbody>
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr pId="${status.index}">
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" value="${cfg.isAudit}"></td>
<%-- <td>${status.index+1 }</td> --%>
<td>${cfg.cfgDesc }</td>
<td>V${cfg.ipType }</td>
<td>${cfg.ipAddress }</td>
<td>${cfg.port }</td>
<td>
<c:forEach items="${serviceList}" var="service">
<c:if test="${cfg.action eq service.action}"><spring:message code="${service.actionCode }"/></c:if>
</c:forEach>
</td>
<%-- <td>${cfg.areaEffectiveIds }</td> --%>
<td>
<c:if test="${cfg.isValid==0}"><spring:message code="no"/></c:if>
<c:if test="${cfg.isValid==1}"><spring:message code="yes"/></c:if>
<c:if test="${cfg.isValid==-1}"><spring:message code="deleted"/></c:if>
</td>
<td>
<c:choose>
<c:when test="${cfg.isAudit eq '0'}"><span class="label label-danger"><spring:message code="created"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '1'}"><span class="label label-success"><spring:message code="approved"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '2'}"><span class="label label-warning"><spring:message code="unapproved"></spring:message></span></c:when>
<c:when test="${cfg.isAudit eq '3'}"><span class="label label-warning"><spring:message code="cancel_approved"></spring:message></span></c:when>
</c:choose>
</td>
<td>${cfg.creatorName }</td>
<td><fmt:formatDate value="${cfg.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${cfg.editorName }</td>
<td><fmt:formatDate value="${cfg.editTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
<td>${cfg.auditorName }</td>
<td><fmt:formatDate value="${cfg.auditTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
</tr>
</c:forEach>
</tbody>
</table>
<div class="page">${page}</div>
</div>
</div>
</div>
</div>
</body>
</html>