(1)修正app ip 配置新增的时候编译ID在config_group_info为空的情况下取编译ID的逻辑

(2)app IP配置导入提交
This commit is contained in:
wangxin
2018-11-02 16:59:03 +08:00
parent ef7c3201f0
commit 857e8ecb85
8 changed files with 187 additions and 29 deletions

View File

@@ -65,8 +65,29 @@ public class BaseIpCfg extends BaseCfg<BaseIpCfg> {
private List<NtcSubscribeIdCfg> 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;
}

View File

@@ -40,7 +40,28 @@ public class BaseStringCfg<T> extends BaseCfg<T> {
@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
*/

View File

@@ -92,7 +92,28 @@ public class ComplexkeywordCfg extends BaseCfg<ComplexkeywordCfg>{
* 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;
}

View File

@@ -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,6 +3340,8 @@ public class BaseController {
asnIpCfgService.saveAsnIpBatch(asnIpCfgs);
}else {
List<Integer> compileIds=Lists.newArrayList();
List<Integer> regionIds=Lists.newArrayList();
if(!regionDict.getFunctionId().equals(405)) {//app ip compileId 从config_group_info中取
try {
compileIds = ConfigServiceUtil.getId(1,ipPortCfgs.size());
} catch (Exception e) {
@@ -3345,6 +3349,15 @@ public class BaseController {
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}else {
try {
regionIds = ConfigServiceUtil.getId(3,ipPortCfgs.size());
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}
int ind=0;
for (BaseIpCfg cfg : ipPortCfgs) {
cfg.setAction(serviceDict==null?null:serviceDict.getAction());
@@ -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");
if(compileIds.size()==ipPortCfgs.size()) {
cfg.setCompileId(compileIds.get(ind));
}
if(regionDict.getFunctionId().equals(405)&&regionIds.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
&&regionDict.getFunctionId().intValue()!=301
&&regionDict.getFunctionId().intValue()!=401) {
&&regionDict.getFunctionId().intValue()!=401
&&regionDict.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&&regionDict.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);

View File

@@ -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<BaseIpCfg> 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<AppIpCfg> 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());

View File

@@ -30,3 +30,6 @@ 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;
#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;

View File

@@ -117,7 +117,7 @@
</div>
</br>
<!-- 63 app -->
<c:if test="${cfg.functionId eq 63 }">
<c:if test="${cfg.functionId eq 63 or cfg.functionId eq 405}">
<c:set var="cfgType" value="1"></c:set>
<c:set var="spec_service_id"><spring:message code="social_app"/></c:set>
<input type="hidden" name="appError" id="appError" value="${spec_service_id } <spring:message code="required" />">

View File

@@ -56,6 +56,23 @@
onClick="javascript:window.location='${ctx}/app/ipCfgForm?functionId=${cfg.functionId}'">
<i class="fa fa-plus"></i>
<spring:message code="add"></spring:message></button>
<c:set var="serviceImport" value="false"></c:set>
<c:set var="regionImport" value="false"></c:set>
<c:forEach items="${serviceList}" var="service" >
<c:if test="${(cfg.functionId eq service.functionId) && service.isImport eq 1}">
<c:set var="serviceImport" value="true"></c:set>
</c:if>
</c:forEach>
<c:forEach items="${regionList}" var="region" >
<c:if test="${(cfg.functionId eq region.functionId) && region.isImport eq 1}">
<c:set var="regionImport" value="true"></c:set>
</c:if>
</c:forEach>
<c:if test="${serviceImport eq 'true' && regionImport eq 'true'}">
<button type="button" class="btn btn-primary import" >
<i class="fa fa-plus"></i>
<spring:message code="import"></spring:message></button>
</c:if>
</shiro:hasPermission>
</div>
@@ -436,6 +453,8 @@
</div>
</div>
</div>
<c:set var="importPath" value="/app/ipCfgList?functionId=${cfg.functionId}"/>
<!-- 模板导入start -->
<%@include file="/WEB-INF/include/excel/importModal.jsp" %>
</body>
</html>