(1)修复特定服务新增时无法选择上级节点的bug

(2)特定服务加入验证,当前节点的配置类型应当与上级配置一致
This commit is contained in:
wangxin
2018-07-25 15:19:24 +08:00
parent 4e0be5b70b
commit 76b7122c21
13 changed files with 68 additions and 13 deletions

View File

@@ -25,11 +25,18 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
private SpecificServiceCfg parent; //parent_id 父节点id int N 0表示一级节点
private Integer isLeaf; //is_leaf 是否是叶子节点 int N 0否1是只有一级填0
private Integer groupId; //group_id maat端配置分组id int N 缺省0表示未与maat分组同步
private Integer cfgType;//配置类型1app;2,加密隧道协议
private Integer cfgType;//配置类型1app;2,加密隧道3基础协议
private Integer parentType;//父配置类型
private Date beginDate; // 开始日期
private Date endDate; // 结束日期
private String showSequence; //显示序号
public Integer getParentType() {
return parentType;
}
public void setParentType(Integer parentType) {
this.parentType = parentType;
}
public Integer getCfgType() {
return cfgType;
}

View File

@@ -129,6 +129,10 @@ public class SpecificServiceCfgController extends BaseController {
SpecificServiceCfg parent = new SpecificServiceCfg();
parent.setSpecServiceId(0);
specificServiceCfg.setParent(parent);
specificServiceCfg.setParentType(0);
}
if(specificServiceCfg!=null&&specificServiceCfg.getParent().getSpecServiceId()!=null){//获取父配置的id
specificServiceCfg.setParentType(specificServiceCfgService.getParentType(specificServiceCfg.getParent().getSpecServiceId()));
}
model.addAttribute("specificServiceCfg", specificServiceCfg);
if (doAction != null && doAction.equals("0")) {
@@ -195,6 +199,7 @@ public class SpecificServiceCfgController extends BaseController {
Map<String, Object> map2 = Maps.newHashMap();
map2.put("id", 0);
map2.put("pId", 0);
map2.put("type",0);
map2.put("name","root_node");
//map2.put("placeholder","0");
mapList.add(map2);
@@ -203,13 +208,15 @@ public class SpecificServiceCfgController extends BaseController {
SpecificServiceCfg specificServiceCfg = list.get(i);
if(StringUtils.isBlank(extId)||(extId!=null&&!extId.equals(specificServiceCfg.getSpecServiceId().toString()))){
if(specificServiceCfg.getIsValid().equals(0)||
(!isLeafShow && specificServiceCfg.getIsLeaf().equals(1))||specificServiceCfg.getCfgType().intValue()!=cfgType){
(!isLeafShow && specificServiceCfg.getIsLeaf().equals(1))||
(cfgType.intValue()!=0&&specificServiceCfg.getCfgType().intValue()!=cfgType)){
continue;
}
Map<String, Object> map = Maps.newHashMap();
map.put("id", specificServiceCfg.getSpecServiceId());
map.put("pId", specificServiceCfg.getParent().getSpecServiceId());
map.put("name",specificServiceCfg.getSpecServiceName());
map.put("type",specificServiceCfg.getCfgType());
mapList.add(map);
}
}
@@ -230,6 +237,7 @@ public class SpecificServiceCfgController extends BaseController {
map.put("code", specificServiceCfg.getSpecServiceCode());
map.put("pId", specificServiceCfg.getParent().getSpecServiceId());
map.put("name",specificServiceCfg.getSpecServiceName());
map.put("type",specificServiceCfg.getCfgType());
mapList.add(map);
}
}

View File

@@ -47,5 +47,6 @@ public interface SpecificServiceCfgDao extends CrudDao<SpecificServiceCfg> {
Integer insertConfigGroupInfo(ConfigGroupInfo entity);
Integer updateConfigGroupInfobyGroupId(ConfigGroupInfo entity);
Integer getParentType(Integer specServiceId);
}

View File

@@ -37,6 +37,10 @@
select <include refid="specificServiceCfgColumns" />
from specific_service_cfg s where s.spec_service_id = #{specServiceId}
</select>
<select id="getParentType" resultType="java.lang.Integer" parameterType="java.lang.Integer">
select cfg_type
from specific_service_cfg s where s.spec_service_id = #{specServiceId}
</select>
<!-- 查出所有符合条件的顶层数据 -->

View File

@@ -140,6 +140,8 @@ public class SpecificServiceCfgService extends BaseService{
return specificServiceCfgDao.getChildrenById(specServiceId);
}
public Integer getParentType(Integer specServiceId) {
return specificServiceCfgDao.getParentType(specServiceId);
}
}

View File

@@ -792,7 +792,7 @@ app_byte_config=APP Byte Feature
social_app=Applicaiton
app_policy_config=APP Policy
app_features_config=APP Feature
cfg_type=Cfg Type
cfg_type=Configuration Type
encrypted_tunnel_behavior=Encrypted Tunnel Behavior
behaviour_type=Behaviour Type
basic_protocol=Basic Protocol

View File

@@ -714,7 +714,7 @@ app_byte_config=APP Byte Feature
social_app=Applicaiton
app_policy_config=APP Policy
app_features_config=APP Feature
cfg_type=Cfg Type
cfg_type=Configuration Type
encrypted_tunnel_behavior=Encrypted Tunnel Behavior
behaviour_type=Behaviour Type
basic_protocol=Basic Protocol

View File

@@ -49,7 +49,7 @@
ajaxData:{selectIds: $("#${id}Id").val()},buttons:{"<spring:message code='ok'/>":"ok", "<spring:message code='clear'/>":"clear","<spring:message code='close'/>":true}, submit:function(v, h, f){
if (v=="ok"){
var tree = h.find("iframe")[0].contentWindow.tree;//h.find("iframe").contents();
var ids = [], names = [], nodes = [];
var ids = [], names = [], nodes = [],types =[];
if ("${checked}" == "true"){
nodes = tree.getCheckedNodes(true);
}else{
@@ -79,7 +79,6 @@
return false;
}//</c:if>
ids.push(nodes[i].id);//<c:if test="${showParentName}">
if (nodes[i].id != null ){
$.ajax({
type:"post",
@@ -103,15 +102,22 @@
}//</c:if><c:if test="${!showParentName}">
names.push(nodes[i].name);
if(nodes[i].type){
types.push(nodes[i].type);
}
//</c:if><c:if test="${!checked}">
break; // 如果为非复选框选择,则返回第一个选择 </c:if>
}
$("#${id}Id").val(ids.join(",").replace(/u_/ig,""));
if(types.length>0){
$("#${id}Id").attr('cfgtype',types.join(","));
}
$("#${id}Id").change();//手动触发change事件使Id的值得变化可以被监听到
$("#${id}Name").val(names.join(","));
}//<c:if test="${allowClear}">
else if (v=="clear"){
$("#${id}Id").val("");
$("#${id}Id").removeAttr('cfgtype');
$("#${id}Id").change();//手动触发change事件使Id的值得变化可以被监听到
$("#${id}Name").val("");
}//</c:if>

View File

@@ -51,6 +51,23 @@
}
}
});
if("${specificServiceCfg.parentType}"){
$("[name=cfgType]").each(function(){
$(this).attr("parent-type","${specificServiceCfg.parentType}");
});
}
$("#specificServiceCfgId").on("change",function(){
var data=$(this).attr("cfgtype");
if(data!=0){
$("[name=cfgType]").each(function(){
$(this).attr("parent-type",data);
if($(this).val()==data){
$(this).click();
}
})
}
});
});
</script>
</head>
@@ -99,7 +116,7 @@
<div class="col-md-4">
<c:set var="fatherName"><spring:message code="root_node"/></c:set>
<sys:treeselect id="specificServiceCfg" name="parent.specServiceId" value="${specificServiceCfg.parent.specServiceId}" labelName="parent.specServiceName" labelValue="${specificServiceCfg.parent.specServiceId eq '0'?fatherName:fns:getBySpecServiceId(specificServiceCfg.parent.specServiceId).specServiceName}"
title="" url="/specific/specificServiceCfg/treeData?isLeafShow=false" extId="${specificServiceCfg.specServiceId}" cssClass="required form-control"/>
title="" url="/specific/specificServiceCfg/treeData?isLeafShow=false&cfgType=0" extId="${specificServiceCfg.specServiceId}" cssClass="required form-control"/>
</div>
</div>
<div class="form-group">
@@ -134,7 +151,7 @@
<label class="col-md-3 control-label"><font color="red">*</font><spring:message code="cfg_type"/>:</label>
<div class="col-md-4">
<c:forEach items="${fns:getDictList('SPECIFIC_SERVICE_CFG_TYPE') }" var="dict">
<label class="radio-inline"><form:radiobutton path="cfgType" class="required" value="${dict.itemCode}"/><spring:message code="${dict.itemValue}"/></label>
<label class="radio-inline"><form:radiobutton path="cfgType" class="required checkParent" value="${dict.itemCode}"/><spring:message code="${dict.itemValue}"/></label>
</c:forEach>
</div>
</div>

View File

@@ -594,6 +594,13 @@ jQuery.validator.addMethod("areaIp",function(value, element) {
}
}
});
jQuery.validator.addMethod("checkParent",function(value, element) {
var parentType=$(element).attr("parent-type");
if(parentType&&parentType!=0&&parentType!=value){
return false;
}
return true;
});
//ip v4转数字
var ipToNumber=function (ip){
var num =0;

View File

@@ -56,6 +56,7 @@
ip_range: "ip Range",
timeout:"timeout",
areaIpPrefix:"Forbiden value: ",
domainCheck:"Please enter a valid domain."
domainCheck:"Please enter a valid domain.",
checkParent:"Configuration Type must match it's parent."
});
}(jQuery));

View File

@@ -54,6 +54,7 @@
ip_range: "ip Range",
timeout:"timeout",
areaIpPrefix:"Forbiden value: ",
domainCheck:"Please enter a valid domain."
domainCheck:"Please enter a valid domain.",
checkParent:"Configuration Type must match it's parent."
});
}(jQuery));

View File

@@ -58,6 +58,7 @@
ip_range: "ip Range",
timeout:"超时",
areaIpPrefix:"禁止使用的值: ",
domainCheck:"请输入有效的域名"
domainCheck:"请输入有效的域名",
checkParent:"配置类型必须与上级配置一致!"
});
}(jQuery));