调整删除asn ip验证,只有下发过的asn ip需要ajax后台判断。调整ajax判断sql
This commit is contained in:
@@ -120,9 +120,9 @@ public class AsnIpController extends BaseController{
|
|||||||
}
|
}
|
||||||
@RequestMapping(value="ajaxIsLast",method=RequestMethod.POST)
|
@RequestMapping(value="ajaxIsLast",method=RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds){
|
public boolean ajaxIsLast(Model model,@RequestParam(required=true,value="serviceGroupIds")String serviceGroupIds,@RequestParam(required=true,value="ids")String ids){
|
||||||
if(StringUtils.isNotBlank(serviceGroupIds)) {
|
if(StringUtils.isNotBlank(serviceGroupIds)&&StringUtils.isNotBlank(ids)) {
|
||||||
return asnIpCfgService.hasLastIp(serviceGroupIds);
|
return asnIpCfgService.hasLastIp(serviceGroupIds,ids);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,5 +18,5 @@ public interface AsnIpCfgDao extends CrudDao<AsnIpCfg>{
|
|||||||
public List<AsnIpCfg> findAllList(AsnIpCfg cfg);
|
public List<AsnIpCfg> findAllList(AsnIpCfg cfg);
|
||||||
public List<ConfigGroupInfo> findPolicyGroupInfosByType(@Param("groupId")Integer groupId);
|
public List<ConfigGroupInfo> findPolicyGroupInfosByType(@Param("groupId")Integer groupId);
|
||||||
public List<Integer> findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId);
|
public List<Integer> findOtherIps(@Param("groupId")Integer groupId,@Param("cfgId")Integer cfgId);
|
||||||
public List<Integer> countValidIPs(@Param("ids")String ids);
|
public List<Integer> countValidIPs(@Param("groups")String groups,@Param("ids")String ids);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -387,7 +387,7 @@
|
|||||||
select 1 from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${ids}) limit 1
|
select 1 from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${ids}) limit 1
|
||||||
</select>
|
</select>
|
||||||
<select id="countValidIPs" resultType="java.lang.Integer" parameterType="java.lang.Integer">
|
<select id="countValidIPs" resultType="java.lang.Integer" parameterType="java.lang.Integer">
|
||||||
select count(1) from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${ids}) GROUP BY asn_ip_group;
|
select count(1) from asn_ip_cfg where is_valid !=-1 and asn_ip_group in(${groups}) and cfg_id not in(${ids}) GROUP BY asn_ip_group;
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -178,14 +178,17 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
|||||||
* @param serviceGroupIds
|
* @param serviceGroupIds
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasLastIp(String serviceGroupIds) {
|
public boolean hasLastIp(String serviceGroupIds,String ids) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
for(String groupId:serviceGroupIds.split(",")) {
|
for(String groupId:serviceGroupIds.split(",")) {
|
||||||
Long.parseLong(groupId);
|
Long.parseLong(groupId);
|
||||||
}
|
}
|
||||||
List<Integer> countList=asnIpCfgDao.countValidIPs(serviceGroupIds);
|
List<Integer> countList=asnIpCfgDao.countValidIPs(serviceGroupIds,ids);
|
||||||
|
if(countList.size()==0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
for(Integer count:countList) {
|
for(Integer count:countList) {
|
||||||
if(count==1) {
|
if(count==0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,17 +50,20 @@ function del(url){
|
|||||||
top.$.jBox.tip("<spring:message code='has_prohibit_delete'/>", "<spring:message code='info'/>");
|
top.$.jBox.tip("<spring:message code='has_prohibit_delete'/>", "<spring:message code='info'/>");
|
||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
var serviceGroupIds=[],canDel=true;
|
var serviceGroupIds=[],ids=[],canDel=true;
|
||||||
$(checkboxes).filter(":checked").each(function(){
|
$(checkboxes).filter(":checked").each(function(){
|
||||||
if($(this).attr("serviceGroupId")){
|
if($(this).attr("serviceGroupId")&&$(this).attr("isValid")){
|
||||||
|
if($(this).attr("isValid")==1){//下发过的组的ip才需要判断是否是组内最后一个IP
|
||||||
serviceGroupIds.push($(this).attr("serviceGroupId"));
|
serviceGroupIds.push($(this).attr("serviceGroupId"));
|
||||||
}
|
}
|
||||||
|
ids.push($(this).attr("id"));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if(serviceGroupIds.length>0){
|
if(serviceGroupIds.length>0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'post',
|
type:'post',
|
||||||
url:'${ctx}/basics/asn/ajaxIsLast',
|
url:'${ctx}/basics/asn/ajaxIsLast',
|
||||||
data:{"serviceGroupIds":serviceGroupIds.join(',')},
|
data:{"serviceGroupIds":serviceGroupIds.join(','),"ids":ids.join(',')},
|
||||||
async:false,
|
async:false,
|
||||||
success:function(data,textStatus){//处理返回结果
|
success:function(data,textStatus){//处理返回结果
|
||||||
if(data){
|
if(data){
|
||||||
|
|||||||
Reference in New Issue
Block a user