diff --git a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java index fbf05089e..4e98f88f2 100644 --- a/src/main/java/com/nis/domain/configuration/BaseIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseIpCfg.java @@ -65,8 +65,29 @@ public class BaseIpCfg extends BaseCfg { private List ntcSubscribeIdCfgList; private NtcSubscribeIdCfg ntcSubscribeIdCfg; - private Integer asnIpGroup;//asn组号,仅用于copy属性使用 + protected Integer asnIpGroup;//asn组号,仅用于copy属性使用 + protected Integer appCode;//仅用于copy属性使用 + protected Integer behavCode;//仅用于copy属性使用 + protected Integer specServiceId;//仅用于copy属性使用 + public Integer getAppCode() { + return appCode; + } + public void setAppCode(Integer appCode) { + this.appCode = appCode; + } + public Integer getBehavCode() { + return behavCode; + } + public void setBehavCode(Integer behavCode) { + this.behavCode = behavCode; + } + public Integer getSpecServiceId() { + return specServiceId; + } + public void setSpecServiceId(Integer specServiceId) { + this.specServiceId = specServiceId; + } public Integer getAsnIpGroup() { return asnIpGroup; } diff --git a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java index 410d0d765..7d9c43222 100644 --- a/src/main/java/com/nis/domain/configuration/BaseStringCfg.java +++ b/src/main/java/com/nis/domain/configuration/BaseStringCfg.java @@ -40,7 +40,28 @@ public class BaseStringCfg extends BaseCfg { @ExcelField(title="key_word",sort=201) protected String cfgKeywords; protected String cfgKeywordsShowName; + protected Integer appCode;//仅用于copy属性使用 + protected Integer behavCode;//仅用于copy属性使用 + protected Integer specServiceId;//仅用于copy属性使用 + public Integer getAppCode() { + return appCode; + } + public void setAppCode(Integer appCode) { + this.appCode = appCode; + } + public Integer getBehavCode() { + return behavCode; + } + public void setBehavCode(Integer behavCode) { + this.behavCode = behavCode; + } + public Integer getSpecServiceId() { + return specServiceId; + } + public void setSpecServiceId(Integer specServiceId) { + this.specServiceId = specServiceId; + } /** * @param cfgKeywords the cfgKeywords to set */ diff --git a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java index 0f11606ed..5344e8541 100644 --- a/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java +++ b/src/main/java/com/nis/domain/configuration/ComplexkeywordCfg.java @@ -92,7 +92,28 @@ public class ComplexkeywordCfg extends BaseCfg{ * copy属性使用 */ protected Long dnsStrategyId; + protected Integer appCode;//仅用于copy属性使用 + protected Integer behavCode;//仅用于copy属性使用 + protected Integer specServiceId;//仅用于copy属性使用 + public Integer getAppCode() { + return appCode; + } + public void setAppCode(Integer appCode) { + this.appCode = appCode; + } + public Integer getBehavCode() { + return behavCode; + } + public void setBehavCode(Integer behavCode) { + this.behavCode = behavCode; + } + public Integer getSpecServiceId() { + return specServiceId; + } + public void setSpecServiceId(Integer specServiceId) { + this.specServiceId = specServiceId; + } public Long getDnsStrategyId() { return dnsStrategyId; } diff --git a/src/main/java/com/nis/web/controller/BaseController.java b/src/main/java/com/nis/web/controller/BaseController.java index 7b3748f1e..76bb5d351 100644 --- a/src/main/java/com/nis/web/controller/BaseController.java +++ b/src/main/java/com/nis/web/controller/BaseController.java @@ -3297,7 +3297,9 @@ public class BaseController { || serviceDict.getServiceId().intValue() == 35 || serviceDict.getServiceId().intValue() == 147 || serviceDict.getServiceId().intValue() == 36 - || serviceDict.getServiceId().intValue() == 148)) { + || serviceDict.getServiceId().intValue() == 148 + || serviceDict.getServiceId().intValue() == 1028)// app ip + ) { if (StringUtils.isNotBlank(specServiceId)) { specificServiceCfg = specificServiceCfgService .getBySpecServiceId(Integer.parseInt(specServiceId)); @@ -3338,12 +3340,23 @@ public class BaseController { asnIpCfgService.saveAsnIpBatch(asnIpCfgs); }else { List compileIds=Lists.newArrayList(); - try { - compileIds = ConfigServiceUtil.getId(1,ipPortCfgs.size()); - } catch (Exception e) { - e.printStackTrace(); - logger.info("获取编译ID出错"); - throw new MaatConvertException(":"+e.getMessage()); + List regionIds=Lists.newArrayList(); + if(!regionDict.getFunctionId().equals(405)) {//app ip compileId 从config_group_info中取 + try { + compileIds = ConfigServiceUtil.getId(1,ipPortCfgs.size()); + } catch (Exception e) { + e.printStackTrace(); + logger.info("获取编译ID出错"); + throw new MaatConvertException(":"+e.getMessage()); + } + }else { + try { + regionIds = ConfigServiceUtil.getId(3,ipPortCfgs.size()); + } catch (Exception e) { + e.printStackTrace(); + logger.info("获取编译ID出错"); + throw new MaatConvertException(":"+e.getMessage()); + } } int ind=0; for (BaseIpCfg cfg : ipPortCfgs) { @@ -3365,24 +3378,35 @@ public class BaseController { cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId); cfg.setServiceId(serviceDict==null?null:serviceDict.getServiceId()); cfg.setTableName("ip_port_cfg"); - cfg.setCompileId(compileIds.get(ind)); + if(compileIds.size()==ipPortCfgs.size()) { + cfg.setCompileId(compileIds.get(ind)); + } + if(regionDict.getFunctionId().equals(405)&®ionIds.size()==ipPortCfgs.size()) { + cfg.setUserRegion1(regionIds.get(ind).toString()); + } + if(specificServiceCfg!=null) { + cfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + cfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + if(StringUtils.isNotBlank(behaviorId)) + cfg.setBehavCode(Integer.parseInt(behaviorId)); + } if (serviceDict!=null&&(serviceDict.getServiceId().intValue() == 33 || serviceDict.getServiceId().intValue() == 145 || serviceDict.getServiceId().intValue() == 35 || serviceDict.getServiceId().intValue() == 147 || serviceDict.getServiceId().intValue() == 36 || serviceDict.getServiceId().intValue() == 148)) { - if (specificServiceCfg != null && appRegion != null) { + if (appRegion != null) { AppPolicyCfg appPolicyCfg = new AppPolicyCfg(); BeanUtils.copyProperties(cfg, appPolicyCfg); - appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); - appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + //appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + //appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); appPolicyCfg.setMatchMethod(0); appPolicyCfg.setIsHexbin(0); appPolicyCfg.setCfgType(appRegion.getConfigRegionValue()); appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode()); if (StringUtils.isNotBlank(behaviorId)) { - appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); + //appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); appPolicyCfg.setExprType(1); } else { appPolicyCfg.setExprType(0); @@ -3392,7 +3416,8 @@ public class BaseController { } else { if(regionDict.getFunctionId().intValue()!=600 &®ionDict.getFunctionId().intValue()!=301 - &®ionDict.getFunctionId().intValue()!=401) { + &®ionDict.getFunctionId().intValue()!=401 + &®ionDict.getFunctionId().intValue()!=405) { CfgIndexInfo cfgIndexInfo = new CfgIndexInfo(); BeanUtils.copyProperties(cfg, cfgIndexInfo); cfgIndexInfos.add(cfgIndexInfo); @@ -3400,12 +3425,13 @@ public class BaseController { } ind++; } - if(ipPortCfgs!=null&&ipPortCfgs.size()>0) { if (regionDict.getFunctionId().equals(301)) { ddosCfgService.saveDdosIpCfg(ipPortCfgs); }else if (regionDict.getFunctionId().equals(401)) { dnsIpCfgService.saveDnsIpCfg(ipPortCfgs); + }else if (specificServiceCfg!=null&®ionDict.getFunctionId().equals(405)) { + appCfgService.saveAppIpCfg(ipPortCfgs,specificServiceCfg); }else { ipCfgService.saveBatch(ipPortCfgs, IpCfgDao.class); } @@ -3441,23 +3467,29 @@ public class BaseController { cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId); cfg.setServiceId(serviceDict.getServiceId()); cfg.setCompileId(compileIds.get(i)); + if(specificServiceCfg!=null) { + cfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + cfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + if(StringUtils.isNotBlank(behaviorId)) + cfg.setBehavCode(Integer.parseInt(behaviorId)); + } if (serviceDict.getServiceId().intValue() == 33 || serviceDict.getServiceId().intValue() == 145 || serviceDict.getServiceId().intValue() == 35 || serviceDict.getServiceId().intValue() == 147 || serviceDict.getServiceId().intValue() == 36 || serviceDict.getServiceId().intValue() == 148) { - if (specificServiceCfg != null && appRegion != null) { + if (appRegion != null) { AppPolicyCfg appPolicyCfg = new AppPolicyCfg(); BeanUtils.copyProperties(cfg, appPolicyCfg); - appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); - appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + //appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + //appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); appPolicyCfg.setMatchMethod(0); appPolicyCfg.setIsHexbin(0); appPolicyCfg.setCfgType(appRegion.getConfigRegionValue()); appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode()); if (StringUtils.isNotBlank(behaviorId)) { - appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); + //appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); appPolicyCfg.setExprType(1); } else { appPolicyCfg.setExprType(0); @@ -3534,23 +3566,29 @@ public class BaseController { cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId); cfg.setServiceId(serviceDict.getServiceId()); cfg.setCompileId(compileIds.get(ind)); + if(specificServiceCfg!=null) { + cfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + cfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + if(StringUtils.isNotBlank(behaviorId)) + cfg.setBehavCode(Integer.parseInt(behaviorId)); + } if (serviceDict.getServiceId().intValue() == 33 || serviceDict.getServiceId().intValue() == 145 || serviceDict.getServiceId().intValue() == 35 || serviceDict.getServiceId().intValue() == 147 || serviceDict.getServiceId().intValue() == 36 || serviceDict.getServiceId().intValue() == 148) { - if (specificServiceCfg != null && appRegion != null) { + if (appRegion != null) { AppPolicyCfg appPolicyCfg = new AppPolicyCfg(); BeanUtils.copyProperties(cfg, appPolicyCfg); - appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); - appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); + //appPolicyCfg.setSpecServiceId(specificServiceCfg.getSpecServiceId()); + //appPolicyCfg.setAppCode(specificServiceCfg.getSpecServiceCode()); appPolicyCfg.setMatchMethod(0); appPolicyCfg.setIsHexbin(0); appPolicyCfg.setCfgType(appRegion.getConfigRegionValue()); appPolicyCfg.setCfgRegionCode(appRegion.getConfigRegionCode()); if (StringUtils.isNotBlank(behaviorId)) { - appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); + //appPolicyCfg.setBehavCode(Integer.parseInt(behaviorId)); appPolicyCfg.setExprType(1); } else { appPolicyCfg.setExprType(0); diff --git a/src/main/java/com/nis/web/service/configuration/AppCfgService.java b/src/main/java/com/nis/web/service/configuration/AppCfgService.java index 72d1d0aaf..5201746e2 100644 --- a/src/main/java/com/nis/web/service/configuration/AppCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AppCfgService.java @@ -24,6 +24,7 @@ import com.nis.domain.configuration.AppSslCertCfg; import com.nis.domain.configuration.AppTcpCfg; import com.nis.domain.configuration.AppTopicDomainCfg; import com.nis.domain.configuration.AreaIpCfg; +import com.nis.domain.configuration.BaseIpCfg; import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.configuration.WebsiteDomainTopic; @@ -312,6 +313,38 @@ public class AppCfgService extends BaseService { appCfgDao.insertAppPolicyCfg(appPolicyCfg); } } + /** + * 同一个app下的ip批量保存 + * @param cfgs + * @param specificServiceCfg + * @throws Exception + */ + @Transactional(readOnly = false, rollbackFor = RuntimeException.class) + public void saveAppIpCfg(List cfgs,SpecificServiceCfg specificServiceCfg) throws Exception { + ConfigGroupInfo configGroupInfo=specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId()); + if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。 + Integer groupId = ConfigServiceUtil.getId(2, 1).get(0); + Integer compileId=ConfigServiceUtil.getId(1, 1).get(0); + specificServiceCfg.setGroupId(groupId); + configGroupInfo = new ConfigGroupInfo(); + configGroupInfo.setGroupId(specificServiceCfg.getGroupId()); + configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName()); + configGroupInfo.setIsIssued(0); + configGroupInfo.setGroupType(1); + configGroupInfo.setCompileId(compileId); + specificServiceCfgDao.insertConfigGroupInfo(configGroupInfo); + //更新group_id + specificServiceCfg.setOpTime(new Date()); + specificServiceCfgDao.update(specificServiceCfg); + } + Integer compileId = configGroupInfo.getCompileId(); + for(BaseIpCfg cfg:cfgs) { + AppIpCfg entity=new AppIpCfg(); + BeanUtils.copyProperties(cfg, entity); + entity.setCompileId(compileId); + appCfgDao.insertAppIpCfg(entity); + } + } @Transactional(readOnly = false, rollbackFor = RuntimeException.class) public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception { // 设置区域运营商信息 @@ -323,19 +356,21 @@ public class AppCfgService extends BaseService { ConfigGroupInfo configGroupInfo=specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId()); if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。 Integer groupId = ConfigServiceUtil.getId(2, 1).get(0); + Integer compileId=ConfigServiceUtil.getId(1, 1).get(0); specificServiceCfg.setGroupId(groupId); configGroupInfo = new ConfigGroupInfo(); configGroupInfo.setGroupId(specificServiceCfg.getGroupId()); configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName()); configGroupInfo.setIsIssued(0); configGroupInfo.setGroupType(1); + configGroupInfo.setCompileId(compileId); specificServiceCfgDao.insertConfigGroupInfo(configGroupInfo); //更新group_id specificServiceCfg.setOpTime(new Date()); specificServiceCfgDao.update(specificServiceCfg); } - Integer compileId = 0; - if(configGroupInfo.getIsIssued().intValue()==0) {//没有下发过 + Integer compileId = configGroupInfo.getCompileId(); + /*if(configGroupInfo.getIsIssued().intValue()==0) {//没有下发过 //查询AppIpCfg对应 的未下发IP的编译ID List beforeCfg=appCfgDao.getAppIpCfgBySpecServiceId(entity.getSpecServiceId()); if(beforeCfg==null||beforeCfg.size()==0) {//第一条,获取编译id @@ -360,7 +395,7 @@ public class AppCfgService extends BaseService { compileId=configGroupInfo.getCompileId(); }else { throw new RuntimeException("Unknown configGroupInfo isIssued value"); - } + }*/ entity.setUserRegion1(String.valueOf(ConfigServiceUtil.getId(3, 1).get(0))); entity.setCompileId(compileId); entity.setCreateTime(new Date()); diff --git a/src/main/resources/sql/20181030/update_region.sql b/src/main/resources/sql/20181030/update_region.sql index 851edbef2..dba5d8df3 100644 --- a/src/main/resources/sql/20181030/update_region.sql +++ b/src/main/resources/sql/20181030/update_region.sql @@ -29,4 +29,7 @@ UPDATE function_region_dict SET is_import=1 WHERE function_id=401; UPDATE function_service_dict SET is_import=1 WHERE function_id=401; #DNS策略 UPDATE function_region_dict SET is_import=1 WHERE function_id=400; -UPDATE function_service_dict SET is_import=1 WHERE function_id=400; \ No newline at end of file +UPDATE function_service_dict SET is_import=1 WHERE function_id=400; +#app ip +UPDATE function_region_dict SET is_import=1 WHERE function_id=405; +UPDATE function_service_dict SET is_import=1 WHERE function_id=405; \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/include/excel/importModal.jsp b/src/main/webapp/WEB-INF/include/excel/importModal.jsp index 107e19abf..9e5a2b942 100644 --- a/src/main/webapp/WEB-INF/include/excel/importModal.jsp +++ b/src/main/webapp/WEB-INF/include/excel/importModal.jsp @@ -117,7 +117,7 @@
- + "> diff --git a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgList.jsp index cdf533047..bbb2bc8fa 100644 --- a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgList.jsp @@ -56,6 +56,23 @@ onClick="javascript:window.location='${ctx}/app/ipCfgForm?functionId=${cfg.functionId}'"> + + + + + + + + + + + + + + + @@ -436,6 +453,8 @@ - + + +<%@include file="/WEB-INF/include/excel/importModal.jsp" %> \ No newline at end of file