diff --git a/src/main/java/com/nis/web/controller/basics/AsnIpController.java b/src/main/java/com/nis/web/controller/basics/AsnIpController.java index 92b7c0358..9c30be14e 100644 --- a/src/main/java/com/nis/web/controller/basics/AsnIpController.java +++ b/src/main/java/com/nis/web/controller/basics/AsnIpController.java @@ -118,4 +118,12 @@ public class AsnIpController extends BaseController{ } return false; } + @RequestMapping(value="ajaxIsLast",method=RequestMethod.POST) + @ResponseBody + public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds){ + if(StringUtils.isNotBlank(serviceGroupIds)) { + return asnIpCfgService.hasLastIp(serviceGroupIds); + } + return false; + } } diff --git a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java index 11ad4ba80..17f0787d2 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java +++ b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.java @@ -18,4 +18,5 @@ public interface AsnIpCfgDao extends CrudDao{ public List findAllList(AsnIpCfg cfg); public List findPolicyGroupInfosByType(@Param("groupId")Integer groupId); public List findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId); + public List countValidIPs(@Param("ids")String ids); } diff --git a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml index 746556359..b53303456 100644 --- a/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml +++ b/src/main/java/com/nis/web/dao/basics/AsnIpCfgDao.xml @@ -381,10 +381,13 @@ from config_group_info c where c.group_type= #{groupId} + \ No newline at end of file diff --git a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java index 79f9398f5..98c08b27e 100644 --- a/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java +++ b/src/main/java/com/nis/web/service/basics/AsnIpCfgService.java @@ -171,4 +171,22 @@ public class AsnIpCfgService extends CrudService, AsnIpCfg> { // TODO Auto-generated method stub return asnIpCfgDao.findPolicyGroupInfosByType(groupId); } + /** + * 选中组中是否含有只剩一个未删除IP的组 + * @param serviceGroupIds + * @return + */ + public boolean hasLastIp(String serviceGroupIds) { + // TODO Auto-generated method stub + for(String groupId:serviceGroupIds.split(",")) { + Long.parseLong(groupId); + } + List countList=asnIpCfgDao.countValidIPs(serviceGroupIds); + for(Integer count:countList) { + if(count==1) { + return true; + } + } + return false; + } } diff --git a/src/main/resources/messages/message_en.properties b/src/main/resources/messages/message_en.properties index 3febf49dd..d41212c61 100644 --- a/src/main/resources/messages/message_en.properties +++ b/src/main/resources/messages/message_en.properties @@ -1138,4 +1138,5 @@ is_issued=Is Issued asn_ip_configuration=ASN IP Configuration asn_policy=ASN Policy asn_ip_group=ASN IP Group -can_not_delete_has_ip_asn_group=Can not delete ASN group which has ASN IP \ No newline at end of file +can_not_delete_has_ip_asn_group=Can not delete ASN group which has ASN IP +last_ip_in_asn_group=Can not delete last IP in an ASN group \ No newline at end of file diff --git a/src/main/resources/messages/message_zh_CN.properties b/src/main/resources/messages/message_zh_CN.properties index 00247a510..383223619 100644 --- a/src/main/resources/messages/message_zh_CN.properties +++ b/src/main/resources/messages/message_zh_CN.properties @@ -1135,4 +1135,5 @@ is_issued=\u662F\u5426\u4E0B\u53D1 asn_ip_configuration=ASN IP\u914D\u7F6E asn_policy=ASN\u7B56\u7565 asn_ip_group=ASN IP\u7EC4 -can_not_delete_has_ip_asn_group=\u4E0D\u80FD\u5220\u9664\u5305\u542BASN IP\u7684 ASN\u7EC4 \ No newline at end of file +can_not_delete_has_ip_asn_group=\u4E0D\u80FD\u5220\u9664\u5305\u542BASN IP\u7684 ASN\u7EC4 +last_ip_in_asn_group=\u4E0D\u80FD\u5220\u9664ASN\u7EC4\u4E2D\u7684\u6700\u540E\u4E00\u4E2AIP \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/tags/sys/delRow.tag b/src/main/webapp/WEB-INF/tags/sys/delRow.tag index c409177e1..2fba386a5 100644 --- a/src/main/webapp/WEB-INF/tags/sys/delRow.tag +++ b/src/main/webapp/WEB-INF/tags/sys/delRow.tag @@ -49,13 +49,35 @@ function del(url){ if(validateAllNoAudit(checkboxes)){ top.$.jBox.tip("", ""); return; - }else{ - doAll(checkboxes,url); + }else{ + var serviceGroupIds=[],canDel=true; + $(checkboxes).filter(":checked").each(function(){ + if($(this).attr("serviceGroupId")){ + serviceGroupIds.push($(this).attr("serviceGroupId")); } - }else{ - top.$.jBox.tip("", ""); - return; + }) + if(serviceGroupIds.length>0){ + $.ajax({ + type:'post', + url:'${ctx}/basics/asn/ajaxIsLast', + data:{"serviceGroupIds":serviceGroupIds.join(',')}, + async:false, + success:function(data,textStatus){//处理返回结果 + if(data){ + top.$.jBox.tip(''); + canDel=false; + } + } + }); + } + if(canDel){ + doAll(checkboxes,url); + } } + }else{ + top.$.jBox.tip("", ""); + return; + } } //修改配置 function update(url){