From 1828b726bac74f6d1158e20ccc801759afde3f85 Mon Sep 17 00:00:00 2001 From: chenjinsong Date: Sun, 8 Apr 2018 17:07:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=AE=A1=E6=8E=A7=E7=9A=84ip=E7=B1=BB?= =?UTF-8?q?=E6=A0=A1=E9=AA=8C=202.=E5=B0=86ip=E5=9C=B0=E5=9D=80=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E6=A0=A1=E9=AA=8C=E6=8F=90=E7=A4=BA=E8=AF=AD=E6=8F=90?= =?UTF-8?q?=E5=87=BA=E8=87=B3=E5=9B=BD=E9=99=85=E5=8C=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemServiceController.java | 1 - .../WEB-INF/include/form/multiple/ipInfo.jsp | 44 +++++++++---------- .../webapp/WEB-INF/views/cfg/dnsIpCfgForm.jsp | 3 +- .../WEB-INF/views/cfg/multipleCfgForm.jsp | 30 +++++++++++++ .../1.11.0/localization/messages_en.js | 3 +- .../1.11.0/localization/messages_ru.js | 3 +- .../1.11.0/localization/messages_zh.js | 3 +- 7 files changed, 59 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java b/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java index 87a41f48e..714d9d147 100644 --- a/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java +++ b/src/main/java/com/nis/web/controller/systemService/SystemServiceController.java @@ -125,7 +125,6 @@ public class SystemServiceController extends BaseController { public String delete(Model model, SystemServiceInfo systemServiceInfo, HttpServletRequest request, HttpServletResponse response) { //增加后台校验,当数据是初始数据时不允许删除 if(systemServiceInfo.getIsInitianlize().intValue() == 1) { - addMessage(model, "delete_failed"); return "/error/403"; } diff --git a/src/main/webapp/WEB-INF/include/form/multiple/ipInfo.jsp b/src/main/webapp/WEB-INF/include/form/multiple/ipInfo.jsp index 843cf021a..f40a2da4d 100644 --- a/src/main/webapp/WEB-INF/include/form/multiple/ipInfo.jsp +++ b/src/main/webapp/WEB-INF/include/form/multiple/ipInfo.jsp @@ -36,14 +36,14 @@
- - > @@ -69,10 +69,10 @@
- + - +
@@ -92,10 +92,10 @@
- + - +
@@ -118,10 +118,10 @@
- + - +
@@ -141,10 +141,10 @@
- + - +
@@ -166,10 +166,10 @@
- + - +
@@ -189,10 +189,10 @@
- + - +
@@ -214,10 +214,10 @@
- + - +
@@ -237,10 +237,10 @@
- + - +
@@ -262,14 +262,14 @@
- > - > @@ -294,7 +294,7 @@
- > @@ -302,7 +302,7 @@ - > diff --git a/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgForm.jsp index dd226e1fe..e3a9c4643 100644 --- a/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/dnsIpCfgForm.jsp @@ -182,8 +182,7 @@ $(function(){ checkIp = /\S+/; } return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256)); - }, - "请输入正确的IP!" + } ); }); diff --git a/src/main/webapp/WEB-INF/views/cfg/multipleCfgForm.jsp b/src/main/webapp/WEB-INF/views/cfg/multipleCfgForm.jsp index 6176e91cf..525838eba 100644 --- a/src/main/webapp/WEB-INF/views/cfg/multipleCfgForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/multipleCfgForm.jsp @@ -40,6 +40,19 @@ $(function(){ errorContainer: "#messageBox" }); + $.validator.addMethod( + "checkIp", + function(value, element, params) { + var checkIp; + if ($("[name$=ipType]").val() == 4) { + checkIp = /((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))/; + } else { + checkIp = /\S+/; + } + return this.optional(element) || (checkIp.test(value) && (RegExp.$1 < 256 && RegExp.$2 < 256 && RegExp.$3 < 256 && RegExp.$4 < 256)); + } + ); + $("#ipSelect").change(function(){ if($(this).prop("checked")){ $("[name^='ipCfg']").removeProp("disabled"); @@ -56,6 +69,23 @@ $(function(){ $("[name^='ipCfg']").attr("disabled",true); } }); + + function myValidate(flag) { + if (flag) { + myValidate(false); + $("[name=ipCfg\\[http_ip_cfg\\]\\.srcIp]").each(function(){ + $(this).rules("add", { + checkIp: true, + messages: { + required:'' + } + }); + }); + } else { + + } + } + $(".district").on("change",function(){ var text=$(this).find("option:selected").text().toLowerCase(); var other=$(this).parent("div").siblings(".otherValue"); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js index 30505d7b8..47a6425f5 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js @@ -20,6 +20,7 @@ rangelength: $.validator.format("Please enter a value between {0} and {1} characters long."), range: $.validator.format("Please enter a value between {0} and {1}."), max: $.validator.format("Please enter a value less than or equal to {0}."), - min: $.validator.format("Please enter a value greater than or equal to {0}.") + min: $.validator.format("Please enter a value greater than or equal to {0}."), + checkIp: $.validator.format("Please enter a correct IP address.") }); }(jQuery)); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js index 46dc78168..307dec287 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js @@ -20,6 +20,7 @@ rangelength: $.validator.format("Пожалуйста, введите значение длиной от {0} до {1} символов."), range: $.validator.format("Пожалуйста, введите число от {0} до {1}."), max: $.validator.format("Пожалуйста, введите число, меньшее или равное {0}."), - min: $.validator.format("Пожалуйста, введите число, большее или равное {0}.") + min: $.validator.format("Пожалуйста, введите число, большее или равное {0}."), + min: $.validator.format(" Пожалуйста, введите  правильный  IP - адрес.") }); }(jQuery)); \ No newline at end of file diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js index aee0edc3f..533e091bb 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js @@ -20,6 +20,7 @@ rangelength: $.validator.format("请输入一个长度介于 {0} 和 {1} 之间的字符串"), range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"), max: $.validator.format("请输入一个最大为 {0} 的值"), - min: $.validator.format("请输入一个最小为 {0} 的值") + min: $.validator.format("请输入一个最小为 {0} 的值"), + checkIp: $.validator.format("请输入一个合法的IP") }); }(jQuery)); From 75cab20b250df69aae45a26b80676af5d75957dc Mon Sep 17 00:00:00 2001 From: zhangwei Date: Sun, 8 Apr 2018 17:19:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A4=BE=E4=BA=A4=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=8A=9F=E8=83=BD=E6=8C=89=E9=92=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../configuration/AppCfgController.java | 71 ++- .../service/configuration/AppCfgService.java | 441 +++++++++--------- src/main/webapp/WEB-INF/tags/sys/delRow.tag | 7 +- .../webapp/WEB-INF/views/cfg/appCfgList.jsp | 79 +++- 4 files changed, 338 insertions(+), 260 deletions(-) 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 25f798537..33e867cd8 100644 --- a/src/main/java/com/nis/web/controller/configuration/AppCfgController.java +++ b/src/main/java/com/nis/web/controller/configuration/AppCfgController.java @@ -11,6 +11,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.servlet.mvc.support.RedirectAttributes; import com.nis.domain.Page; import com.nis.domain.ServiceConfigInfo; @@ -186,7 +187,7 @@ public class AppCfgController extends BaseController { logger.info("saveOrUpdateAppCfg loaded"); if(cfg==null){ logger.error("无法保存空的配置!"); - addMessage(model,"保存失败!"); + addMessage(model,"save_failed"); }else{ SpecificServiceCfg protocol = specificServiceCfgService.getBySpecServiceId(cfg.getAppId().intValue()); if(protocol!=null){ @@ -202,7 +203,7 @@ public class AppCfgController extends BaseController { } catch (Exception e) { e.printStackTrace(); logger.error("配置保存失败!"+e.getMessage()); - addMessage(model,"保存失败!"); + addMessage(model,"save_failed"); } }else{ cfg.setEditorId(cfg.getCurrentUser().getId()); @@ -212,15 +213,15 @@ public class AppCfgController extends BaseController { } catch (Exception e) { e.printStackTrace(); logger.error("配置保存失败!"+e.getMessage()); - addMessage(model,"保存失败!"); + addMessage(model,"save_failed"); } } model.addAttribute("serviceId",serviceId); model.addAttribute("action",cfg.getAction()); - addMessage(model,"保存成功,正在为您跳转页面..."); + addMessage(model,"save_success"); }else{ logger.error("所选协议信息无效!"); - addMessage(model,"保存失败!"); + addMessage(model,"save_failed"); } } @@ -237,36 +238,27 @@ public class AppCfgController extends BaseController { * @since 1.0.0 */ @RequestMapping(value = {"auditCfg"}) - public String auditAppCfg(String cfgName,AppIdCfg cfg,Model model) { + public String auditAppCfg(String cfgName,String ids,Integer auditState,Integer serviceId,Integer action, + Model model,RedirectAttributes redirectAttributes) { model.addAttribute("cfgName", cfgName); model.addAttribute("audit", Constants.AUDIT_PAGE); - if(cfg==null){ - logger.error("无法审核空的配置!"); - }else{ - int audit=appCfgService.getIsAudit(cfg.getCfgId()); - if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){ - logger.error("审核通过的配置只能取消审核通过!"); + model.addAttribute("serviceId", serviceId); + model.addAttribute("action",action); + model.addAttribute("cfgType","app"); + try { + String[] cfgIds = ids.split(","); + int result=appCfgService.auditAppCfg(cfgIds,auditState); + if(result==1){ + addMessage(model,"audit_success"); }else{ - cfg.setAuditorId(cfg.getCurrentUser().getId()); - cfg.setAuditTime(new Date()); - - if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 - cfg.setIsValid(Constants.VALID_NO); - }else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过,设置有效标志为1 - cfg.setIsValid(Constants.VALID_YES); - } - try { - int result=appCfgService.auditAppCfg(cfg); - } catch (Exception e) { - e.printStackTrace(); - logger.error("配置下发maat失败,"+e.getMessage()); - addMessage(model,"配置审核下发失败!"); - } - model.addAttribute("serviceId", cfg.getServiceId()); - model.addAttribute("action", cfg.getAction()); + addMessage(model,"audit_failed"); } + } catch (Exception e) { + e.printStackTrace(); + logger.error("配置下发maat失败,"+e.getMessage()); + addMessage(model,"audit_failed"); } - return "redirect:" + adminPath + "/cfg/app/list"; + return "/cfg/resultPage"; } /** * @@ -278,25 +270,18 @@ public class AppCfgController extends BaseController { * @since 1.0.0 */ @RequestMapping(value = {"deleteCfg"}) - public String deleteAppCfg(int action,long cfgId,Integer compileId,String cfgName,Integer serviceId,Model model) { + public String deleteAppCfg(int action,String ids,String cfgName,Integer serviceId,Model model,RedirectAttributes redirectAttributes) { model.addAttribute("serviceId", serviceId); model.addAttribute("cfgName", cfgName); model.addAttribute("action", action); model.addAttribute("cfgType","app"); model.addAttribute("audit", Constants.CFG_PAGE); - int audit=appCfgService.getIsAudit(cfgId); - //未审核时可删除 - if(audit!=Constants.AUDIT_YES){ - AppIdCfg cfg=new AppIdCfg(); - cfg.setCfgId(cfgId); - cfg.setEditorId(cfg.getCurrentUser().getId()); - cfg.setEditTime(new Date()); - cfg.setIsValid(Constants.VALID_DEL); - cfg.setCompileId(compileId); - int result=appCfgService.deleteAppCfg(cfg); - addMessage(model,"删除成功,正在为您跳转页面..."); + String[] cfgIds = ids.split(","); + int result=appCfgService.deleteAppCfg(cfgIds); + if(result==1){ + addMessage(redirectAttributes,"delete_success"); }else{ - logger.error("通过审核的配置不能删除!"); + addMessage(redirectAttributes,"delete_failed"); } return "/cfg/resultPage"; } 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 95581b21f..fcdb0eed3 100644 --- a/src/main/java/com/nis/web/service/configuration/AppCfgService.java +++ b/src/main/java/com/nis/web/service/configuration/AppCfgService.java @@ -267,230 +267,248 @@ public class AppCfgService extends CrudService { * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int auditAppCfg(AppIdCfg entity) throws Exception{ - boolean sendFlag = false; - AppIdCfg appCfg = appCfgDao.getById(entity.getCfgId()); - List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId()); - List strList = new ArrayList(); - List complexList = new ArrayList(); - List hostList =new ArrayList(); - List areaList = new ArrayList(); - ConfigGroupInfo group = null; - - - Gson gson=new GsonBuilder().disableHtmlEscaping() - .excludeFieldsWithoutExposeAnnotation() - .create(); - - //配置审核状态即将改变后的状态 - if(Constants.AUDIT_NOT_YES==entity.getIsAudit().intValue()|| - Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat + public int auditAppCfg(String[] cfgIds,Integer auditState) throws Exception{ + for(String id:cfgIds){ + boolean sendFlag = false; + AppIdCfg appCfg = appCfgDao.getById(Long.parseLong(id)); - if(Constants.AUDIT_YES==entity.getIsAudit().intValue()){//审核通过 - if(StringUtil.isEmpty(featuresTableList)){ - SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue()); - group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId()); - //featuresTableList为空的时候,该service只有特定服务IP一个配置表 - ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); - if(group==null){ - throw new RuntimeException("配置审核失败,未获取社交应用服务器IP所属分组信息"); - }else{ - if(group.getIsIssued()==0){ - //如果分组信息尚未下发,则下发IP - group.setGroupId(protocol.getGroupId()); - group.setIsIssued(1); - SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg(); - hostCfg.setSpecServiceId(protocol.getSpecServiceId()); - hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg); - - for(SpecificServiceHostCfg host:hostList){ - SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId()); - host.setProtocolId(0); - host.setGroupId(specServiceCfg.getGroupId()); - if(StringUtil.isEmpty(serviceCfg)){ - host.setMaatTable("DF_PROTOCOL_APP"); - }else{ - host.setMaatTable(serviceCfg.getMaatTable()); - } - } + //给需要修改的配置字段赋值 + appCfg.setIsAudit(auditState); + appCfg.setAuditorId(appCfg.getCurrentUser().getId()); + appCfg.setAuditTime(new Date()); + if(auditState==Constants.AUDIT_NOT_YES){//取消审核通过,设置有效标志为0 + appCfg.setIsValid(Constants.VALID_NO); + }else if(auditState==Constants.AUDIT_YES){//审核通过,设置有效标志为1 + appCfg.setIsValid(Constants.VALID_YES); + } + + if(appCfg.getCompileId()==0){ + logger.error("转换出错,未获取到正确的compileId"); + break; + } + + List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(appCfg.getCompileId()); + List strList = new ArrayList(); + List complexList = new ArrayList(); + List hostList =new ArrayList(); + List areaList = new ArrayList(); + ConfigGroupInfo group = null; + + + Gson gson=new GsonBuilder().disableHtmlEscaping() + .excludeFieldsWithoutExposeAnnotation() + .create(); + + //配置审核状态即将改变后的状态 + if(Constants.AUDIT_NOT_YES==auditState|| + Constants.AUDIT_YES==auditState){//审核通过,取消审核通过需要发到maat + + if(Constants.AUDIT_YES==auditState){//审核通过 + if(StringUtil.isEmpty(featuresTableList)){ + SpecificServiceCfg protocol = specificServiceCfgDao.getBySpecServiceId(appCfg.getAppId().intValue()); + group = specificServiceCfgDao.getConfigGroupInfoByGroupId(protocol.getGroupId()); + //featuresTableList为空的时候,该service只有特定服务IP一个配置表 + ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); + if(group==null){ + throw new RuntimeException("配置审核失败,未获取社交应用服务器IP所属分组信息"); }else{ - SpecificServiceHostCfg host = new SpecificServiceHostCfg(); - host.setGroupId(protocol.getGroupId()); - hostList.add(host); + if(group.getIsIssued()==0){ + //如果分组信息尚未下发,则下发IP + group.setGroupId(protocol.getGroupId()); + group.setIsIssued(1); + SpecificServiceHostCfg hostCfg = new SpecificServiceHostCfg(); + hostCfg.setSpecServiceId(protocol.getSpecServiceId()); + hostList = specificServiceHostCfgDao.findSpecHostList(hostCfg); + + for(SpecificServiceHostCfg host:hostList){ + SpecificServiceCfg specServiceCfg = specificServiceCfgDao.getBySpecServiceId(host.getSpecServiceId()); + host.setProtocolId(0); + host.setGroupId(specServiceCfg.getGroupId()); + if(StringUtil.isEmpty(serviceCfg)){ + host.setMaatTable("DF_PROTOCOL_APP"); + }else{ + host.setMaatTable(serviceCfg.getMaatTable()); + } + } + }else{ + SpecificServiceHostCfg host = new SpecificServiceHostCfg(); + host.setGroupId(protocol.getGroupId()); + hostList.add(host); + } } - } - - - //生效区域列表信息 - if(appCfg.getIsAreaEffective()==1){ - if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){ - BaseIpCfg ipCfg = new BaseIpCfg(); - ipCfg.setCompileId(appCfg.getCompileId()); - ipCfg.setTableName("area_ip_cfg"); - areaList = ipCfgDao.findList(ipCfg); + + + //生效区域列表信息 + if(appCfg.getIsAreaEffective()==1){ + if(StringUtil.isEmpty(appCfg.getAreaEffectiveIds())){ + BaseIpCfg ipCfg = new BaseIpCfg(); + ipCfg.setCompileId(appCfg.getCompileId()); + ipCfg.setTableName("area_ip_cfg"); + areaList = ipCfgDao.findList(ipCfg); + } } - } - }else{ - for(AppFeaturesIndex featuresCfg:featuresTableList){ - if(featuresCfg.getFeaturesTableType()==2){ - List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); - for(AppStringCfg cfg:list){ - List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); - if(!StringUtil.isEmpty(cList)){ - for(ServiceConfigInfo c:cList){ - if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ - cfg.setMaatTable(c.getMaatTable()); + }else{ + for(AppFeaturesIndex featuresCfg:featuresTableList){ + if(featuresCfg.getFeaturesTableType()==2){ + List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppStringCfg cfg:list){ + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + cfg.setMaatTable(c.getMaatTable()); + } + } + + } + cfg.setCompileId(featuresCfg.getFeaturesCompileId()); + strList.add(cfg); + } + } + if(featuresCfg.getFeaturesTableType()==4){ + List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppComplexKeywordCfg cfg:list){ + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + cfg.setMaatTable(c.getMaatTable()); + } } } + cfg.setCompileId(featuresCfg.getFeaturesCompileId()); + complexList.add(cfg); } - cfg.setCompileId(featuresCfg.getFeaturesCompileId()); - strList.add(cfg); } } - if(featuresCfg.getFeaturesTableType()==4){ - List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); - for(AppComplexKeywordCfg cfg:list){ - List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); - if(!StringUtil.isEmpty(cList)){ - for(ServiceConfigInfo c:cList){ - if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ - cfg.setMaatTable(c.getMaatTable()); + } + AppMaatCfg maatCfg = new AppMaatCfg(); + if(StringUtil.isEmpty(featuresTableList)){ + maatCfg.setIpCfg(hostList); + maatCfg.setAreaCfg(areaList); + if(appCfg.getCompileId()==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + }else{ + maatCfg.setCompileId(appCfg.getCompileId()); + } + }else{//特征配置 + maatCfg.setStrCfg(strList); + maatCfg.setComplexStrCfg(complexList); + } + + if(appCfg.getAction()==null){ + throw new RuntimeException("转换出错,未获取到正确的action"); + }else{ + maatCfg.setAction(appCfg.getAction()); + } + if(appCfg.getIsAreaEffective()==null){ + throw new RuntimeException("转换出错,未获取到正确的isAreaEffective"); + }else{ + maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective()); + } + if(appCfg.getIsValid()==null){ + throw new RuntimeException("转换出错,未获取到正确的isValid"); + }else{ + maatCfg.setIsValid(appCfg.getIsValid()); + } + if(appCfg.getRequestId()==null){ + throw new RuntimeException("转换出错,未获取到正确的requestId"); + }else{ + maatCfg.setRequestId(appCfg.getRequestId()); + } + if(appCfg.getServiceId()==null){ + throw new RuntimeException("转换出错,未获取到正确的serviceId"); + }else{ + maatCfg.setServiceId(appCfg.getServiceId()); + } + maatCfg.setSpecificServiceId(appCfg.getAppId()); + maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds()); + maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute()); + maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify()); + maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable()); + String json=gson.toJson(maatCfg); + //下发maat +// new ConvertTool().saveAppConfig(json); + sendFlag = true; + + }else{//取消审核通过 + AppMaatCfg maatCfg = new AppMaatCfg(); + if(StringUtil.isEmpty(featuresTableList)){ + ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); + maatCfg.setMaatTable(serviceCfg.getMaatTable()); + if(appCfg.getCompileId()==0){ + throw new RuntimeException("转换出错,未获取到正确的compileId"); + }else{ + maatCfg.setCompileId(appCfg.getCompileId()); + } + }else{//特征配置 + for(AppFeaturesIndex featuresCfg:featuresTableList){ + if(featuresCfg.getFeaturesTableType()==2){ + List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppStringCfg cfg:list){ + AppStringCfg strCfg = new AppStringCfg(); + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + strCfg.setMaatTable(c.getMaatTable()); + } } + } + strCfg.setCompileId(featuresCfg.getFeaturesCompileId()); + strList.add(strCfg); } - - cfg.setCompileId(featuresCfg.getFeaturesCompileId()); - complexList.add(cfg); } - } - } - } - AppMaatCfg maatCfg = new AppMaatCfg(); - if(StringUtil.isEmpty(featuresTableList)){ - maatCfg.setIpCfg(hostList); - maatCfg.setAreaCfg(areaList); - if(appCfg.getCompileId()==0){ - throw new RuntimeException("转换出错,未获取到正确的compileId"); - }else{ - maatCfg.setCompileId(appCfg.getCompileId()); - } - }else{//特征配置 - maatCfg.setStrCfg(strList); - maatCfg.setComplexStrCfg(complexList); - } - - if(appCfg.getAction()==null){ - throw new RuntimeException("转换出错,未获取到正确的action"); - }else{ - maatCfg.setAction(appCfg.getAction()); - } - if(appCfg.getIsAreaEffective()==null){ - throw new RuntimeException("转换出错,未获取到正确的isAreaEffective"); - }else{ - maatCfg.setIsAreaEffective(appCfg.getIsAreaEffective()); - } - if(appCfg.getIsValid()==null){ - throw new RuntimeException("转换出错,未获取到正确的isValid"); - }else{ - maatCfg.setIsValid(appCfg.getIsValid()); - } - if(appCfg.getRequestId()==null){ - throw new RuntimeException("转换出错,未获取到正确的requestId"); - }else{ - maatCfg.setRequestId(appCfg.getRequestId()); - } - if(appCfg.getServiceId()==null){ - throw new RuntimeException("转换出错,未获取到正确的serviceId"); - }else{ - maatCfg.setServiceId(appCfg.getServiceId()); - } - maatCfg.setSpecificServiceId(appCfg.getAppId()); - maatCfg.setAreaEffectiveIds(appCfg.getAreaEffectiveIds()==null?"":appCfg.getAreaEffectiveIds()); - maatCfg.setAttribute(appCfg.getAttribute()==null?"":appCfg.getAttribute()); - maatCfg.setClassify(appCfg.getClassify()==null?"":appCfg.getClassify()); - maatCfg.setLable(appCfg.getLable()==null?"":appCfg.getLable()); - String json=gson.toJson(maatCfg); - //下发maat -// new ConvertTool().saveAppConfig(json); - sendFlag = true; - - }else{//取消审核通过 - AppMaatCfg maatCfg = new AppMaatCfg(); - if(StringUtil.isEmpty(featuresTableList)){ - ServiceConfigInfo serviceCfg=serviceConfigInfoDao.findSysServiceConfigInfo(appCfg.getServiceId()); - maatCfg.setMaatTable(serviceCfg.getMaatTable()); - if(appCfg.getCompileId()==0){ - throw new RuntimeException("转换出错,未获取到正确的compileId"); - }else{ - maatCfg.setCompileId(appCfg.getCompileId()); - } - }else{//特征配置 - for(AppFeaturesIndex featuresCfg:featuresTableList){ - if(featuresCfg.getFeaturesTableType()==2){ - List list =appCfgDao.getStrFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); - for(AppStringCfg cfg:list){ - AppStringCfg strCfg = new AppStringCfg(); - List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); - if(!StringUtil.isEmpty(cList)){ - for(ServiceConfigInfo c:cList){ - if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ - strCfg.setMaatTable(c.getMaatTable()); + if(featuresCfg.getFeaturesTableType()==4){ + List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); + for(AppComplexKeywordCfg cfg:list){ + AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg(); + List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); + if(!StringUtil.isEmpty(cList)){ + for(ServiceConfigInfo c:cList){ + if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ + complexCfg.setMaatTable(c.getMaatTable()); + } } } + complexCfg.setCompileId(featuresCfg.getFeaturesCompileId()); + complexList.add(complexCfg); } - strCfg.setCompileId(featuresCfg.getFeaturesCompileId()); - strList.add(strCfg); - } - } - if(featuresCfg.getFeaturesTableType()==4){ - List list = appCfgDao.getComplexkeywordFeaturesCfgListByCompileId(featuresCfg.getFeaturesTable(), featuresCfg.getFeaturesCompileId()); - for(AppComplexKeywordCfg cfg:list){ - AppComplexKeywordCfg complexCfg = new AppComplexKeywordCfg(); - List cList = serviceConfigInfoDao.findList(appCfg.getServiceId()); - if(!StringUtil.isEmpty(cList)){ - for(ServiceConfigInfo c:cList){ - if(c.getTableName().equals(featuresCfg.getFeaturesTable())){ - complexCfg.setMaatTable(c.getMaatTable()); - } - } - } - - complexCfg.setCompileId(featuresCfg.getFeaturesCompileId()); - complexList.add(complexCfg); } } + maatCfg.setStrCfg(strList); + maatCfg.setComplexStrCfg(complexList); } - maatCfg.setStrCfg(strList); - maatCfg.setComplexStrCfg(complexList); + + String json=gson.toJson(maatCfg); + //下发maat +// new ConvertTool().saveAppConfig(json); + sendFlag = true; } - String json=gson.toJson(maatCfg); - //下发maat -// new ConvertTool().saveAppConfig(json); + }else{ sendFlag = true; } - }else{ - sendFlag = false; - } - - if(sendFlag){ - //修改appId配置审核下发状态 - appCfgDao.audit(entity); - //修改特定服务IP分组下发状态 - specificServiceCfgDao.updateConfigGroupInfobyGroupId(group); - //修改特征表配置审核下发状态 - for(AppFeaturesIndex cfg:featuresTableList){ - appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), entity.getIsValid(), - entity.getIsAudit(), entity.getAuditorId(), entity.getAuditTime()); - + if(sendFlag){ + //修改appId配置审核下发状态 + appCfgDao.audit(appCfg); + //修改特定服务IP分组下发状态 + specificServiceCfgDao.updateConfigGroupInfobyGroupId(group); + //修改特征表配置审核下发状态 + for(AppFeaturesIndex cfg:featuresTableList){ + appCfgDao.auditFeaturesTable(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), appCfg.getIsValid(), + appCfg.getIsAudit(), appCfg.getAuditorId(), appCfg.getAuditTime()); + + } + }else{ + return 0; } - return 1; - }else{ - return 0; } + return 1; } /** * @@ -503,22 +521,27 @@ public class AppCfgService extends CrudService { * @since 1.0.0 */ @Transactional(readOnly=false,rollbackFor=RuntimeException.class) - public int deleteAppCfg(AppIdCfg entity){ - Integer status = appCfgDao.updateValid(entity); - if(status==1){ - List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId()); - for(AppFeaturesIndex cfg:featuresTableList){ - status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), - entity.getIsValid(), entity.getEditorId(), entity.getEditTime()); - if(status==0){ - return 0; + public int deleteAppCfg(String[] cfgIds){ + for(String id : cfgIds){ + AppIdCfg entity = appCfgDao.getById(Long.parseLong(id)); + entity.setEditorId(entity.getCurrentUser().getId()); + entity.setEditTime(new Date()); + entity.setIsValid(Constants.VALID_DEL); + Integer status = appCfgDao.updateValid(entity); + if(status==1){ + List featuresTableList = appCfgDao.getFeaturesTableListByAppCompileId(entity.getCompileId()); + for(AppFeaturesIndex cfg:featuresTableList){ + status = appCfgDao.updateFeaturesTableValid(cfg.getFeaturesTable(), cfg.getFeaturesCompileId(), + entity.getIsValid(), entity.getEditorId(), entity.getEditTime()); + if(status==0){ + return 0; + } } + }else{ + return 0; } - return status; - }else{ - return status; } -// return appCfgDao.updateValid(cfg); + return 1; } /** * diff --git a/src/main/webapp/WEB-INF/tags/sys/delRow.tag b/src/main/webapp/WEB-INF/tags/sys/delRow.tag index 0989b9077..d1a5bf134 100644 --- a/src/main/webapp/WEB-INF/tags/sys/delRow.tag +++ b/src/main/webapp/WEB-INF/tags/sys/delRow.tag @@ -115,7 +115,12 @@ var checkboxes=$("#${id} ${value} tbody tr td input.i-checks:checkbox"); top.$.jBox.confirm("","",function(v,h,f){ if(v=="ok"){ - window.location = url+"?ids="+ids; + if(url.indexOf("?")>0){ + window.location = url+"&ids="+ids; + }else{ + window.location = url+"?ids="+ids; + } + //$("#searchForm").submit(); } },{buttonsFocus:1}); diff --git a/src/main/webapp/WEB-INF/views/cfg/appCfgList.jsp b/src/main/webapp/WEB-INF/views/cfg/appCfgList.jsp index 36a2c70f3..7e8151c68 100644 --- a/src/main/webapp/WEB-INF/views/cfg/appCfgList.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/appCfgList.jsp @@ -24,6 +24,14 @@ $("#keywords").attr("value",''); $("#searchForm")[0].reset(); }); + //全选及取消 + $("#checkAll").change(function(){ + if($("#checkAll").prop("checked")){ + $("input.i-checks").prop("checked",true); + }else{ + $("input.i-checks").prop("checked",false); + } + }); }); //查询 function page(n,s){ @@ -32,6 +40,24 @@ $("#searchForm").submit(); return false; } + //修改配置 + function updateCfg(){ + var cked = $('tbody tr td input.i-checks:checkbox:checked'); + if(cked.val()==1){ + top.$.jBox.tip("", ""); + return; + }else if(cked.val()==3){ + top.$.jBox.tip("", ""); + return; + } + if(cked.length==1){ + window.location = "${ctx}/cfg/app/updateForm?serviceId="+$("#serviceId").val()+"&action="+ + $("#action").val()+"&cfgId="+cked.attr("id")+"&cfgName="+$("#cfgName").val(); + }else{ + top.$.jBox.tip("", ""); + return; + } + } @@ -114,6 +140,41 @@