Authored by qinchao

支持tcp探测

... ... @@ -14,6 +14,9 @@ public class JavaApiInfoReq extends PageRequest {
private String apiName;
//请求类型 http ,tcp
private String requestType;
private String apiUrl;
private String apiData;
... ...
... ... @@ -66,6 +66,15 @@ public class JavaAPICtrl {
@RequestMapping("/save")
@ResponseBody
public BaseResponse saveApiInfo(JavaApiInfoReq req) {
if("http".equals(req.getRequestType())){
if(StringUtils.isBlank(req.getApiUrl())){
return new BaseResponse(201,"url不能为空");
}
}else if("tcp".equals(req.getRequestType())){
if(StringUtils.isBlank(req.getApiUrl())&&req.getApiUrlCustom()==1){
return new BaseResponse(201,"url不能为空");
}
}
BaseResponse rep = httpClient.defaultPost(HttpUriContants.JAVA_API_SAVE, req, BaseResponse.class);
return rep;
}
... ...
... ... @@ -12,7 +12,18 @@
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> <span style="color:red">*</span>url:</label>
<label class="col-sm-2 control-label"> <span style="color:red">*</span>请求类型:</label>
<div class="col-sm-7">
<select id="requestType" name="requestType" class="form-control">
<option value="http">http</option>
<option value="tcp">tcp</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"> url:</label>
<div class="col-sm-8">
<input type="text" class="form-control" id="apiUrl" name="apiUrl" placeholder="输入url"
... ... @@ -28,7 +39,7 @@
</select>
</div>
<label class="col-sm-2 control-label"> <span style="color:red">*</span>请求:</label>
<label class="col-sm-2 control-label"> <span style="color:red">*</span>请求方式:</label>
<div class="col-sm-2">
<select id="apiReqMethod" name="apiReqMethod" class="form-control">
... ...
... ... @@ -600,6 +600,7 @@
onLoadSuccess: function (data) {
if (serviceId == 0) {
$("#javaInfoForm #apiName").val("");
$("#javaInfoForm #requestType").val("http");
$("#javaInfoForm #apiUrl").val("");
$("#javaInfoForm #apiData").val("");
$("#javaInfoForm #apiToggle").prop("checked", true)
... ... @@ -611,6 +612,7 @@
} else {
$("#javaInfoForm #serviceType").val(rowData.serviceType);
$("#javaInfoForm #apiName").val(rowData.apiName);
$("#javaInfoForm #requestType").val(rowData.requestType);
$("#javaInfoForm #apiUrl").val(rowData.apiUrl);
$("#javaInfoForm #apiData").val(rowData.apiData);
$("#javaInfoForm #apiToggle").prop("checked", (rowData.apiToggle == 1) ? true : false);
... ... @@ -641,6 +643,7 @@
'serviceId': serviceId,
'serviceType': $("#javaInfoForm #serviceType").val(),
'apiName': $("#javaInfoForm #apiName").val(),
'requestType': $("#javaInfoForm #requestType").find("option:selected").val(),
'apiUrl': $("#javaInfoForm #apiUrl").val(),
'apiData': $("#javaInfoForm #apiData").val(),
'apiToggle': $("#javaInfoForm #apiToggle").prop("checked") == true ? 1 : 0,
... ... @@ -650,7 +653,6 @@
'apiUrlCustom': $("#javaInfoForm #apiUrlCustom").prop("checked") == true ? 1 : 0
},
success: function (data) {
console.log("fffuck 1");
if (!data || data.code != 200) {
btn.removeAttr("disabled");
$("#javaInfoForm #messageAlert").alerts({
... ...