From 98016b5232ea50c7e35b83effe4ac6af3b0ae8a7 Mon Sep 17 00:00:00 2001 From: zhangwei Date: Mon, 25 Jun 2018 10:44:38 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9app=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=9A=84=E5=8C=BA=E5=9F=9FIP=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nis/domain/configuration/AppIpCfg.java | 24 +- .../configuration/AppCfgController.java | 2 + .../nis/web/dao/configuration/AppCfgDao.xml | 10 +- .../service/configuration/AppCfgService.java | 212 ++++++++++++++---- .../WEB-INF/views/cfg/app/appIpCfgForm.jsp | 1 - 5 files changed, 190 insertions(+), 59 deletions(-) diff --git a/src/main/java/com/nis/domain/configuration/AppIpCfg.java b/src/main/java/com/nis/domain/configuration/AppIpCfg.java index 968e60686..f86e8b651 100644 --- a/src/main/java/com/nis/domain/configuration/AppIpCfg.java +++ b/src/main/java/com/nis/domain/configuration/AppIpCfg.java @@ -49,9 +49,9 @@ public class AppIpCfg extends BaseCfg { /** * 协议ID */ - @Expose - @SerializedName("protocolId") - protected Integer protocolId ; +// @Expose +// @SerializedName("protocolId") +// protected Integer protocolId ; /** * ipType @@ -101,15 +101,15 @@ public class AppIpCfg extends BaseCfg { * @return protocolId */ - public Integer getProtocolId() { - return protocolId; - } - /** - * @param protocolId the protocolId to set - */ - public void setProtocolId(Integer protocolId) { - this.protocolId = protocolId; - } +// public Integer getProtocolId() { +// return protocolId; +// } +// /** +// * @param protocolId the protocolId to set +// */ +// public void setProtocolId(Integer protocolId) { +// this.protocolId = protocolId; +// } /** * ipPattern diff --git a/src/main/java/com/nis/web/controller/configuration/AppCfgController.java b/src/main/java/com/nis/web/controller/configuration/AppCfgController.java index 067a6a957..0ecb84ea9 100644 --- a/src/main/java/com/nis/web/controller/configuration/AppCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/AppCfgController.java @@ -21,6 +21,7 @@ import com.nis.domain.configuration.AppIpCfg; import com.nis.domain.configuration.AppPolicyCfg; import com.nis.domain.specific.SpecificServiceCfg; import com.nis.exceptions.MaatConvertException; +import com.nis.util.Constants; import com.nis.web.controller.BaseController; import com.nis.web.security.UserUtils; @@ -258,6 +259,7 @@ public class AppCfgController extends BaseController { for(AppHttpCfg entity:page.getList()){ SpecificServiceCfg app = specificServiceCfgService.getBySpecServiceId(entity.getSpecServiceId()); entity.setAppName(app.getSpecServiceName()); + entity.setCfgKeywords(entity.getCfgKeywords().replace(Constants.KEYWORD_EXPR, "&")); } model.addAttribute("page", page); initPageCondition(model,cfg); diff --git a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml index 89999080f..804c577f8 100644 --- a/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml +++ b/src/main/java/com/nis/web/dao/configuration/AppCfgDao.xml @@ -1066,7 +1066,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, @@ -1147,7 +1147,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, @@ -1254,7 +1254,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, @@ -1349,7 +1349,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, @@ -1441,7 +1441,7 @@ lable = #{lable,jdbcType=VARCHAR}, - + area_effective_ids = #{areaEffectiveIds,jdbcType=VARCHAR}, 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 ee64074bb..4d117b6b5 100644 --- a/src/main/java/com/nis/web/service/configuration/AppCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AppCfgService.java @@ -98,9 +98,10 @@ public class AppCfgService extends BaseService { return appCfgDao.getAppByteCfg(cfgId); } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{ + public void saveOrUpdateAppPolicyCfg(AppPolicyCfg entity) throws Exception{ //设置区域运营商信息 setAreaEffectiveIds(entity); + if(entity.getCfgId()==null){ Integer compileId = 0; try { @@ -113,7 +114,15 @@ public class AppCfgService extends BaseService { entity.setCreatorId(entity.getCurrentUser().getId()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.insertAppPolicyCfg(entity); + appCfgDao.insertAppPolicyCfg(entity); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } }catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -124,13 +133,30 @@ public class AppCfgService extends BaseService { entity.setEditTime(new Date()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.updateAppPolicyCfg(entity); + appCfgDao.updateAppPolicyCfg(entity); + + //删除旧的区域IP,新增新的区域IP + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{ + public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception{ //设置区域运营商信息 setAreaEffectiveIds(entity); + if(entity.getCfgId()==null){ Integer compileId = 0; try { @@ -143,7 +169,19 @@ public class AppCfgService extends BaseService { entity.setCreatorId(entity.getCurrentUser().getId()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.insertAppIpCfg(entity); + appCfgDao.insertAppIpCfg(entity); + + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg, + new String[]{"cfgRegionCode","cfgType","ipType","isAreaEffective", + "areaEffectiveIds","protocol","portPattern","srcPort","destPort","direction", + "destIpAddress","srcIpAddress","ipPattern"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } }catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -154,11 +192,28 @@ public class AppCfgService extends BaseService { entity.setEditTime(new Date()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.updateAppIpCfg(entity); + appCfgDao.updateAppIpCfg(entity); + //删除旧的区域IP,新增新的区域IP + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType","ipType","isAreaEffective", + "areaEffectiveIds","protocol","portPattern","srcPort","destPort","direction", + "destIpAddress","srcIpAddress","ipPattern"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{ + public void saveOrUpdateAppHttpCfg(AppHttpCfg entity) throws Exception{ //设置区域运营商信息 setAreaEffectiveIds(entity); if(entity.getCfgId()==null){ @@ -173,7 +228,17 @@ public class AppCfgService extends BaseService { entity.setCreatorId(entity.getCurrentUser().getId()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.insertAppHttpCfg(entity); + appCfgDao.insertAppHttpCfg(entity); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); + + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } + }catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -184,11 +249,83 @@ public class AppCfgService extends BaseService { entity.setEditTime(new Date()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.updateAppHttpCfg(entity); + appCfgDao.updateAppHttpCfg(entity); + + //删除旧的区域IP,新增新的区域IP + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } + + } + + } + @Transactional(readOnly=false,rollbackFor=RuntimeException.class) + public void saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception{ + //设置区域运营商信息 + setAreaEffectiveIds(entity); + + if(entity.getCfgId()==null){ + Integer compileId = 0; + try { + List idList = ConfigServiceUtil.getId(1, 1); + if(idList!=null && idList.size()>0){ + compileId = idList.get(0); + } + entity.setCompileId(compileId); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + entity.setIsValid(0); + entity.setIsAudit(0); + appCfgDao.insertAppDomainCfg(entity); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } + }catch (Exception e) { + e.printStackTrace(); + logger.info("获取编译ID出错"); + throw new MaatConvertException(":"+e.getMessage()); + } + }else{ + entity.setEditorId(entity.getCurrentUser().getId()); + entity.setEditTime(new Date()); + entity.setIsValid(0); + entity.setIsAudit(0); + appCfgDao.updateAppDomainCfg(entity); + //删除旧的区域IP,新增新的区域IP + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } } @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int saveOrUpdateAppDomainCfg(AppDomainCfg entity) throws Exception{ + public void saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception{ //设置区域运营商信息 setAreaEffectiveIds(entity); if(entity.getCfgId()==null){ @@ -203,37 +340,15 @@ public class AppCfgService extends BaseService { entity.setCreatorId(entity.getCurrentUser().getId()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.insertAppDomainCfg(entity); - }catch (Exception e) { - e.printStackTrace(); - logger.info("获取编译ID出错"); - throw new MaatConvertException(":"+e.getMessage()); - } - }else{ - entity.setEditorId(entity.getCurrentUser().getId()); - entity.setEditTime(new Date()); - entity.setIsValid(0); - entity.setIsAudit(0); - return appCfgDao.updateAppDomainCfg(entity); - } - } - @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int saveOrUpdateAppByteCfg(AppByteCfg entity) throws Exception{ - //设置区域运营商信息 - setAreaEffectiveIds(entity); - if(entity.getCfgId()==null){ - Integer compileId = 0; - try { - List idList = ConfigServiceUtil.getId(1, 1); - if(idList!=null && idList.size()>0){ - compileId = idList.get(0); + appCfgDao.insertAppByteCfg(entity); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } } - entity.setCompileId(compileId); - entity.setCreateTime(new Date()); - entity.setCreatorId(entity.getCurrentUser().getId()); - entity.setIsValid(0); - entity.setIsAudit(0); - return appCfgDao.insertAppByteCfg(entity); }catch (Exception e) { e.printStackTrace(); logger.info("获取编译ID出错"); @@ -244,7 +359,22 @@ public class AppCfgService extends BaseService { entity.setEditTime(new Date()); entity.setIsValid(0); entity.setIsAudit(0); - return appCfgDao.updateAppByteCfg(entity); + appCfgDao.updateAppByteCfg(entity); + //删除旧的区域IP,新增新的区域IP + AreaIpCfg area = new AreaIpCfg(); + area.setCompileId(entity.getCompileId()); + area.setFunctionId(entity.getFunctionId()); + areaIpCfgDao.deleteAreaIpCfg(area); + entity.setCreateTime(new Date()); + entity.setCreatorId(entity.getCurrentUser().getId()); + //保存区域IP信息 + if(entity.getAreaCfg()!=null){ + for(AreaIpCfg cfg:entity.getAreaCfg()){ + cfg.initDefaultValue(); + BeanUtils.copyProperties(entity, cfg,new String[]{"cfgDesc","cfgRegionCode","cfgType"}); + areaIpCfgDao.saveAreaIpCfg(cfg); + } + } } } public void auditAppPolicyCfg(AppPolicyCfg entity,Integer isAudit){ diff --git a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp index 16d0f656f..4bdec6810 100644 --- a/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/app/appIpCfgForm.jsp @@ -47,7 +47,6 @@ $(function(){ -