S/DNAT复用策略配置修改.

This commit is contained in:
zhangwq
2018-10-23 12:57:49 +08:00
parent 5d10d711bf
commit a4ff9ae493
9 changed files with 103 additions and 29 deletions

View File

@@ -144,6 +144,8 @@ public class IpMultiplexController extends CommonController {
@RequestMapping(value = {"/saveOrUpdateSnat"})
public String saveOrUpdateSnat(String cfgName,RedirectAttributes model, IpPortCfg cfg) {
// 设置生效区域信息
groupAreaService.setAreaEffective(cfg);
this._saveOrUpdateIp(cfgName,model, cfg);
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/snatPolicyList?functionId="+cfg.getFunctionId();
}
@@ -191,6 +193,8 @@ public class IpMultiplexController extends CommonController {
@RequestMapping(value = {"/saveOrUpdateDnat"})
public String saveOrUpdateDnat(String cfgName,RedirectAttributes model, IpPortCfg cfg) {
// 设置生效区域信息
groupAreaService.setAreaCodeByGroupId(cfg);
this._saveOrUpdateIp(cfgName,model, cfg);
return "redirect:" + adminPath +"/manipulation/ipmulitiplex/dnatPolicyList?functionId="+cfg.getFunctionId();
}

View File

@@ -17,6 +17,6 @@ public interface IpMultiplexPoolCfgDao extends CrudDao<IpMultiplexPoolCfg> {
IpMultiplexPoolCfg getCfgInfo(IpMultiplexPoolCfg cfg);
String getIspByGroupId(Integer groupId);
List<IpMultiplexPoolCfg> getIspByGroupId(Integer groupId);
}

View File

@@ -328,13 +328,13 @@
</trim>
</select>
<select id="getIspByGroupId" resultType="java.lang.String">
<select id="getIspByGroupId" resultMap="IpMultiplexPoolCfgMap">
SELECT
area_effective_ids
<include refid="IpMultiplexPoolCfgColumns"/>
FROM
ip_multiplex_pool_cfg
ip_multiplex_pool_cfg r
WHERE
policy_group = #{groupId} AND is_valid != -1
r.POLICY_GROUP = #{groupId} AND r.IS_VALID != -1
</select>
</mapper>

View File

@@ -85,21 +85,49 @@ public class GroupAreaService extends BaseService{
return policyGroups;
}
// SNAT策略 组织生效区域信息
public void setAreaCodeByGroupId(IpPortCfg cfg){
Integer areaCode = groupAreaDao.getAreaCodeByGroupId(cfg.getDnsStrategyId());
cfg.setAreaEffectiveIds(areaCode+"");
}
// snat策略 设置生效区域信息
public void setAreaEffective(IpPortCfg cfg) {
String areaEffectiveIds = "";
if(cfg.getDnsStrategyId() != 0){// 已选择分组
// 1.获取该分组的省份信息
Integer areaCode = groupAreaDao.getAreaCodeByGroupId(cfg.getDnsStrategyId());
// 1.设置省份信息
this.setAreaCodeByGroupId(cfg);
areaEffectiveIds = cfg.getAreaEffectiveIds();
// 2.获取该分组下的IP复用地址池配置的ISP
IpMultiplexPoolCfgService poolCfgService = SpringContextHolder.getBean(IpMultiplexPoolCfgService.class);
String ispInfo = poolCfgService.getIspByGroupId(cfg.getDnsStrategyId());
if(ispInfo.indexOf(":") != -1){
ispInfo = ispInfo.substring(ispInfo.indexOf(":"));
List<IpMultiplexPoolCfg> cfgsList = poolCfgService.getIspByGroupId(cfg.getDnsStrategyId());
String newAreaEffectiveIds = "";
List<String> ispList = new ArrayList<>();
if(cfgsList.size() != 0){
for (IpMultiplexPoolCfg poolCfg : cfgsList) {
String areaIsp = poolCfg.getAreaEffectiveIds();
if(areaIsp.contains(":")){
areaIsp = areaIsp.substring(areaIsp.indexOf(":")+1);
}
ispList.add(areaIsp);
}
}
areaEffectiveIds = areaCode + ispInfo;
// 3.组织格式
if(ispList.size() != 0){
for (int i = 0; i < ispList.size(); i++) {
if(i < ispList.size()-1){
newAreaEffectiveIds += cfg.getAreaEffectiveIds()+":"+ispList.get(i)+",";
}else{
newAreaEffectiveIds += cfg.getAreaEffectiveIds()+":"+ispList.get(i);
}
}
areaEffectiveIds = newAreaEffectiveIds;
}
}else{
areaEffectiveIds = cfg.getAreaEffectiveIds();
}
cfg.setAreaEffectiveIds(areaEffectiveIds);
}
// IP复用地址池 设置省份信息

View File

@@ -181,7 +181,7 @@ public class IpMultiplexPoolCfgService extends BaseService{
* @param groupId
* @return
*/
public String getIspByGroupId(Integer groupId){
public List<IpMultiplexPoolCfg> getIspByGroupId(Integer groupId){
return ipMultiplexStrategyDao.getIspByGroupId(groupId);
};
}