1.serviceId改为自动获取,不能手动输入
2.修改时serviceId、动作、类型、表类型不可更改 3.增加单域、多域时关联表数量的限制
This commit is contained in:
@@ -16,7 +16,7 @@ public class SystemServiceInfo extends BaseEntity<SystemServiceInfo> {
|
||||
private String serviceDesc;//业务描述
|
||||
private Integer action;//业务动作 1:阻断;2:监测;5:FD白名单;6:监测白名单;7:FD监测白名单;8:灰名单;
|
||||
private Integer isValid;//有效标识 0:无效;1:有效;
|
||||
private Integer serviceType;//业务类型 1:常规(单域)业务配置;2:多域业务配置;
|
||||
private Integer serviceType;//业务类型 1:常规(单域)业务配置;2:多域业务配置;3.特定服务配置;
|
||||
private SysUser creator;
|
||||
private Date createTime;
|
||||
private SysUser editor;
|
||||
@@ -105,4 +105,13 @@ public class SystemServiceInfo extends BaseEntity<SystemServiceInfo> {
|
||||
return e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private Integer serviceIdPre;//辅助用,用来存放serviceId前四位以获得最新serviceId
|
||||
|
||||
public Integer getServiceIdPre() {
|
||||
return serviceIdPre;
|
||||
}
|
||||
public void setServiceIdPre(Integer serviceIdPre) {
|
||||
this.serviceIdPre = serviceIdPre;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.nis.web.controller.systemService;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -12,11 +14,13 @@ 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.ResponseBody;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.ServiceConfigInfo;
|
||||
import com.nis.domain.SystemServiceInfo;
|
||||
import com.nis.util.Collections3;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
@@ -30,8 +34,6 @@ public class SystemServiceController extends BaseController {
|
||||
@ModelAttribute
|
||||
public SystemServiceInfo get(Long id) {
|
||||
if (!StringUtil.isEmpty(id)){
|
||||
// SystemServiceInfo systemServiceInfo = new SystemServiceInfo();
|
||||
// systemServiceInfo.setId(id);
|
||||
return systemServiceService.get(id);
|
||||
}else{
|
||||
return new SystemServiceInfo();
|
||||
@@ -123,5 +125,44 @@ public class SystemServiceController extends BaseController {
|
||||
return "/systemService/list";
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "serviceIdValidate")
|
||||
public String serviceIdValidate(String serviceId, Long id) {
|
||||
List<SystemServiceInfo> list = systemServiceService.getSystemServiceByServiceId(serviceId);
|
||||
if (Collections3.isEmpty(list)) {
|
||||
return "true";
|
||||
} else {
|
||||
if (id != null) {
|
||||
if (list.get(0).getId() == id) {
|
||||
return "true";
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
} else {
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "newServiceId")
|
||||
public Integer getNewServiceId(Integer serviceIdPre) {
|
||||
if (serviceIdPre != null) {
|
||||
SystemServiceInfo ssi = new SystemServiceInfo();
|
||||
ssi.setServiceIdPre(serviceIdPre);
|
||||
List<SystemServiceInfo> list = systemServiceService.findList(ssi);
|
||||
if (!Collections3.isEmpty(list)) {
|
||||
Collections.sort(list, new Comparator<SystemServiceInfo>() {
|
||||
@Override
|
||||
public int compare(SystemServiceInfo arg0, SystemServiceInfo arg1) {
|
||||
return arg1.getServiceId().compareTo(arg0.getServiceId());
|
||||
}
|
||||
});
|
||||
return list.get(0).getServiceId() + 1;
|
||||
} else {
|
||||
return serviceIdPre * 100;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.nis.web.dao.systemService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import com.nis.domain.SystemServiceInfo;
|
||||
@@ -8,4 +10,6 @@ import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
@MyBatisDao
|
||||
public interface SystemServiceInfoDao extends CrudDao<SystemServiceInfo> {
|
||||
|
||||
List<SystemServiceInfo> getSystemServiceByServiceId(String serviceId);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
<if test="serviceType != null">
|
||||
and ssi.service_type=#{serviceType}
|
||||
</if>
|
||||
<if test="serviceIdPre != null">
|
||||
and service_id like concat(#{serviceIdPre}, '%')
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="get" resultMap="systemServiceInfoMap">
|
||||
@@ -87,6 +90,15 @@
|
||||
service_id=#{service_id} and is_valid=1
|
||||
</select>
|
||||
|
||||
<select id="getSystemServiceByServiceId" resultType="systemServiceInfo">
|
||||
select
|
||||
id
|
||||
from
|
||||
system_service_info
|
||||
where
|
||||
service_id=#{serviceId} and is_valid=1
|
||||
</select>
|
||||
|
||||
<insert id="insert">
|
||||
insert into system_service_info (
|
||||
service_id, service_name, service_desc, action, is_valid, service_type,
|
||||
|
||||
@@ -58,4 +58,8 @@ public class SystemServiceService extends CrudService<SystemServiceInfoDao, Syst
|
||||
|
||||
}
|
||||
|
||||
public List<SystemServiceInfo> getSystemServiceByServiceId(String serviceId) {
|
||||
return dao.getSystemServiceByServiceId(serviceId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
required:true
|
||||
},
|
||||
'serviceId':{
|
||||
required:true
|
||||
required:true,
|
||||
remote:"${ctx}/systemService/serviceIdValidate?id=" + encodeURIComponent($("#id").val())
|
||||
},
|
||||
'action':{
|
||||
required:true
|
||||
@@ -31,7 +32,8 @@
|
||||
required:'必填项'
|
||||
},
|
||||
'serviceId':{
|
||||
required:'必填项'
|
||||
required:'必填项',
|
||||
remote:'重复的serviceId'
|
||||
},
|
||||
'action':{
|
||||
required:'必填项'
|
||||
@@ -72,8 +74,78 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
changeType($("#serviceType").val(), $("#serviceType"));
|
||||
|
||||
//类型、动作不允许修改
|
||||
if ("${systemServiceInfo.id}") {
|
||||
$("#action").attr("disabled", true);
|
||||
$("#serviceType").attr("disabled", true);
|
||||
$("[name=tableType]").attr("disabled", true);
|
||||
}
|
||||
});
|
||||
|
||||
function changeType(v, obj) {
|
||||
if ($(obj).val() == '') {
|
||||
$("#addBtn").attr("disabled", true);
|
||||
} else if ($(obj).val() == '1') {
|
||||
if ($(".table-list").length > 1) {
|
||||
alert("单域业务只能关联一个表");
|
||||
$(obj).val(v);
|
||||
} else if ($(".table-list").length == 1) {
|
||||
$("#addBtn").attr("disabled", true);
|
||||
} else if ($(".table-list").length == 0) {
|
||||
$("#addBtn").attr("disabled", false);
|
||||
}
|
||||
} else if ($(obj).val() == '2') {
|
||||
$("#addBtn").attr("disabled", false);
|
||||
} else if ($(obj).val() == '3') {
|
||||
if ($(".table-list").length > 1) {
|
||||
alert("特定服务只能关联一个表");
|
||||
$(obj).val(v);
|
||||
} else if ($(".table-list").length == 1) {
|
||||
$("#addBtn").attr("disabled", true);
|
||||
} else if ($(".table-list").length == 0) {
|
||||
$("#addBtn").attr("disabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
autoServiceId();
|
||||
}
|
||||
|
||||
//自动获取serviceId
|
||||
function autoServiceId() {
|
||||
var type = $("[name=tableType]").val();
|
||||
var action = $("#action").val();
|
||||
var serviceIdPre;
|
||||
if ($("#serviceType").val() == "1" && action && type) {
|
||||
serviceIdPre = type + "0" + (action < 10 ? ("0" + action) : action);
|
||||
} else if ($("#serviceType").val() == "2" && action) {
|
||||
type = "60";
|
||||
serviceIdPre = type + (action < 10 ? ("0" + action) : action);
|
||||
} else if ($("#serviceType").val() == "3" && action) {
|
||||
type = "50";
|
||||
serviceIdPre = type + (action < 10 ? ("0" + action) : action);
|
||||
} else {
|
||||
serviceIdPre = "";
|
||||
}
|
||||
|
||||
if (serviceIdPre) {
|
||||
$.ajax({
|
||||
type:"get",
|
||||
url:"${ctx}/systemService/newServiceId?serviceIdPre=" + serviceIdPre,
|
||||
dataType:"text",
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
$("#serviceIdInput").val(data);
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$("#serviceIdInput").val("");
|
||||
}
|
||||
}
|
||||
|
||||
function addDatatable() {
|
||||
$("#datatables").append(
|
||||
'<div class="table-list col-md-10">' +
|
||||
@@ -84,7 +156,7 @@
|
||||
'<span><input class="child-required form-control child-input" name="tableName"/></span> ' +
|
||||
'<span class="child-label"><font color="red">*</font>表类型:</span> ' +
|
||||
'<span> ' +
|
||||
'<select class="child-required" name="tableType"> ' +
|
||||
'<select class="child-required" name="tableType" onchange="autoServiceId()"> ' +
|
||||
'<option value="">请选择</option>' +
|
||||
'<option value="1">IP</option>' +
|
||||
'<option value="2">字符串</option>' +
|
||||
@@ -102,15 +174,21 @@
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
if ($("#serviceType").val() == '1' || $("#serviceType").val() == '3') {
|
||||
$("#addBtn").attr("disabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
function del(obj) {
|
||||
$(obj).parent().parent().find("[name=sciIsValid]").val("0");
|
||||
$(obj).parent().parent().css("display", "none");
|
||||
$(obj).parent().parent().css("display", "none").attr("class", "table-delete");
|
||||
changeType($("#serviceType").val(), $("#serviceType"));
|
||||
}
|
||||
|
||||
function del2(obj) {
|
||||
$(obj).parent().parent().remove();
|
||||
changeType($("#serviceType").val(), $("#serviceType"));
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -138,7 +216,7 @@
|
||||
|
||||
<!-- BEGIN FORM-->
|
||||
<form:form id="inputForm" modelAttribute="systemServiceInfo" action="${ctx}/systemService/save" method="post" class="form-horizontal">
|
||||
<form:hidden path="id"/>
|
||||
<form:hidden path="id" id="id"/>
|
||||
<sys:message content="${message}"/>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -148,17 +226,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label"><font color="red">*</font>业务ID:</label>
|
||||
<div class="col-md-4">
|
||||
<form:input path="serviceId" htmlEscape="false" maxlength="30" class="required form-control"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label"><font color="red">*</font>动作:</label>
|
||||
<div class="col-md-4">
|
||||
<form:select path="action" class="required form-control">
|
||||
<form:select id="action" path="action" class="required form-control" onchange="autoServiceId()">
|
||||
<form:option value="">请选择</form:option>
|
||||
<form:option value="1">阻断</form:option>
|
||||
<form:option value="2">监测</form:option>
|
||||
@@ -173,10 +244,11 @@
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label"><font color="red">*</font>类型:</label>
|
||||
<div class="col-md-4">
|
||||
<form:select path="serviceType" class="required form-control">
|
||||
<form:select id="serviceType" path="serviceType" class="required form-control" onclick="now=this.value" onchange="changeType(now, this)">
|
||||
<form:option value="">请选择</form:option>
|
||||
<form:option value="1">单域</form:option>
|
||||
<form:option value="2">多域</form:option>
|
||||
<form:option value="3">特定服务</form:option>
|
||||
</form:select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -186,7 +258,7 @@
|
||||
<div class="col-md-8" id="datatables">
|
||||
<shiro:hasPermission name="system:service:edit">
|
||||
<div>
|
||||
<button type="button" class="btn btn-default" onclick="addDatatable()">增加</button>
|
||||
<button id="addBtn" type="button" class="btn btn-default" onclick="addDatatable()">增加</button>
|
||||
<label for="childTableFlag" class="error" style="display:none">有未填项</label>
|
||||
</div>
|
||||
</shiro:hasPermission>
|
||||
@@ -223,6 +295,13 @@
|
||||
</c:forEach>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label"><font color="red">*</font>业务ID:</label>
|
||||
<div class="col-md-4">
|
||||
<input id="serviceIdInput" class="required form-control" name="serviceId" value="${systemServiceInfo.serviceId }" readonly="readonly">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label"><font color="red">*</font>描述:</label>
|
||||
|
||||
@@ -74,6 +74,7 @@ function deleteService(id) {
|
||||
<form:option value="">请选择</form:option>
|
||||
<form:option value="1">单域</form:option>
|
||||
<form:option value="2">多域</form:option>
|
||||
<form:option value="3">特定服务</form:option>
|
||||
</form:select>
|
||||
</span>
|
||||
|
||||
@@ -121,6 +122,7 @@ function deleteService(id) {
|
||||
<td>
|
||||
<c:if test="${1 eq ssi.serviceType }">单域</c:if>
|
||||
<c:if test="${2 eq ssi.serviceType }">多域</c:if>
|
||||
<c:if test="${3 eq ssi.serviceType }">特定服务</c:if>
|
||||
</td>
|
||||
<td>${ssi.creator.loginId }</td>
|
||||
<td><fmt:formatDate value="${ssi.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
|
||||
|
||||
Reference in New Issue
Block a user