分组配置管理删除分组下最后一条域配置时增加提示信息

This commit is contained in:
zhangwenqing
2019-06-11 17:25:10 +08:00
parent 2b23095c9d
commit bbda5e233f
17 changed files with 345 additions and 27 deletions

View File

@@ -21,7 +21,7 @@ public class IpCommCfg extends BaseCfg<IpCommCfg> {
super();
// TODO Auto-generated constructor stub
}
private static String indexTable="ip_comm_cfg";
private static final String indexTable="ip_comm_cfg";
/**
* ip类型
*/
@@ -300,12 +300,9 @@ public class IpCommCfg extends BaseCfg<IpCommCfg> {
this.direction = 0;
}
public String getIndexTable() {
public static String getIndexTable() {
return indexTable;
}
public void setIndexTable(String indexTable) {
this.indexTable = indexTable;
}
public Integer getIndex() {
return index;
}

View File

@@ -13,6 +13,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.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@@ -83,6 +84,12 @@ public class CommonGroupManageController extends BaseController {
return "redirect:" + adminPath + "/basics/commonGroup/list";
}
@ResponseBody
@RequestMapping(value="ajaxCheckIsLastOneCfg",method=RequestMethod.POST)
public List<Integer> ajaxCheckIsLastOneCfg(Model model, String grouIdAndCfgId, Integer groupType){
return commonGroupManageService.ajaxCheckIsLastOneCfg(grouIdAndCfgId, groupType);
}
// 数据导出
@RequestMapping(value = "exportGroup")
public void exportGroup(Model model,@ModelAttribute("cfg")CommonGroupInfo entity,String ids,RedirectAttributes redirectAttributes,

View File

@@ -116,9 +116,9 @@ public class DomainCommGroupController extends BaseController{
}
@RequestMapping(value = {"/delete"})
public String delete(String compileIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
try{
domainCommGroupService.delete(ids,compileIds);
domainCommGroupService.delete(ids,groupIds);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);

View File

@@ -125,9 +125,9 @@ public class IpCommGroupController extends BaseController {
@RequestMapping(value = { "/delete" })
@RequiresPermissions(value = { "ip:common:config" })
public String delete(String compileIds, String ids, Integer functionId, RedirectAttributes redirectAttributes) {
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes) {
try {
ipCommGroupCfgService.delete(ids, compileIds);
ipCommGroupCfgService.delete(ids, groupIds);
addMessage(redirectAttributes, "success", "delete_success");
} catch (Exception e) {
logger.error("Delete failed", e);

View File

@@ -116,9 +116,9 @@ public class ScriberIdCommGroupController extends BaseController{
}
@RequestMapping(value = {"/delete"})
public String delete(String compileIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
try{
scriberIdCommGroupService.delete(ids,compileIds);
scriberIdCommGroupService.delete(ids,groupIds);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);

View File

@@ -116,9 +116,9 @@ public class UrlCommGroupController extends BaseController{
}
@RequestMapping(value = {"/delete"})
public String delete(String compileIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
public String delete(String groupIds, String ids, Integer functionId, RedirectAttributes redirectAttributes){
try{
urlCommGroupService.delete(ids,compileIds);
urlCommGroupService.delete(ids,groupIds);
addMessage(redirectAttributes,"success","delete_success");
}catch(Exception e){
logger.error("Delete failed",e);

View File

@@ -22,4 +22,8 @@ public interface CommonGroupManageDao extends CrudDao<CommonGroupInfo> {
CommonGroupInfo getGroupInfo(CommonGroupInfo searchCfg);
Integer getCompileIdByGroupId(String groupId);
// 校验是否是当前引用Group的最后一条配置
public Integer ajaxCheckIsLastOneCfg(@Param("groupId")Integer groupId, @Param("cfgIds")String CfgIds, @Param("tableName")String indextable);
}

View File

@@ -205,5 +205,22 @@
</if>
</trim>
</select>
<select id="getCompileIdByGroupId" resultType="java.lang.Integer">
SELECT
compile_id
FROM
cfg_index_info
WHERE
common_group_ids LIKE concat(concat('%',#{groupId,jdbcType=VARCHAR}),'%') AND is_valid != -1
</select>
<select id="ajaxCheckIsLastOneCfg" resultType="java.lang.Integer">
SELECT
COUNT(1)
FROM
${tableName} r
WHERE
r.group_id = #{groupId} AND r.cfg_id NOT IN(${cfgIds})
</select>
</mapper>

View File

@@ -203,4 +203,55 @@ public class CommonGroupManageService extends BaseService{
}
/**
* 校验执行删除操作后分组下域配置是否为空
* @param serviceGroupIds
* @param groupType
* @return
*/
public List<Integer> ajaxCheckIsLastOneCfg(String grouIdAndCfgId, Integer groupType) {
// 组织格式
Map<Integer,List<Integer>> map = new HashMap<Integer,List<Integer>>();
for(String str : grouIdAndCfgId.split(",")) {
Integer groupId = Integer.valueOf(str.substring(0, str.indexOf("_")));
Integer cfgId = Integer.valueOf(str.substring(str.indexOf("_")+1));
if(map.containsKey(groupId)) {
List<Integer> list = map.get(groupId);
list.add(cfgId);
map.put(groupId, list);
}else {
List<Integer> list = new ArrayList<Integer>();
list.add(cfgId);
map.put(groupId, list);
}
}
List<Integer> resultList = new ArrayList<Integer>();
for (Integer groupId : map.keySet()) {
List<Integer> cfgIdList = map.get(groupId);
String cfgIds = "";
for (Integer cfgId : cfgIdList) {
cfgIds += "," + cfgId;
}
Integer size = 0;
if(groupType == 5) { // IP
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), IpCommCfg.getIndexTable());
}else if(groupType == 7) { // URL
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), UrlCommCfg.getTablename());
}else if(groupType == 8) { // Domain
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), DomainCommCfg.getTablename());
}else if(groupType == 9) { // ScriberId
size = commonGroupManageDao.ajaxCheckIsLastOneCfg(groupId, cfgIds.substring(1), ScriberIdCommCfg.getTablename());
}
if(size == 0) { // 0为分组下的最后一条配置获取配置ID提示
Integer compileId = commonGroupManageDao.getCompileIdByGroupId(","+groupId+",");
if(compileId != null) {
resultList.add(compileId);
}
}
}
return resultList;
}
}

View File

@@ -128,8 +128,8 @@ public class IpCommGroupCfgService extends BaseService {
}
public void delete(String ids, String compileIds) {
List<PolicyGroupInfo> policyGroupInfos=policyGroupInfoDao.findPolicyByServiceGroupInfoList(compileIds);
public void delete(String ids, String groupIds) {
List<PolicyGroupInfo> policyGroupInfos=policyGroupInfoDao.findPolicyByServiceGroupInfoList(groupIds);
if(ids==null) {
throw new RuntimeException("ids is null!");
}

View File

@@ -61,6 +61,63 @@
return;
}
}
function deletes(url){
var checkboxes = $("tbody tr td input.i-checks:checkbox");
var ids = "";
var str = "";
var groupIds = "";
var canDel = true;
checkboxes.each(function(){
if(true == $(this).is(':checked')){
ids += ","+$(this).attr("id");
str += ","+$(this).attr("groupId")+"_"+$(this).attr("id");
groupIds += ","+$(this).attr("groupId");
}
});
ids = ids.substr(1);
str = str.substr(1);
groupIds = groupIds.substr(1);
if(ids.length >0){
var tipInfoAdd = "";
var tipCompileIds = "";
$.ajax({
type:'post',
url:'${ctx}/basics/commonGroup/ajaxCheckIsLastOneCfg',
data:{"grouIdAndCfgId":str,"groupType":8},
async:false,
success:function(data,textStatus){// 处理返回结果
if(data.length > 0){
canDel = false;
for(var index in data){
tipCompileIds += ","+data[index]
}
tipCompileIds = tipCompileIds.substr(1);
}
}
});
if(!canDel){
var shortStr = tipCompileIds.length > 6? tipCompileIds.substr(0,6)+"..." : tipCompileIds ;
tipInfoAdd = $.validator.messages.cancel_config_warn.replace("{0}","<b title='"+tipCompileIds+"'>'"+shortStr+"'</b>")+"";
}
top.$.jBox.confirm(tipInfoAdd+"<spring:message code='confirm_message'/>","<spring:message code='info'/>",function(v,h,f){
if(v=="ok"){
window.location = url+"&ids="+ids+"&groupIds="+groupIds;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
}else{
top.$.jBox.tip("<spring:message code='one_more'/>", "<spring:message code='info'/>");
return;
}
}
</script>
</head>
<body>
@@ -135,7 +192,10 @@
<div class="pull-right">
<shiro:hasPermission name="domain:common:config">
<sys:delRow url="${ctx}/basics/domain/updateForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/basics/domain/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<%-- <sys:delRow url="${ctx}/basics/domain/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow> --%>
<a href="javascript:void(0);" class="btn btn-default" onclick="deletes('${ctx}/basics/domain/delete?isValid=-1&functionId=${cfg.functionId }')" data-toggle="tooltip" data-placement="top">
<i class="fa fa-trash"> <spring:message code="delete"/></i>
</a>
</shiro:hasPermission>
<div class="btn-group">
@@ -218,7 +278,7 @@
<tbody>
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" compileId="${cfg.groupId}"></td>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" groupId="${cfg.groupId}"></td>
<td>${cfg.cfgDesc }</td>
<td>
<c:forEach items="${policyGroupInfos}" var="info">

View File

@@ -59,6 +59,62 @@
}
}
function deletes(url){
var checkboxes = $("tbody tr td input.i-checks:checkbox");
var ids = "";
var str = "";
var groupIds = "";
var canDel = true;
checkboxes.each(function(){
if(true == $(this).is(':checked')){
ids += ","+$(this).attr("id");
str += ","+$(this).attr("groupId")+"_"+$(this).attr("id");
groupIds += ","+$(this).attr("groupId");
}
});
ids = ids.substr(1);
str = str.substr(1);
groupIds = groupIds.substr(1);
if(ids.length >0){
var tipInfoAdd = "";
var tipCompileIds = "";
$.ajax({
type:'post',
url:'${ctx}/basics/commonGroup/ajaxCheckIsLastOneCfg',
data:{"grouIdAndCfgId":str,"groupType":5},
async:false,
success:function(data,textStatus){// 处理返回结果
if(data.length > 0){
canDel = false;
for(var index in data){
tipCompileIds += ","+data[index]
}
tipCompileIds = tipCompileIds.substr(1);
}
}
});
if(!canDel){
var shortStr = tipCompileIds.length > 6? tipCompileIds.substr(0,6)+"..." : tipCompileIds ;
tipInfoAdd = $.validator.messages.cancel_config_warn.replace("{0}","<b title='"+tipCompileIds+"'>'"+shortStr+"'</b>")+"";
}
top.$.jBox.confirm(tipInfoAdd+"<spring:message code='confirm_message'/>","<spring:message code='info'/>",function(v,h,f){
if(v=="ok"){
window.location = url+"&ids="+ids+"&groupIds="+groupIds;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
}else{
top.$.jBox.tip("<spring:message code='one_more'/>", "<spring:message code='info'/>");
return;
}
}
</script>
</head>
<body>
@@ -154,7 +210,10 @@
<div class="pull-right">
<shiro:hasPermission name="ip:common:config">
<sys:delRow url="${ctx}/basics/ip/updateForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/basics/ip/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<%-- <sys:delRow url="${ctx}/basics/ip/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow> --%>
<a href="javascript:void(0);" class="btn btn-default" onclick="deletes('${ctx}/basics/ip/delete?isValid=-1&functionId=${cfg.functionId }')" data-toggle="tooltip" data-placement="top">
<i class="fa fa-trash"> <spring:message code="delete"/></i>
</a>
</shiro:hasPermission>
<div class="btn-group">
@@ -253,7 +312,7 @@
<tbody>
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" compileId="${cfg.groupId}"></td>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" groupId="${cfg.groupId}"></td>
<td>${cfg.cfgDesc }</td>
<td>
<c:forEach items="${policyGroupInfos}" var="policyGroup">

View File

@@ -61,6 +61,63 @@
return;
}
}
function deletes(url){
var checkboxes = $("tbody tr td input.i-checks:checkbox");
var ids = "";
var str = "";
var groupIds = "";
var canDel = true;
checkboxes.each(function(){
if(true == $(this).is(':checked')){
ids += ","+$(this).attr("id");
str += ","+$(this).attr("groupId")+"_"+$(this).attr("id");
groupIds += ","+$(this).attr("groupId");
}
});
ids = ids.substr(1);
str = str.substr(1);
groupIds = groupIds.substr(1);
if(ids.length >0){
var tipInfoAdd = "";
var tipCompileIds = "";
$.ajax({
type:'post',
url:'${ctx}/basics/commonGroup/ajaxCheckIsLastOneCfg',
data:{"grouIdAndCfgId":str,"groupType":9},
async:false,
success:function(data,textStatus){// 处理返回结果
if(data.length > 0){
canDel = false;
for(var index in data){
tipCompileIds += ","+data[index]
}
tipCompileIds = tipCompileIds.substr(1);
}
}
});
if(!canDel){
var shortStr = tipCompileIds.length > 6? tipCompileIds.substr(0,6)+"..." : tipCompileIds ;
tipInfoAdd = $.validator.messages.cancel_config_warn.replace("{0}","<b title='"+tipCompileIds+"'>'"+shortStr+"'</b>")+"";
}
top.$.jBox.confirm(tipInfoAdd+"<spring:message code='confirm_message'/>","<spring:message code='info'/>",function(v,h,f){
if(v=="ok"){
window.location = url+"&ids="+ids+"&groupIds="+groupIds;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
}else{
top.$.jBox.tip("<spring:message code='one_more'/>", "<spring:message code='info'/>");
return;
}
}
</script>
</head>
<body>
@@ -135,7 +192,10 @@
<div class="pull-right">
<shiro:hasPermission name="scriberid:common:config">
<sys:delRow url="${ctx}/basics/scriberId/updateForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/basics/scriberId/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<%-- <sys:delRow url="${ctx}/basics/scriberId/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow> --%>
<a href="javascript:void(0);" class="btn btn-default" onclick="deletes('${ctx}/basics/scriberId/delete?isValid=-1&functionId=${cfg.functionId }')" data-toggle="tooltip" data-placement="top">
<i class="fa fa-trash"> <spring:message code="delete"/></i>
</a>
</shiro:hasPermission>
<div class="btn-group">
@@ -218,7 +278,7 @@
<tbody>
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" compileId="${cfg.groupId}"></td>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" groupId="${cfg.groupId}"></td>
<td>${cfg.cfgDesc }</td>
<td>
<c:forEach items="${policyGroupInfos}" var="info">

View File

@@ -56,6 +56,63 @@
return;
}
}
function deletes(url){
var checkboxes = $("tbody tr td input.i-checks:checkbox");
var ids = "";
var str = "";
var groupIds = "";
var canDel = true;
checkboxes.each(function(){
if(true == $(this).is(':checked')){
ids += ","+$(this).attr("id");
str += ","+$(this).attr("groupId")+"_"+$(this).attr("id");
groupIds += ","+$(this).attr("groupId");
}
});
ids = ids.substr(1);
str = str.substr(1);
groupIds = groupIds.substr(1);
if(ids.length >0){
var tipInfoAdd = "";
var tipCompileIds = "";
$.ajax({
type:'post',
url:'${ctx}/basics/commonGroup/ajaxCheckIsLastOneCfg',
data:{"grouIdAndCfgId":str,"groupType":7},
async:false,
success:function(data,textStatus){// 处理返回结果
if(data.length > 0){
canDel = false;
for(var index in data){
tipCompileIds += ","+data[index]
}
tipCompileIds = tipCompileIds.substr(1);
}
}
});
if(!canDel){
var shortStr = tipCompileIds.length > 6? tipCompileIds.substr(0,6)+"..." : tipCompileIds ;
tipInfoAdd = $.validator.messages.cancel_config_warn.replace("{0}","<b title='"+tipCompileIds+"'>'"+shortStr+"'</b>")+"";
}
top.$.jBox.confirm(tipInfoAdd+"<spring:message code='confirm_message'/>","<spring:message code='info'/>",function(v,h,f){
if(v=="ok"){
window.location = url+"&ids="+ids+"&groupIds="+groupIds;
}
},{buttonsFocus:1});
top.$('.jbox-body .jbox-icon').css('top','55px');
}else{
top.$.jBox.tip("<spring:message code='one_more'/>", "<spring:message code='info'/>");
return;
}
}
</script>
</head>
<body>
@@ -130,7 +187,10 @@
<div class="pull-right">
<shiro:hasPermission name="url:common:config">
<sys:delRow url="${ctx}/basics/url/updateForm?functionId=${cfg.functionId}" id="contentTable" label="update"></sys:delRow>
<sys:delRow url="${ctx}/basics/url/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow>
<%-- <sys:delRow url="${ctx}/basics/url/delete?isValid=-1&functionId=${cfg.functionId }" id="contentTable" label="delete"></sys:delRow> --%>
<a href="javascript:void(0);" class="btn btn-default" onclick="deletes('${ctx}/basics/url/delete?isValid=-1&functionId=${cfg.functionId }')" data-toggle="tooltip" data-placement="top">
<i class="fa fa-trash"> <spring:message code="delete"/></i>
</a>
</shiro:hasPermission>
<div class="btn-group">
@@ -213,7 +273,7 @@
<tbody>
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
<tr>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" compileId="${cfg.groupId}"></td>
<td><input type="checkbox" class="i-checks" id="${cfg.cfgId}" isValid="${cfg.isValid}" value="${cfg.isAudit}" groupId="${cfg.groupId}"></td>
<td>${cfg.cfgDesc }</td>
<td>
<c:forEach items="${policyGroupInfos}" var="info">

View File

@@ -99,6 +99,7 @@
rangeCross1:"The IP range {0} has intersections with {1}",
protectedCfgUnique:"Keyword already exists.",
addrList:"Please enter a correct: MAC(aa:bb:cc:11:22:33),VLAN must be exponent of 1 not greater than 4094,Multiple data separated by commas",
sslVersionCheck:"Min SSL version should smaller than Max SSL version"
sslVersionCheck:"Min SSL version should smaller than Max SSL version",
cancel_config_warn:"This action cancels the business configuration with a configuration ID of {0}"
});
}(jQuery));

View File

@@ -99,6 +99,7 @@
rangeCross1:"Диапазон IP {0} имеет пересечения с {1}",
protectedCfgUnique:"Ключевое слово уже существует.",
addrList:"Please enter a correct: MAC(aa:bb:cc:11:22:33),VLAN must be exponent of 1 not greater than 4094,Multiple data separated by commas",
sslVersionCheck:"моя версия SSL должны меньше, чем версия SSL, макс"
sslVersionCheck:"моя версия SSL должны меньше, чем версия SSL, макс",
cancel_config_warn:"This action cancels the business configuration with a configuration ID of {0}"
});
}(jQuery));

View File

@@ -99,6 +99,7 @@
rangeCross1:"IP范围{0}和IP范围{1}有交集",
protectedCfgUnique:"关键字已存在",
addrList:"请输入合法的目标标识如MAC(aa:bb:cc:11:22:33),VLAN介于1-4094之间,多条数据用逗号分隔",
sslVersionCheck:"最小SSL协议版本应小于最大SSL协议版本"
sslVersionCheck:"最小SSL协议版本应小于最大SSL协议版本",
cancel_config_warn:"该操作会取消配置ID为{0}的业务配置"
});
}(jQuery));