修改公共组管理删除校验
This commit is contained in:
@@ -83,12 +83,6 @@ public class CommonGroupManageController extends BaseController {
|
||||
return "redirect:" + adminPath + "/basics/commonGroup/list";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value="ajaxCheckGroupUse")
|
||||
public boolean ajaxCheckGroupUse(@RequestParam("groupIds")String groupIds){
|
||||
return commonGroupManageService.checkIsIssued(groupIds);
|
||||
}
|
||||
|
||||
// 数据导出
|
||||
@RequestMapping(value = "exportGroup")
|
||||
public void exportGroup(Model model,@ModelAttribute("cfg")CommonGroupInfo entity,String ids,RedirectAttributes redirectAttributes,
|
||||
|
||||
@@ -13,10 +13,11 @@
|
||||
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
|
||||
<result column="service_group_id" property="serviceGroupId" jdbcType="INTEGER" />
|
||||
<result column="description" property="description" jdbcType="VARCHAR" />
|
||||
<result column="ud_flag" property="udFlag" jdbcType="INTEGER" />
|
||||
</resultMap>
|
||||
<sql id="CommonGroupInfoColumns">
|
||||
r.group_id,r.group_name,r.group_type,r.is_valid,r.create_time,r.edit_time,
|
||||
r.creator_id,r.editor_id,r.service_group_id,r.description
|
||||
r.creator_id,r.editor_id,r.service_group_id,r.description, ud_flag
|
||||
</sql>
|
||||
|
||||
<!-- 查出所有 有效数据-->
|
||||
|
||||
@@ -108,49 +108,6 @@ public class CommonGroupManageService extends BaseService{
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除时校验分组是否被引用,未被引用可删除
|
||||
* @param groupIds
|
||||
* @return false未被引用 / true已被引用
|
||||
*/
|
||||
public boolean checkIsIssued(String groupIds) {
|
||||
// 组织格式
|
||||
Map<Integer,Set<Integer>> map = new HashMap<Integer,Set<Integer>>();
|
||||
for(String str : groupIds.split(",")) {
|
||||
Integer id = Integer.valueOf(str.substring(0, str.indexOf("_")));
|
||||
Integer type = Integer.valueOf(str.substring(str.indexOf("_")+1));
|
||||
if(map.containsKey(type)) {
|
||||
Set<Integer> set = map.get(type);
|
||||
set.add(id);
|
||||
map.put(type, set);
|
||||
}else {
|
||||
Set<Integer> set = new HashSet<Integer>();
|
||||
set.add(id);
|
||||
map.put(type, set);
|
||||
}
|
||||
}
|
||||
|
||||
// 根据类型去相应配置查询,若存在被引用的则限制操作
|
||||
Set<Integer> keySet = map.keySet();
|
||||
for (Integer type : keySet) {
|
||||
Set<Integer> set = map.get(type);
|
||||
String str = set.toString();
|
||||
String ids = str.substring(1, str.indexOf("]"));
|
||||
if(type == 5) {
|
||||
List<IpCommCfg> list = ipCommGroupCfgDao.getCfgInfoByGroupIds(ids);
|
||||
if(list.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}else if(type == 7) {
|
||||
List<UrlCommCfg> list = urlCommGroupDao.getCfgInfoByGroupIds(ids);
|
||||
if(list.size() > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分组状态 policy_group_info ud_flag:0(无有效的域配置) 1(存在有效的域配置)
|
||||
* @param serviceGroupId
|
||||
|
||||
@@ -34,11 +34,16 @@
|
||||
var checkboxes = $("tbody tr td input.i-checks:checkbox");
|
||||
var ids = "";
|
||||
var str = "";
|
||||
var canDel = true;
|
||||
|
||||
checkboxes.each(function(){
|
||||
if(true == $(this).is(':checked')){
|
||||
str += $(this).attr("id")+"_"+$(this).attr("groupType")+",";
|
||||
ids += $(this).attr("id")+",";
|
||||
if($(this).attr("udFlag") != 0){ // 存在被引用的分组
|
||||
canDel = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -51,21 +56,7 @@
|
||||
}
|
||||
|
||||
if(str.length >0){
|
||||
// 删除时 校验分组是否已被引用,未引用可删除
|
||||
var canDel = true;
|
||||
var tip='<spring:message code="can_not_delete_issued_group"/>';
|
||||
$.ajax({
|
||||
type:'post',
|
||||
url:'${ctx}/basics/commonGroup/ajaxCheckGroupUse',
|
||||
data:{"groupIds":str},
|
||||
async:false,
|
||||
success:function(data,textStatus){
|
||||
if(data){
|
||||
canDel=false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(canDel){
|
||||
top.$.jBox.confirm("<spring:message code='confirm_message'/>","<spring:message code='info'/>",function(v,h,f){
|
||||
if(v=="ok"){
|
||||
@@ -231,7 +222,7 @@
|
||||
<tbody>
|
||||
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
|
||||
<tr>
|
||||
<td><input type="checkbox" class="i-checks" id="${cfg.groupId}" groupType="${cfg.groupType}" serviceGroupId="${cfg.serviceGroupId}"></td>
|
||||
<td><input type="checkbox" class="i-checks" id="${cfg.groupId}" groupType="${cfg.groupType}" serviceGroupId="${cfg.serviceGroupId}" udFlag="${cfg.udFlag }"></td>
|
||||
<td>
|
||||
<a href="javascript:;" data-original-title="${cfg.groupName}"
|
||||
class="tooltips" data-flag="false" data-html="true" data-placement="top">
|
||||
|
||||
Reference in New Issue
Block a user