snat策略增加用户类型选项.

This commit is contained in:
zhangwq
2018-12-06 15:00:05 +08:00
parent 23b402fc50
commit 04e35d5b3c
10 changed files with 257 additions and 39 deletions

View File

@@ -119,7 +119,17 @@ public class IpAddrPoolCfgService extends BaseService{
// 2.更新地址池IP信息
ipAddrPoolCfgDao.deleteReuseIpCfgs(addrPoolId);
for (BaseIpCfg IpCfg : entity.getIpCfgs()) {
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId"});
try {
List<Integer> compileIds = ConfigServiceUtil.getId(1,1);
if(compileIds != null && compileIds.size() > 0 ){
IpCfg.setCompileId(compileIds.get(0));
}
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
BeanUtils.copyProperties(entity, IpCfg, new String[]{"cfgId","compileId"});
IpCfg.setUserRegion1(addrPoolId+"");
ipAddrPoolCfgDao.saveReuseIpCfgs(IpCfg);
}
@@ -169,7 +179,7 @@ public class IpAddrPoolCfgService extends BaseService{
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
IpAddrPool ip = new IpAddrPool();
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
if (cfgs.size() > 1) {
throw new RuntimeException("CallBack IP did not support IP range!");
@@ -216,7 +226,7 @@ public class IpAddrPoolCfgService extends BaseService{
List<IpAddrPool> resStrategyList=new ArrayList<IpAddrPool>();
for(BaseIpCfg ipcfg : cfg.getIpCfgs()) {
IpAddrPool ip = new IpAddrPool();
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId"});
BeanUtils.copyProperties(cfg, ipcfg, new String[]{"cfgId","compileId"});
List<IpCfg> cfgs = BaseService.ipConvert(new IpCfg(), ipcfg);
if (cfgs.size() > 1) {
throw new RuntimeException("CallBack IP did not support IP range!");

View File

@@ -56,10 +56,12 @@ public class IpMultiplexService extends BaseService{
entity.setIsAudit(0);
setAreaEffectiveIds(entity);
// 获取用户/账号类型
if(StringUtils.isNotBlank(entity.getUserName())){
String userType = ipMultiplexDao.getUserType(entity.getUserName());
entity.setUserType(userType);
if("VPN".equals(entity.getUserType())){
entity.setIpType(null);
entity.setIpPattern(null);
entity.setSrcIpAddress("");
}else{
entity.setUserName("");
}
// 更新策略信息
@@ -120,8 +122,7 @@ public class IpMultiplexService extends BaseService{
cfg.setIsAudit(isAudit);
cfg.setAuditorId(UserUtils.getUser().getId());
cfg.setAuditTime(auditTime);
cfg.setDoLog(null);
ipMultiplexDao.updatePolicyCfg(cfg);
ipMultiplexDao.updatePolicyAuditStatus(cfg);
SysDictInfoService sysDictInfoService = SpringContextHolder.getBean(SysDictInfoService.class);
// 获取配置信息
@@ -133,7 +134,7 @@ public class IpMultiplexService extends BaseService{
params.put("configId", cfg.getCompileId());
params.put("addrPoolId", cfg.getAddrPoolId());
params.put("userType", cfg.getUserType());
params.put("userId", keywordsEscape(cfg.getUserName()));
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
params.put("doLog", cfg.getDoLog());
params.put("action", cfg.getAction());
params.put("service", cfg.getServiceId());
@@ -164,7 +165,7 @@ public class IpMultiplexService extends BaseService{
params.put("configId", cfg.getCompileId());
params.put("addrPoolId", cfg.getAddrPoolId());
params.put("userType", cfg.getUserType());
params.put("userId", keywordsEscape(cfg.getUserName()));
params.put("userId", keywordsEscape(StringUtils.isNotBlank(cfg.getUserName())?cfg.getUserName():cfg.getSrcIpAddress()));
params.put("doLog", cfg.getDoLog());
params.put("action", cfg.getAction());
params.put("service", cfg.getServiceId());