增加文件上传功能
This commit is contained in:
@@ -82,21 +82,31 @@
|
|||||||
<version>${springfox.swagger.version}</version>
|
<version>${springfox.swagger.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- 在线文档解析页面 -->
|
<!-- 在线文档解析页面 -->
|
||||||
<dependency>
|
<!--zyplayer-doc-core-->
|
||||||
<groupId>com.zyplayer</groupId>
|
|
||||||
<artifactId>zyplayer-doc-swagger</artifactId>
|
|
||||||
<version>${zyplayer.doc.swagger.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zyplayer</groupId>
|
<groupId>com.zyplayer</groupId>
|
||||||
<artifactId>zyplayer-doc-core</artifactId>
|
<artifactId>zyplayer-doc-core</artifactId>
|
||||||
<version>${zyplayer.doc.core.version}</version>
|
<version>${zyplayer.doc.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--zyplayer-doc-db-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zyplayer</groupId>
|
||||||
|
<artifactId>zyplayer-doc-db</artifactId>
|
||||||
|
<version>${zyplayer.doc.db.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!--zyplayer-doc-swagger-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zyplayer</groupId>
|
||||||
|
<artifactId>zyplayer-doc-swagger</artifactId>
|
||||||
|
<version>${zyplayer.doc.swagger.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<!--swagger-bootstrap-ui-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.xiaoymin</groupId>
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
<artifactId>swagger-bootstrap-ui</artifactId>
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
<version>${swagger.bootstrap.ui.version}</version>
|
<version>${swagger.bootstrap.ui.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--springfox-swagger-ui-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>io.springfox</groupId>
|
||||||
<artifactId>springfox-swagger-ui</artifactId>
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
@@ -118,12 +128,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.zyplayer</groupId>
|
|
||||||
<artifactId>zyplayer-doc-db</artifactId>
|
|
||||||
<version>${zyplayer.doc.db.version}</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -34,16 +34,11 @@ public class Application extends SpringBootServletInitializer {
|
|||||||
String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
String hostAddress = InetAddress.getLocalHost().getHostAddress();
|
||||||
String serverPort = env.getProperty("server.port");
|
String serverPort = env.getProperty("server.port");
|
||||||
String urlCtx = hostAddress + ":" + serverPort + "/" + contextPath;
|
String urlCtx = hostAddress + ":" + serverPort + "/" + contextPath;
|
||||||
// 三个UI的名字长度惊人的一致!肯定是知道我有强迫症!
|
|
||||||
logger.info("\n----------------------------------------------------------\n\t" +
|
logger.info("\n----------------------------------------------------------\n\t" +
|
||||||
"\t\t地址列表\n\t" +
|
"\t\t地址列表\n\t" +
|
||||||
"zyplayer-doc-swagger:http://{}document.html\n\t" +
|
|
||||||
"swagger-bootstrap-ui:http://{}doc.html\n\t" +
|
|
||||||
"springfox-swagger-ui:http://{}swagger-ui.html\n\t" +
|
|
||||||
"数据库文档管理地址:http://{}doc-db.html\n\t" +
|
|
||||||
"管理地址:http://{}statics/manage/home.html\n" +
|
"管理地址:http://{}statics/manage/home.html\n" +
|
||||||
"----------------------------------------------------------",
|
"----------------------------------------------------------",
|
||||||
urlCtx, urlCtx, urlCtx, urlCtx, urlCtx
|
urlCtx
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,11 @@
|
|||||||
<artifactId>zyplayer-doc-core</artifactId>
|
<artifactId>zyplayer-doc-core</artifactId>
|
||||||
<version>${zyplayer.doc.core.version}</version>
|
<version>${zyplayer.doc.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-fileupload</groupId>
|
||||||
|
<artifactId>commons-fileupload</artifactId>
|
||||||
|
<version>1.3.3</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
|
|||||||
@@ -52,14 +52,13 @@ public class MgDocumentController {
|
|||||||
*/
|
*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping(value = "/resourcesList")
|
@PostMapping(value = "/resourcesList")
|
||||||
public ResponseJson<Set<SwaggerResourcesInfoVo>> resourcesList() {
|
public ResponseJson<List<SwaggerResourcesInfoVo>> resourcesList() {
|
||||||
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
||||||
Set<SwaggerResourcesInfoVo> resourcesSet = new HashSet<>();
|
List<SwaggerResourcesInfoVo> resourcesList = new LinkedList<>();
|
||||||
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
||||||
List<SwaggerResourcesInfoVo> resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
||||||
resourcesSet.addAll(resourcesList);
|
|
||||||
}
|
}
|
||||||
return DocResponseJson.ok(resourcesSet);
|
return DocResponseJson.ok(resourcesList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,16 @@
|
|||||||
package com.zyplayer.doc.swagger.controller;
|
package com.zyplayer.doc.swagger.controller;
|
||||||
|
|
||||||
|
import cn.hutool.http.HttpRequest;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
|
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||||
|
import com.zyplayer.doc.swagger.controller.param.HttpRequestParam;
|
||||||
|
import com.zyplayer.doc.swagger.controller.vo.HttpCookieVo;
|
||||||
|
import com.zyplayer.doc.swagger.controller.vo.HttpHeaderVo;
|
||||||
|
import com.zyplayer.doc.swagger.controller.vo.HttpRequestVo;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.net.HttpCookie;
|
import java.net.HttpCookie;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -7,19 +18,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
|
||||||
import com.zyplayer.doc.swagger.controller.param.HttpRequestParam;
|
|
||||||
import com.zyplayer.doc.swagger.controller.vo.HttpCookieVo;
|
|
||||||
import com.zyplayer.doc.swagger.controller.vo.HttpHeaderVo;
|
|
||||||
import com.zyplayer.doc.swagger.controller.vo.HttpRequestVo;
|
|
||||||
|
|
||||||
import cn.hutool.http.HttpRequest;
|
|
||||||
import cn.hutool.http.HttpResponse;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 后台代理网络请求的控制器
|
* 后台代理网络请求的控制器
|
||||||
*
|
*
|
||||||
@@ -39,9 +37,7 @@ public class MgHttpRequestController {
|
|||||||
httpRequestVo.setStatus(response.getStatus());
|
httpRequestVo.setStatus(response.getStatus());
|
||||||
List<HttpCookie> cookies = response.getCookies();
|
List<HttpCookie> cookies = response.getCookies();
|
||||||
if (cookies != null && cookies.size() > 0) {
|
if (cookies != null && cookies.size() > 0) {
|
||||||
List<HttpCookieVo> cookie = cookies.stream().map(val -> {
|
List<HttpCookieVo> cookie = cookies.stream().map(val -> new HttpCookieVo(val.getName(), val.getValue())).collect(Collectors.toList());
|
||||||
return new HttpCookieVo(val.getName(), val.getValue());
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
httpRequestVo.setCookie(cookie);
|
httpRequestVo.setCookie(cookie);
|
||||||
}
|
}
|
||||||
Map<String, List<String>> headers = response.headers();
|
Map<String, List<String>> headers = response.headers();
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
package com.zyplayer.doc.swagger.controller.param;
|
package com.zyplayer.doc.swagger.controller.param;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.io.resource.BytesResource;
|
||||||
|
import cn.hutool.core.io.resource.MultiFileResource;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
@@ -10,6 +17,7 @@ import com.alibaba.fastjson.TypeReference;
|
|||||||
|
|
||||||
import cn.hutool.http.HttpRequest;
|
import cn.hutool.http.HttpRequest;
|
||||||
import cn.hutool.http.Method;
|
import cn.hutool.http.Method;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 请求参数对象
|
* 请求参数对象
|
||||||
@@ -23,6 +31,8 @@ public class HttpRequestParam {
|
|||||||
private String header;
|
private String header;
|
||||||
private String form;
|
private String form;
|
||||||
private String body;
|
private String body;
|
||||||
|
private String[] fileNames;
|
||||||
|
private MultipartFile[] files;
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
@@ -84,6 +94,28 @@ public class HttpRequestParam {
|
|||||||
if (formMap != null) {
|
if (formMap != null) {
|
||||||
request.form(formMap);
|
request.form(formMap);
|
||||||
}
|
}
|
||||||
|
// 拼文件
|
||||||
|
if (this.getFiles() != null && this.getFiles().length > 0) {
|
||||||
|
Map<String, MultiFileResource> bytesResourceMap = new HashMap<>();
|
||||||
|
for (int i = 0; i < this.getFiles().length; i++) {
|
||||||
|
try {
|
||||||
|
String fileName = this.getFileNames()[i].replace("[", "").replace("]", "");
|
||||||
|
MultipartFile file = this.getFiles()[i];
|
||||||
|
BytesResource bytesResource = new BytesResource(file.getBytes(), file.getOriginalFilename());
|
||||||
|
MultiFileResource multiFileResource = bytesResourceMap.get(fileName);
|
||||||
|
if (multiFileResource == null) {
|
||||||
|
multiFileResource = new MultiFileResource();
|
||||||
|
}
|
||||||
|
multiFileResource.add(bytesResource);
|
||||||
|
bytesResourceMap.put(fileName, multiFileResource);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, MultiFileResource> entry : bytesResourceMap.entrySet()) {
|
||||||
|
request.form(entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
if (StringUtils.isNotBlank(body) && request.getMethod() != Method.GET) {
|
if (StringUtils.isNotBlank(body) && request.getMethod() != Method.GET) {
|
||||||
request.body(body);
|
request.body(body);
|
||||||
}
|
}
|
||||||
@@ -193,4 +225,19 @@ public class HttpRequestParam {
|
|||||||
this.method = method;
|
this.method = method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MultipartFile[] getFiles() {
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFiles(MultipartFile[] files) {
|
||||||
|
this.files = files;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getFileNames() {
|
||||||
|
return fileNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileNames(String[] fileNames) {
|
||||||
|
this.fileNames = fileNames;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -212,6 +212,36 @@ function ajaxTemp(url, dataSentType, dataReceiveType, paramsStr, successFunction
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function postWithFile(url, paramsStr, successFunction, errorFunction, completeFunction, id) {
|
||||||
|
$.ajax({
|
||||||
|
url: url, // 后台处理程序
|
||||||
|
sync: false,
|
||||||
|
type: "POST", // 数据发送方式
|
||||||
|
dataType: "JSON", // 接受数据格式
|
||||||
|
data: eval(paramsStr),
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function (msg) {
|
||||||
|
if (typeof successFunction == "function") {
|
||||||
|
successFunction(msg, id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
beforeSend: function () {
|
||||||
|
|
||||||
|
},
|
||||||
|
complete: function (msg) {
|
||||||
|
if (typeof completeFunction == "function") {
|
||||||
|
completeFunction(msg, id);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (msg) {
|
||||||
|
if (typeof errorFunction == "function") {
|
||||||
|
errorFunction(msg, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取cookie
|
* 获取cookie
|
||||||
* @param name
|
* @param name
|
||||||
|
|||||||
@@ -45,17 +45,19 @@ $(document).ready(function(){
|
|||||||
var paramFormSend = {};
|
var paramFormSend = {};
|
||||||
var paramBodySend = $("[name=paramBody]").val();
|
var paramBodySend = $("[name=paramBody]").val();
|
||||||
var formToUrl = $("[name=formToUrl]").prop('checked') ? 1 : 0;
|
var formToUrl = $("[name=formToUrl]").prop('checked') ? 1 : 0;
|
||||||
var paramSendToServer = {};
|
// 组装空的表单对象
|
||||||
|
var formDataToServer = new FormData();
|
||||||
|
|
||||||
requestHeaderForm = serializeArrayToObj(requestHeaderForm);
|
requestHeaderForm = serializeArrayToObj(requestHeaderForm);
|
||||||
requestParamForm = serializeArrayToObj(requestParamForm);
|
requestParamForm = serializeArrayToObj(requestParamForm);
|
||||||
storeRequestParam.formToUrl = formToUrl;
|
storeRequestParam.formToUrl = formToUrl;
|
||||||
paramSendToServer.formToUrl = formToUrl;
|
formDataToServer.append("formToUrl", formToUrl);
|
||||||
if (isNotEmpty(paramBodySend)) {
|
if (isNotEmpty(paramBodySend)) {
|
||||||
try {
|
try {
|
||||||
paramBodySend = JSON.stringify(JSON.parse(paramBodySend));
|
paramBodySend = JSON.stringify(JSON.parse(paramBodySend));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
storeRequestParam.body = paramBodySend;
|
storeRequestParam.body = paramBodySend;
|
||||||
paramSendToServer.body = paramBodySend;
|
formDataToServer.append("body", paramBodySend);
|
||||||
// 替换path参数
|
// 替换path参数
|
||||||
Object.keys(requestParamForm).forEach(function (key) {
|
Object.keys(requestParamForm).forEach(function (key) {
|
||||||
postUrl = postUrl.replace("{" + key + "}", requestParamForm[key]);
|
postUrl = postUrl.replace("{" + key + "}", requestParamForm[key]);
|
||||||
@@ -74,13 +76,14 @@ $(document).ready(function(){
|
|||||||
postUrl = postUrl.replace("{" + key + "}", value);
|
postUrl = postUrl.replace("{" + key + "}", value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
storeRequestParam.form = paramFormSend;
|
storeRequestParam.form = paramFormSend;
|
||||||
// 表单参数是否拼在url上
|
// 表单参数是否拼在url上
|
||||||
if(formToUrl == 1) {
|
if(formToUrl == 1) {
|
||||||
postUrl += "?" + reqParamStr;
|
postUrl += "?" + reqParamStr;
|
||||||
paramFormSend = "";
|
paramFormSend = "";
|
||||||
} else {
|
} else {
|
||||||
paramSendToServer.form = JSON.stringify(paramFormSend);
|
formDataToServer.append("form", JSON.stringify(paramFormSend));
|
||||||
}
|
}
|
||||||
// 显示加载中图标
|
// 显示加载中图标
|
||||||
$(".send-request .icon").removeClass("hide");
|
$(".send-request .icon").removeClass("hide");
|
||||||
@@ -92,13 +95,23 @@ $(document).ready(function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
storeRequestParam.header = paramHeaderSend;
|
storeRequestParam.header = paramHeaderSend;
|
||||||
paramSendToServer.header = JSON.stringify(paramHeaderSend);
|
|
||||||
paramSendToServer.url = postUrl;
|
|
||||||
paramSendToServer.method = options;
|
|
||||||
//console.log(paramBodySend);
|
//console.log(paramBodySend);
|
||||||
var beforeSendTime = new Date().getTime();
|
var beforeSendTime = new Date().getTime();
|
||||||
|
// 拼装文件
|
||||||
|
var fileInput = $('#requestParamForm').find(".file-input");
|
||||||
|
for (var i = 0; i < fileInput.length; i++) {
|
||||||
|
var fileName = $(fileInput[i]).parents("tr").find("[name=paramName]").val();
|
||||||
|
for (var j = 0; j < fileInput[i].files.length; j++) {
|
||||||
|
formDataToServer.append('files', fileInput[i].files[j]);
|
||||||
|
formDataToServer.append('fileNames', fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
formDataToServer.append("header", JSON.stringify(paramHeaderSend));
|
||||||
|
formDataToServer.append("url", postUrl);
|
||||||
|
formDataToServer.append("method", options);
|
||||||
|
// debugger;
|
||||||
// 模拟请求开始
|
// 模拟请求开始
|
||||||
ajaxTemp("swagger-mg-ui/http/request", "post", "json", paramSendToServer, function(result){
|
postWithFile("swagger-mg-ui/http/request", formDataToServer, function(result){
|
||||||
var afterSendTime = new Date().getTime();
|
var afterSendTime = new Date().getTime();
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
var requestObj = result.data;
|
var requestObj = result.data;
|
||||||
@@ -361,6 +374,7 @@ function createOnlineDebugRequestParamFun(pRequestObj, requestParamObj, url) {
|
|||||||
|| (tempParam.paramIn == "path")
|
|| (tempParam.paramIn == "path")
|
||||||
|| (tempParam.paramIn == "body")
|
|| (tempParam.paramIn == "body")
|
||||||
|| (tempParam.paramIn == "form")
|
|| (tempParam.paramIn == "form")
|
||||||
|
|| (tempParam.paramIn == "formData")
|
||||||
|| isNotEmpty(tempParam.paramIn);
|
|| isNotEmpty(tempParam.paramIn);
|
||||||
if (paramInForm && !onlyUseLastForm) {
|
if (paramInForm && !onlyUseLastForm) {
|
||||||
//console.log(tempParam);
|
//console.log(tempParam);
|
||||||
@@ -374,10 +388,21 @@ function createOnlineDebugRequestParamFun(pRequestObj, requestParamObj, url) {
|
|||||||
formVal = getAutoFillValue(tempParam.paramType, key);
|
formVal = getAutoFillValue(tempParam.paramType, key);
|
||||||
}
|
}
|
||||||
if(formValueCount > 0) {
|
if(formValueCount > 0) {
|
||||||
$("#tabParamTypeForm table tbody").append(getParamTableTr(key, formVal, "", tempParam.paramDesc));
|
$("#tabParamTypeForm table tbody").append(getParamTableTr(key, formVal, "", tempParam.paramDesc, tempParam.paramType));
|
||||||
} else {
|
} else {
|
||||||
|
// 文件的input特殊处理
|
||||||
|
if(tempParam.paramType == 'file'){
|
||||||
|
$("#tabParamTypeForm table tbody .base input[name=paramValue]")
|
||||||
|
.attr("type", "file").attr("multiple", "multiple")
|
||||||
|
.addClass("file-input")
|
||||||
|
.val(formVal);
|
||||||
|
} else {
|
||||||
|
$("#tabParamTypeForm table tbody .base input[name=paramValue]")
|
||||||
|
.attr("type", "text")
|
||||||
|
.removeClass("file-input")
|
||||||
|
.val(formVal);
|
||||||
|
}
|
||||||
$("#tabParamTypeForm table tbody .base input[name=paramName]").val(key);
|
$("#tabParamTypeForm table tbody .base input[name=paramName]").val(key);
|
||||||
$("#tabParamTypeForm table tbody .base input[name=paramValue]").val(formVal);
|
|
||||||
$("#tabParamTypeForm table tbody .base input[name=paramValue]").attr("placeholder", getNotEmptyStr(tempParam.paramDesc));
|
$("#tabParamTypeForm table tbody .base input[name=paramValue]").attr("placeholder", getNotEmptyStr(tempParam.paramDesc));
|
||||||
}
|
}
|
||||||
$("#tabParamBody .nav li").eq(0).find("a").click();
|
$("#tabParamBody .nav li").eq(0).find("a").click();
|
||||||
@@ -462,8 +487,8 @@ function serializeArrayToObj(formArr) {
|
|||||||
for (var i = 0; i < formArr.length; i++) {
|
for (var i = 0; i < formArr.length; i++) {
|
||||||
if (formArr[i].name == "paramName" && i < formArr.length) {
|
if (formArr[i].name == "paramName" && i < formArr.length) {
|
||||||
var key = formArr[i].value;
|
var key = formArr[i].value;
|
||||||
var value = formArr[i+1].value;
|
var value = formArr[i + 1].value;
|
||||||
if(isNotEmpty(key)) {
|
if (isNotEmpty(key) && formArr[i + 1].name != "paramName") {
|
||||||
paramObj[key] = value;
|
paramObj[key] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -503,7 +528,7 @@ function bulkEditToTable(tableId, bulkEdit) {
|
|||||||
* @param valuePl
|
* @param valuePl
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function getParamTableTr(name, value, namePl, valuePl) {
|
function getParamTableTr(name, value, namePl, valuePl, paramType) {
|
||||||
name = getNotEmptyStr(name);
|
name = getNotEmptyStr(name);
|
||||||
namePl = getNotEmptyStr(namePl);
|
namePl = getNotEmptyStr(namePl);
|
||||||
value = getNotEmptyStr(value);
|
value = getNotEmptyStr(value);
|
||||||
@@ -514,12 +539,18 @@ function getParamTableTr(name, value, namePl, valuePl) {
|
|||||||
namePl = (typeof namePl === 'string') ? namePl.replace(regExp, """) : namePl;
|
namePl = (typeof namePl === 'string') ? namePl.replace(regExp, """) : namePl;
|
||||||
value = (typeof value === 'string') ? value.replace(regExp, """) : value;
|
value = (typeof value === 'string') ? value.replace(regExp, """) : value;
|
||||||
valuePl = (typeof valuePl === 'string') ? valuePl.replace(regExp, """) : valuePl;
|
valuePl = (typeof valuePl === 'string') ? valuePl.replace(regExp, """) : valuePl;
|
||||||
|
|
||||||
var resultStr =
|
var resultStr =
|
||||||
'<tr class="new">'
|
'<tr class="new">'
|
||||||
+'<td><input type="text" class="form-control" name="paramName" value="'+name+'" placeholder="'+namePl+'"></td>'
|
+'<td><input type="text" class="form-control" name="paramName" value="'+name+'" placeholder="'+namePl+'"></td>';
|
||||||
+'<td><input type="text" class="form-control" name="paramValue" value="'+value+'" placeholder="'+valuePl+'"></td>'
|
// 文件的input特殊处理
|
||||||
+'<td><i class="icon-times"></i></td>'
|
if(paramType == 'file') {
|
||||||
+'</tr>';
|
resultStr += '<td><input type="file" multiple class="form-control file-input" name="paramValue" value="'+value+'" placeholder="'+valuePl+'"></td>';
|
||||||
|
} else {
|
||||||
|
resultStr += '<td><input type="text" class="form-control" name="paramValue" value="'+value+'" placeholder="'+valuePl+'"></td>'
|
||||||
|
}
|
||||||
|
resultStr += '<td><i class="icon-times"></i></td>'
|
||||||
|
+'</tr>';
|
||||||
return resultStr;
|
return resultStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,8 +375,15 @@ $("#apiPathTree").on("click", ".show-doc", function(){
|
|||||||
var paramIn = getNotEmptyStr(tempParameters.in);
|
var paramIn = getNotEmptyStr(tempParameters.in);
|
||||||
var example = getNotEmptyStr(tempParameters.example, tempParameters.default);
|
var example = getNotEmptyStr(tempParameters.example, tempParameters.default);
|
||||||
if(isNotEmpty(tempParameters.items)) {
|
if(isNotEmpty(tempParameters.items)) {
|
||||||
htmlStr = paramName + "[0]";
|
if(tempParameters.items.$ref == '#/definitions/MultipartFile') {
|
||||||
htmlStrExample = paramName + "[0]";
|
htmlStr = paramName;
|
||||||
|
htmlStrExample = paramName;
|
||||||
|
paramType = 'file';
|
||||||
|
addRequestParamObj(requestParamObj, paramName, paramType, paramIn, required, paramDesc, example);
|
||||||
|
} else {
|
||||||
|
htmlStr = paramName + "[0]";
|
||||||
|
htmlStrExample = paramName + "[0]";
|
||||||
|
}
|
||||||
} else if(isNotEmpty(tempParameters.schema)) {
|
} else if(isNotEmpty(tempParameters.schema)) {
|
||||||
if("array" == tempParameters.schema.type) {
|
if("array" == tempParameters.schema.type) {
|
||||||
var responsesObj = definitionsDataMap.get(tempParameters.schema.items.$ref);
|
var responsesObj = definitionsDataMap.get(tempParameters.schema.items.$ref);
|
||||||
|
|||||||
Reference in New Issue
Block a user