app策略,加密隧道行为,基础协议,去掉多余循环,属性名获取采用ajax

This commit is contained in:
wangxin
2018-10-25 12:51:29 +08:00
parent 632187702e
commit c98400a7f0
11 changed files with 262 additions and 73 deletions

View File

@@ -37,9 +37,7 @@ import com.nis.domain.configuration.AppPolicyCfg;
import com.nis.domain.configuration.AppSslCertCfg;
import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.AppTopicDomainCfg;
import com.nis.domain.configuration.AvFileSampleCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.domain.configuration.DdosIpCfg;
import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.WebsiteDomainTopic;
@@ -77,38 +75,58 @@ public class AppCfgController extends BaseController {
public String policyCfgList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) {
Page<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
for(AppPolicyCfg entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(app!=null) {
entity.setAppName(app.getSpecServiceName());
}
}
// for(AppPolicyCfg entity:page.getList()){
// SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
// if(app!=null) {
// entity.setAppName(app.getSpecServiceName());
// }
// }
//查找社交应用的所有有效二级特定服务
SpecificServiceCfg second=new SpecificServiceCfg();
for(SysDataDictionaryItem dict:DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if(Constants.SPECIFIC_SERVICE_CFG_TYPE_APP.equals(dict.getItemValue())) {
second.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
second.setIsValid(Constants.VALID_YES);
second.setIsLeaf(1);
List<SpecificServiceCfg> secondList=specificServiceCfgService.findAllSpecificServiceCfg(second, null);
// SpecificServiceCfg second=new SpecificServiceCfg();
// second.setCfgType(1);
// second.setIsValid(Constants.VALID_YES);
// second.setIsLeaf(1);
// List<SpecificServiceCfg> secondList=specificServiceCfgService.findAllSpecificServiceCfg(second, null);
//遍历,找到匹配项后将行为设置进去
for(AppPolicyCfg entity:page.getList()){
if(entity.getBehavCode()==null) continue;
for(SpecificServiceCfg secondCfg:secondList) {
if(secondCfg.getSpecServiceCode()==null) continue;
if(secondCfg.getSpecServiceCode().intValue()==entity.getBehavCode().intValue()) {
entity.setBehavName(secondCfg.getSpecServiceName());
break;
}
}
}
// for(AppPolicyCfg entity:page.getList()){
// if(entity.getBehavCode()==null) continue;
// for(SpecificServiceCfg secondCfg:secondList) {
// if(secondCfg.getSpecServiceCode()==null) continue;
// if(secondCfg.getSpecServiceCode().intValue()==entity.getBehavCode().intValue()) {
// entity.setBehavName(secondCfg.getSpecServiceName());
// break;
// }
// }
// }
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/app/appPolicyCfgList";
}
/**
* ajax设置Name
* @param model
* @param ids
* @return
*/
@RequestMapping(value="ajaxAppName",method=RequestMethod.POST)
@ResponseBody
public List<Map<String, String>> ajaxAppName(Model model,String ids){
List<Map<String, String>> dataList=new ArrayList<>();
List<SpecificServiceCfg> serviceList=specificServiceCfgService.getBySpecServiceCodes(ids);
Map<String, String> appMap=new HashMap<>();
Map<String, String> behavMap=new HashMap<>();
for(SpecificServiceCfg cfg:serviceList) {
if(cfg.getIsLeaf().intValue()==0) {
appMap.put(cfg.getSpecServiceCode().toString(), cfg.getSpecServiceName());
}else {
behavMap.put(cfg.getSpecServiceCode().toString(), cfg.getSpecServiceName());
}
}
dataList.add(appMap);
dataList.add(behavMap);
return dataList;
}
/**
* 查询APP策略IP子配置
* @param model

View File

@@ -52,13 +52,13 @@ public class BasicProtocolController extends BaseController {
public String policyCfgList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) {
Page<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
for(AppPolicyCfg entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(app!=null) {
entity.setAppName(app.getSpecServiceName());
}
}
// for(AppPolicyCfg entity:page.getList()){
// SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
// if(app!=null) {
// entity.setAppName(app.getSpecServiceName());
// }
//
// }
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/basicprotocol/list";

View File

@@ -15,6 +15,8 @@ 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.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.nis.domain.Page;
@@ -51,34 +53,34 @@ public class EncryptedTunnelBehaviorController extends BaseController {
public String policyCfgList(Model model,@ModelAttribute("cfg")AppPolicyCfg cfg,HttpServletRequest request,HttpServletResponse response) {
Page<AppPolicyCfg> searchPage=new Page<AppPolicyCfg>(request,response,"r");
Page<AppPolicyCfg> page = appCfgService.findAppPolicyList(searchPage, cfg);
for(AppPolicyCfg entity:page.getList()){
SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
if(app!=null) {
entity.setAppName(app.getSpecServiceName());
}
}
//查找社交应用的所有有效二级特定服务
SpecificServiceCfg second=new SpecificServiceCfg();
for(SysDataDictionaryItem dict:DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
if(Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
second.setCfgType(Integer.parseInt(dict.getItemCode()));
break;
}
}
second.setIsValid(Constants.VALID_YES);
second.setIsLeaf(1);
List<SpecificServiceCfg> secondList=specificServiceCfgService.findAllSpecificServiceCfg(second, null);
//遍历,找到匹配项后将行为设置进去
for(AppPolicyCfg entity:page.getList()){
if(entity.getBehavCode()==null) continue;
for(SpecificServiceCfg secondCfg:secondList) {
if(secondCfg.getSpecServiceCode()==null) continue;
if(secondCfg.getSpecServiceCode().intValue()==entity.getBehavCode().intValue()) {
entity.setBehavName(secondCfg.getSpecServiceName());
break;
}
}
}
// for(AppPolicyCfg entity:page.getList()){
// SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId());
// if(app!=null) {
// entity.setAppName(app.getSpecServiceName());
// }
// }
// //查找社交应用的所有有效二级特定服务
// SpecificServiceCfg second=new SpecificServiceCfg();
// for(SysDataDictionaryItem dict:DictUtils.getDictList("SPECIFIC_SERVICE_CFG_TYPE")) {
// if(Constants.SPECIFIC_SERVICE_CFG_TYPE_ENCRYPTED_TUNNEL_BEHAVIOR.equals(dict.getItemValue())) {
// second.setCfgType(Integer.parseInt(dict.getItemCode()));
// break;
// }
// }
// second.setIsValid(Constants.VALID_YES);
// second.setIsLeaf(1);
// List<SpecificServiceCfg> secondList=specificServiceCfgService.findAllSpecificServiceCfg(second, null);
// //遍历,找到匹配项后将行为设置进去
// for(AppPolicyCfg entity:page.getList()){
// if(entity.getBehavCode()==null) continue;
// for(SpecificServiceCfg secondCfg:secondList) {
// if(secondCfg.getSpecServiceCode()==null) continue;
// if(secondCfg.getSpecServiceCode().intValue()==entity.getBehavCode().intValue()) {
// entity.setBehavName(secondCfg.getSpecServiceName());
// break;
// }
// }
// }
model.addAttribute("page", page);
initPageCondition(model,cfg);
return "/cfg/encryptedtunnelbehav/list";

View File

@@ -18,6 +18,7 @@ public interface SpecificServiceCfgDao extends CrudDao<SpecificServiceCfg> {
* @return
*/
SpecificServiceCfg getBySpecServiceId(Integer specServiceId);
List<SpecificServiceCfg> getBySpecServiceCodes(@Param("ids")String ids);
/**
* 查询所有符合条件顶层分页列表
* @param specificServiceCfg

View File

@@ -41,6 +41,10 @@
select <include refid="specificServiceCfgColumns" />
from specific_service_cfg s where s.spec_service_id = #{specServiceId}
</select>
<select id="getBySpecServiceCodes" resultType="com.nis.domain.specific.SpecificServiceCfg" parameterType="java.lang.String">
select <include refid="specificServiceCfgColumns" />
from specific_service_cfg s where s.spec_service_code in(${ids})
</select>
<select id="getRepeat" resultType="com.nis.domain.specific.SpecificServiceCfg" >
select <include refid="specificServiceCfgColumns" />
from specific_service_cfg s where s.spec_service_code = #{specServiceCode} and s.cfg_type=#{cfgType} and s.is_valid=1

View File

@@ -30,6 +30,12 @@ public class SpecificServiceCfgService extends BaseService{
public SpecificServiceCfg getBySpecServiceId(Integer specServiceId) {
return specificServiceCfgDao.getBySpecServiceId(specServiceId);
}
public List<SpecificServiceCfg> getBySpecServiceCodes(String specServiceCodes) {
for(String specServiceId:specServiceCodes.split(",")) {
Integer.parseInt(specServiceId);
}
return specificServiceCfgDao.getBySpecServiceCodes(specServiceCodes);
}
/**
* 查询所有符合条件的顶层分页
* @param page

View File

@@ -105,3 +105,4 @@
<!-- 日志界面 -->
<script src="${pageContext.request.contextPath}/static/pages/scripts/pageLogs.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/static/pages/scripts/appNames.js" type="text/javascript"></script>

View File

@@ -83,8 +83,6 @@
$("#"+openId).show();
$("#"+closeId).parent().parent().next("tr").hide();
});
});
</script>
@@ -389,8 +387,8 @@
</td>
<td>${cfg.compileId }</td>
<td>${cfg.cfgDesc }</td>
<td>${cfg.appName }</td>
<td>${cfg.behavName }</td>
<td class="appCode" id="${cfg.appCode }">${cfg.appCode }</td>
<td class="behavCode" id="${cfg.behavCode }">${cfg.behavCode }</td>
<%-- <td>${cfg.ratelimit }</td> --%>
<td>
<c:forEach items="${fns:getDictList('SERVICE_ACTION') }" var="dict">

View File

@@ -392,8 +392,8 @@
</td>
<td>${cfg.compileId }</td>
<td>${cfg.cfgDesc }</td>
<td>${cfg.appName }</td>
<%-- <td>${cfg.behavName }</td> --%>
<td class="appCode" id="${cfg.appCode }">${cfg.appCode }</td>
<%--<td class="behavCode" id="${cfg.behavCode }">${cfg.behavCode }</td>--%>
<%-- <td>${cfg.ratelimit }</td> --%>
<td>
<c:forEach items="${fns:getDictList('SERVICE_ACTION') }" var="dict">

View File

@@ -389,8 +389,8 @@
</td>
<td>${cfg.compileId }</td>
<td>${cfg.cfgDesc }</td>
<td>${cfg.appName }</td>
<td>${cfg.behavName }</td>
<td class="appCode" id="${cfg.appCode }">${cfg.appCode }</td>
<td class="behavCode" id="${cfg.behavCode }">${cfg.behavCode }</td>
<%-- <td>${cfg.ratelimit }</td> --%>
<td>
<c:forEach items="${fns:getDictList('SERVICE_ACTION') }" var="dict">

View File

@@ -0,0 +1,159 @@
$(function(){
var ids=[];
$(".appCode").each(function(){
if($(this).attr("id")&&$(this).attr("id")!=''){
ids.push($(this).attr("id"));
}
ids.push($(this).attr("id"));
});
$(".behavCode").each(function(){
if($(this).attr("id")&&$(this).attr("id")!=''){
ids.push($(this).attr("id"));
}
});
var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.indexOf("/nis")+4);
$.ajax({
type:'post',
async:false,
url:pathName+'/app/ajaxAppName',
data:{"ids":ids.join(",")},
success:function(data){
if(data&&data.length==2){
var apps=data[0];
for(var ind in apps){
$("[class='appCode'][id='"+ind+"']").html(apps[ind]);
}
var behavs=data[1];
for(var ind in behavs){
$("[class='behavCode'][id='"+ind+"']").html(behavs[ind]);
}
}
}
});
});
/**
* action动作切换
*/
function switchService(){
var functionId=$("#functionId").val();
if(functionId==5 || functionId==6){//IP配置特殊处理 //URL配置特殊处理
var cfgRegionCodeS=$("input[name='serviceDictId']:checked").attr("cfgRegionCodeS");
var cfgRegionCode=cfgRegionCodeS.split(",")[0];
$("input[name='regionDictIds'][cfgregioncoder!='"+cfgRegionCode+"']").prop("checked",false);
$("input[name='regionDictIds'][cfgRegionCodeR!='"+cfgRegionCode+"']").parents(".radio-inline").addClass("hidden");
$("input[name='regionDictIds'][cfgRegionCodeR='"+cfgRegionCode+"']").prop("checked",true);
$("input[name='regionDictIds'][cfgRegionCodeR='"+cfgRegionCode+"']").parents(".radio-inline").removeClass("hidden");
if(cfgRegionCodeS.split(",").length==1){
$(".region").addClass("hidden");
}else{
$(".region").removeClass("hidden");
}
}else{
if($("input[name='regionDictIds']").length==1){
$(".region").addClass("hidden");
}else{
$(".region").removeClass("hidden");
}
}
if($("input[name='serviceDictId']").length==1){
$(".service").addClass("hidden");
}else{
$(".service").removeClass("hidden");
}
}
/**
* 模板下载
* TODO 后期修改为传入regionDictId
* */
function downLoadTemplate(path){
var obj={
"regionDictId":$("input[name='regionDictIds']:checked").val()
,"serviceDictId":$("input[name='serviceDictId']:checked").val()
,"requestId":$("select[name='requestId']").val()
};
var params = $.param(obj);
document.location.href = path+'/ntc/iplist/import/template?' + params;
}
var ajaxBehaviour=function(val){
var pathName=window.document.location.pathname.substring(0,window.document.location.pathname.indexOf("/nis")+4);
var request=$.ajax({
type:'post',
url:pathName+'/specific/specificServiceCfg/childrenList',
data:{"parent":val},
dataType:'json',
async:true,
success:function(data,textStatus){//处理返回结果
if(textStatus=="success"){
var html='<select name="behaviorId" data-live-search="true" class="selectpicker form-control">'
+'<option value=""><spring:message code="select"/></option>';
if(data.length>0){
for(i=0;i<data.length;i++){
html+='<option value="'+data[i].code+'"';
html+='>'+data[i].name+'</option>';
}
html+='</select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}else{
html+='</select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}
}
},
complete:function(XMLHttpRequest,status){//超时设置
if(status=="timeout"){
var html='<select name="behaviorId" data-live-search="true" class="selectpicker form-control">'
+'<option value=""><spring:message code="select"/></option></select>';
$("#behaviorId").html(html);
$("[name='behaviorId']").selectpicker("refresh");
$("[name='behaviorId']").selectpicker("render");
}
}
});
}
//导入配置
var importCfg=function(){
if($("#serviceId").val()==""){
alert("请选择action");
return ;
}
var appFlag=true;
if(($("#functionId").val() == 63)||($("#functionId").val() == 408)||($("#functionId").val() == 407)){
var appIdValue=$("#appIdName").val();
if(appIdValue == null || appIdValue ==''){
appFlag=false;
}
}
var fileName = $(".fileupload-preview", $("#importForm1")).text();
var $error = $('.alert-error', $("#importForm1"));
if(!appFlag){
$("span",$error).html($("#appError").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}
if(fileName==""){
$("span",$error).html($("#importTip").val());
$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($("#importTip").val());
$error.removeClass("hide");
$error.addClass("show");
return false;
}
$("#import_modal").modal('hide');//导入文件隐藏
$("#importForm1").submit();
}