debug参数展示,基本功能开发
This commit is contained in:
@@ -5,6 +5,8 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.zyplayer.doc.manage.framework.interceptor.RequestInfoInterceptor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.format.FormatterRegistry;
|
import org.springframework.format.FormatterRegistry;
|
||||||
@@ -12,6 +14,7 @@ import org.springframework.format.datetime.DateFormatter;
|
|||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
import org.springframework.http.converter.HttpMessageConverter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||||
@@ -22,6 +25,9 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
|||||||
@Configuration
|
@Configuration
|
||||||
public class WebMvcConfig implements WebMvcConfigurer {
|
public class WebMvcConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
RequestInfoInterceptor requestInfoInterceptor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addFormatters(FormatterRegistry registry) {
|
public void addFormatters(FormatterRegistry registry) {
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
@@ -49,4 +55,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
converters.add(0, fastJsonHttpMessageConverter());
|
converters.add(0, fastJsonHttpMessageConverter());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(requestInfoInterceptor).excludePathPatterns("/**/*.js", "/**/*.css", "/**/*.png",
|
||||||
|
"/**/*.gif", "/**/*.jpg", "/**/*.jpeg", "/**/fonts/*");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,81 @@
|
|||||||
Target Server Version : 50624
|
Target Server Version : 50624
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 27/11/2018 20:19:45
|
Date: 12/12/2018 14:29:09
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
SET FOREIGN_KEY_CHECKS = 0;
|
SET FOREIGN_KEY_CHECKS = 0;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for auth_info
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `auth_info`;
|
||||||
|
CREATE TABLE `auth_info` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`auth_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限名',
|
||||||
|
`auth_desc` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '权限说明',
|
||||||
|
`can_edit` tinyint(4) NULL DEFAULT 1 COMMENT '是否可编辑 0=否 1=是',
|
||||||
|
`create_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of auth_info
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `auth_info` VALUES (1, 'DOC_ALL', '文档查看权', 0, 1, '2018-12-01 11:40:42');
|
||||||
|
INSERT INTO `auth_info` VALUES (2, 'AUTH_MANAGE', '权限管理权', 0, 1, '2018-12-01 11:40:42');
|
||||||
|
INSERT INTO `auth_info` VALUES (3, 'AUTH_ASSIGN', '权限分配权', 0, 1, '2018-12-01 11:40:42');
|
||||||
|
INSERT INTO `auth_info` VALUES (4, 'USER_MANAGE', '用户管理权', 0, 1, '2018-12-01 11:40:42');
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for user_auth
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `user_auth`;
|
||||||
|
CREATE TABLE `user_auth` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户ID',
|
||||||
|
`auth_id` bigint(20) NULL DEFAULT NULL COMMENT '权限ID',
|
||||||
|
`create_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建用户ID',
|
||||||
|
`update_uid` bigint(20) NULL DEFAULT NULL COMMENT '更新用户ID',
|
||||||
|
`del_flag` tinyint(4) NULL DEFAULT 0 COMMENT '是否删除 0=未删除 1=已删除',
|
||||||
|
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of user_auth
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `user_auth` VALUES (1, 1, 1, 1, 1, 0, '2018-12-01 11:41:13', '2018-12-01 11:41:13');
|
||||||
|
INSERT INTO `user_auth` VALUES (2, 1, 2, 1, 1, 0, '2018-12-01 11:41:13', '2018-12-01 11:41:13');
|
||||||
|
INSERT INTO `user_auth` VALUES (3, 1, 3, 1, 1, 0, '2018-12-01 11:41:13', '2018-12-01 11:41:13');
|
||||||
|
INSERT INTO `user_auth` VALUES (4, 1, 4, 1, 1, 0, '2018-12-01 11:41:13', '2018-12-01 11:41:13');
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Table structure for user_info
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `user_info`;
|
||||||
|
CREATE TABLE `user_info` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||||
|
`user_no` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户编号,用于登录等',
|
||||||
|
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '密码',
|
||||||
|
`user_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户名',
|
||||||
|
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
|
||||||
|
`avatar` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '头像',
|
||||||
|
`del_flag` tinyint(4) NULL DEFAULT 0 COMMENT '是否删除 0=未删除 1=已删除',
|
||||||
|
`create_uid` bigint(20) NULL DEFAULT NULL COMMENT '创建人',
|
||||||
|
`creation_time` datetime(0) NULL DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`update_time` datetime(0) NULL DEFAULT NULL COMMENT '修改时间',
|
||||||
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
|
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of user_info
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `user_info` VALUES (1, 'zyplayer', 'e10adc3949ba59abbe56e057f20f883e', '暮光:城中城', '806783409@qq.com', NULL, 0, NULL, '2018-12-01 11:37:39', NULL);
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for zyplayer_storage
|
-- Table structure for zyplayer_storage
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
@@ -24,10 +93,15 @@ DROP TABLE IF EXISTS `zyplayer_storage`;
|
|||||||
CREATE TABLE `zyplayer_storage` (
|
CREATE TABLE `zyplayer_storage` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`doc_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
`doc_key` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
`doc_value` varchar(2048) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
`doc_value` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL,
|
||||||
`creation_time` datetime NULL DEFAULT NULL,
|
`creation_time` datetime(0) NULL DEFAULT NULL,
|
||||||
|
`update_time` datetime(0) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`) USING BTREE,
|
PRIMARY KEY (`id`) USING BTREE,
|
||||||
UNIQUE INDEX `key`(`doc_key`) USING BTREE COMMENT 'key唯一索引'
|
UNIQUE INDEX `key`(`doc_key`) USING BTREE COMMENT 'key唯一索引'
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- Records of zyplayer_storage
|
||||||
|
-- ----------------------------
|
||||||
|
|
||||||
SET FOREIGN_KEY_CHECKS = 1;
|
SET FOREIGN_KEY_CHECKS = 1;
|
||||||
|
|||||||
@@ -1,17 +1,15 @@
|
|||||||
package com.zyplayer.doc.swagger.controller;
|
package com.zyplayer.doc.swagger.controller;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import cn.hutool.http.HttpRequest;
|
||||||
import java.util.Arrays;
|
import com.alibaba.fastjson.JSON;
|
||||||
import java.util.HashMap;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
import java.util.HashSet;
|
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||||
import java.util.LinkedList;
|
import com.zyplayer.doc.core.json.ResponseJson;
|
||||||
import java.util.List;
|
import com.zyplayer.doc.swagger.controller.vo.SwaggerResourcesInfoVo;
|
||||||
import java.util.Map;
|
import com.zyplayer.doc.swagger.framework.configuration.EnableSwaggerMgUi;
|
||||||
import java.util.Set;
|
import com.zyplayer.doc.swagger.framework.configuration.SpringContextUtil;
|
||||||
|
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -21,19 +19,13 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.TypeReference;
|
|
||||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
|
||||||
import com.zyplayer.doc.core.json.ResponseJson;
|
|
||||||
import com.zyplayer.doc.swagger.framework.configuration.EnableSwaggerMgUi;
|
|
||||||
import com.zyplayer.doc.swagger.framework.configuration.SpringContextUtil;
|
|
||||||
import com.zyplayer.doc.swagger.framework.constant.StorageKeys;
|
|
||||||
import com.zyplayer.doc.swagger.framework.service.MgStorageService;
|
|
||||||
|
|
||||||
import cn.hutool.http.HttpRequest;
|
|
||||||
import springfox.documentation.swagger.web.SwaggerResource;
|
import springfox.documentation.swagger.web.SwaggerResource;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文档控制器
|
* 文档控制器
|
||||||
*
|
*
|
||||||
@@ -58,11 +50,11 @@ public class MgDocumentController {
|
|||||||
*/
|
*/
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@PostMapping(value = "/resourcesList")
|
@PostMapping(value = "/resourcesList")
|
||||||
public ResponseJson<Set<String>> resourcesList() {
|
public ResponseJson<Set<SwaggerResourcesInfoVo>> resourcesList() {
|
||||||
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
||||||
Set<String> resourcesSet = new HashSet<>();
|
Set<SwaggerResourcesInfoVo> resourcesSet = new HashSet<>();
|
||||||
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
||||||
List<String> resourcesList = JSON.parseArray(swaggerResourcesStr, String.class);
|
List<SwaggerResourcesInfoVo> resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
||||||
resourcesSet.addAll(resourcesList);
|
resourcesSet.addAll(resourcesList);
|
||||||
}
|
}
|
||||||
return DocResponseJson.ok(resourcesSet);
|
return DocResponseJson.ok(resourcesSet);
|
||||||
@@ -81,16 +73,18 @@ public class MgDocumentController {
|
|||||||
boolean needRestorage = true;
|
boolean needRestorage = true;
|
||||||
String choiseDocList = request.getParameter("choiseDocList");
|
String choiseDocList = request.getParameter("choiseDocList");
|
||||||
// 转成set,防止重复
|
// 转成set,防止重复
|
||||||
Set<String> resourcesSet = new HashSet<>();
|
Set<SwaggerResourcesInfoVo> resourcesSet = new HashSet<>();
|
||||||
Set<String> swaggerDocsDeleteSet = new HashSet<>();
|
Set<String> swaggerDocsDeleteSet = new HashSet<>();
|
||||||
if (StringUtils.isNotBlank(choiseDocList)) {
|
if (StringUtils.isNotBlank(choiseDocList)) {
|
||||||
needRestorage = false;// 选择的则不再存入
|
needRestorage = false;// 选择的则不再存入
|
||||||
resourcesSet.addAll(Arrays.asList(choiseDocList.split(",")));
|
for (String url : choiseDocList.split(",")) {
|
||||||
|
resourcesSet.add(new SwaggerResourcesInfoVo(url));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
||||||
String swaggerDocsDeleteStr = storageService.get(StorageKeys.SWAGGER_DOCS_DELETE_LIST);
|
String swaggerDocsDeleteStr = storageService.get(StorageKeys.SWAGGER_DOCS_DELETE_LIST);
|
||||||
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
||||||
List<String> resourcesList = JSON.parseArray(swaggerResourcesStr, String.class);
|
List<SwaggerResourcesInfoVo> resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
||||||
resourcesSet.addAll(resourcesList);
|
resourcesSet.addAll(resourcesList);
|
||||||
} else {
|
} else {
|
||||||
// 默认加上自身的文档
|
// 默认加上自身的文档
|
||||||
@@ -115,15 +109,17 @@ public class MgDocumentController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (swaggerMgUi == null) {
|
if (swaggerMgUi == null) {
|
||||||
resourcesSet.add(serverPath + "/swagger-resources");
|
resourcesSet.add(new SwaggerResourcesInfoVo(serverPath + "/swagger-resources"));
|
||||||
} else {
|
} else {
|
||||||
if (swaggerMgUi.selfDoc()) {
|
if (swaggerMgUi.selfDoc()) {
|
||||||
resourcesSet.add(serverPath + "/swagger-resources");
|
resourcesSet.add(new SwaggerResourcesInfoVo(serverPath + "/swagger-resources"));
|
||||||
}
|
}
|
||||||
// 启动后第一次访问没有数据情况下需要加载进来的swagger-resources地址
|
// 启动后第一次访问没有数据情况下需要加载进来的swagger-resources地址
|
||||||
String[] defaultResources = swaggerMgUi.defaultResources();
|
String[] defaultResources = swaggerMgUi.defaultResources();
|
||||||
if (defaultResources != null && defaultResources.length > 0) {
|
if (defaultResources != null && defaultResources.length > 0) {
|
||||||
resourcesSet.addAll(Arrays.asList(defaultResources));
|
for (String url : defaultResources) {
|
||||||
|
resourcesSet.add(new SwaggerResourcesInfoVo(url));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,8 +130,9 @@ public class MgDocumentController {
|
|||||||
}
|
}
|
||||||
List<Map<String, Object>> swaggerResourceList = new LinkedList<>();
|
List<Map<String, Object>> swaggerResourceList = new LinkedList<>();
|
||||||
List<String> swaggerResourceStrList = new LinkedList<>();
|
List<String> swaggerResourceStrList = new LinkedList<>();
|
||||||
for (String resourcesUrl : resourcesSet) {
|
for (SwaggerResourcesInfoVo resourcesInfoVo : resourcesSet) {
|
||||||
List<SwaggerResource> resourceList = null;
|
List<SwaggerResource> resourceList = null;
|
||||||
|
String resourcesUrl = resourcesInfoVo.getUrl();
|
||||||
try {
|
try {
|
||||||
String resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
String resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
||||||
resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
||||||
@@ -208,36 +205,35 @@ public class MgDocumentController {
|
|||||||
swaggerDocsDeleteSet.addAll(swaggerDocsDeleteList);
|
swaggerDocsDeleteSet.addAll(swaggerDocsDeleteList);
|
||||||
}
|
}
|
||||||
// 转成set,防止重复
|
// 转成set,防止重复
|
||||||
Set<String> resourcesSet = new HashSet<>();
|
Set<SwaggerResourcesInfoVo> resourcesSet = new HashSet<>();
|
||||||
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
||||||
List<String> resourcesList = JSON.parseArray(swaggerResourcesStr, String.class);
|
List<SwaggerResourcesInfoVo> resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
||||||
resourcesSet.addAll(resourcesList);
|
resourcesSet.addAll(resourcesList);
|
||||||
}
|
}
|
||||||
String resourcesStr = null;
|
|
||||||
try {
|
try {
|
||||||
// resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
String resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
||||||
// List<SwaggerResource> resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
List<SwaggerResource> resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
||||||
// if (resourceList == null || resourceList.isEmpty()) {
|
if (resourceList == null || resourceList.isEmpty()) {
|
||||||
// return DocResponseJson.warn("该地址未找到文档");
|
return DocResponseJson.warn("该地址未找到文档");
|
||||||
// }
|
}
|
||||||
// // 重新加入的时候把之前的已删除的回恢复
|
// 重新加入的时候把之前的已删除的回恢复
|
||||||
// String resourcesDomain = resourcesUrl.substring(0, resourcesUrl.lastIndexOf("/") + 1);
|
String resourcesDomain = resourcesUrl.substring(0, resourcesUrl.lastIndexOf("/") + 1);
|
||||||
// for (SwaggerResource swaggerResource : resourceList) {
|
for (SwaggerResource swaggerResource : resourceList) {
|
||||||
// String location = swaggerResource.getLocation();
|
String location = swaggerResource.getLocation();
|
||||||
// // 最后一个斜杠在resourcesUrl中已经加上,替换掉后面的防止两根斜杠
|
// 最后一个斜杠在resourcesUrl中已经加上,替换掉后面的防止两根斜杠
|
||||||
// location = location.startsWith("/") ? location.replaceFirst("/", "") : location;
|
location = location.startsWith("/") ? location.replaceFirst("/", "") : location;
|
||||||
// if (location.indexOf("?") >= 0) {
|
if (location.indexOf("?") >= 0) {
|
||||||
// try {
|
try {
|
||||||
// String encode = URLEncoder.encode(swaggerResource.getName(), "utf-8");
|
String encode = URLEncoder.encode(swaggerResource.getName(), "utf-8");
|
||||||
// location = location.substring(0, location.lastIndexOf("?")) + "?group=" + encode;
|
location = location.substring(0, location.lastIndexOf("?")) + "?group=" + encode;
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// location = resourcesDomain + location;
|
location = resourcesDomain + location;
|
||||||
// swaggerDocsDeleteSet.remove(location);
|
swaggerDocsDeleteSet.remove(location);
|
||||||
// }
|
}
|
||||||
resourcesSet.add(resourcesUrl);
|
resourcesSet.add(new SwaggerResourcesInfoVo(resourcesUrl));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// 暂不想支持直接添加地址
|
// 暂不想支持直接添加地址
|
||||||
// try {
|
// try {
|
||||||
@@ -263,6 +259,54 @@ public class MgDocumentController {
|
|||||||
return DocResponseJson.ok();
|
return DocResponseJson.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加/swagger-resources地址
|
||||||
|
*
|
||||||
|
* @author 暮光:城中城
|
||||||
|
* @since 2018年8月21日
|
||||||
|
* @param resourcesUrl swagger-resources地址
|
||||||
|
* @return 添加结果
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "/syncDocData")
|
||||||
|
public ResponseJson<Object> syncDocData(String resourcesUrl) {
|
||||||
|
String swaggerResourcesStr = storageService.get(StorageKeys.SWAGGER_RESOURCES_LIST);
|
||||||
|
// 转成set,防止重复
|
||||||
|
Set<SwaggerResourcesInfoVo> resourcesSet = new HashSet<>();
|
||||||
|
if (StringUtils.isNotBlank(swaggerResourcesStr)) {
|
||||||
|
List<SwaggerResourcesInfoVo> resourcesList = JSON.parseArray(swaggerResourcesStr, SwaggerResourcesInfoVo.class);
|
||||||
|
resourcesSet.addAll(resourcesList);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String resourcesStr = HttpRequest.get(resourcesUrl).timeout(3000).execute().body();
|
||||||
|
List<SwaggerResource> resourceList = JSON.parseArray(resourcesStr, SwaggerResource.class);
|
||||||
|
if (resourceList == null || resourceList.isEmpty()) {
|
||||||
|
return DocResponseJson.warn("该地址未找到文档");
|
||||||
|
}
|
||||||
|
// 重新加入的时候把之前的已删除的回恢复
|
||||||
|
String resourcesDomain = resourcesUrl.substring(0, resourcesUrl.lastIndexOf("/") + 1);
|
||||||
|
for (SwaggerResource swaggerResource : resourceList) {
|
||||||
|
String location = swaggerResource.getLocation();
|
||||||
|
// 最后一个斜杠在resourcesUrl中已经加上,替换掉后面的防止两根斜杠
|
||||||
|
location = location.startsWith("/") ? location.replaceFirst("/", "") : location;
|
||||||
|
if (location.indexOf("?") >= 0) {
|
||||||
|
try {
|
||||||
|
String encode = URLEncoder.encode(swaggerResource.getName(), "utf-8");
|
||||||
|
location = location.substring(0, location.lastIndexOf("?")) + "?group=" + encode;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
location = resourcesDomain + location;
|
||||||
|
}
|
||||||
|
resourcesSet.add(new SwaggerResourcesInfoVo(resourcesUrl));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取文档失败:{},{}", resourcesUrl, e.getMessage());
|
||||||
|
return DocResponseJson.warn("该地址查找文档失败");
|
||||||
|
}
|
||||||
|
storageService.put(StorageKeys.SWAGGER_RESOURCES_LIST, JSON.toJSONString(resourcesSet));
|
||||||
|
return DocResponseJson.ok();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除/v2/api-docs
|
* 删除/v2/api-docs
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -13,4 +13,6 @@ public class StorageKeys {
|
|||||||
public static final String SWAGGER_DOCS_DELETE_LIST = "swagger-docs-delete-list";
|
public static final String SWAGGER_DOCS_DELETE_LIST = "swagger-docs-delete-list";
|
||||||
// 所有详细文档地址
|
// 所有详细文档地址
|
||||||
public static final String SWAGGER_LOCATION_LIST = "swagger-location-list";
|
public static final String SWAGGER_LOCATION_LIST = "swagger-location-list";
|
||||||
|
// 文档的离线数据key
|
||||||
|
public static final String SWAGGER_OFFLINE_DOC_START = "swagger-offline-doc-";
|
||||||
}
|
}
|
||||||
@@ -383,6 +383,7 @@
|
|||||||
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-tag.js"></script>
|
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-tag.js"></script>
|
||||||
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-debug.js"></script>
|
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-debug.js"></script>
|
||||||
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-export.js"></script>
|
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-export.js"></script>
|
||||||
|
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui-cache-keys.js"></script>
|
||||||
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui.js"></script>
|
<script type="text/javascript" src="webjars/mg-ui/js/mg-ui.js"></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,5 @@ var cacheKeys = {
|
|||||||
swaggerResourcesList: 'swagger-resources-list',
|
swaggerResourcesList: 'swagger-resources-list',
|
||||||
globalParamList: 'zyplayer-doc-global-param-list',
|
globalParamList: 'zyplayer-doc-global-param-list',
|
||||||
pRequestObjStart: 'p-request-obj-',
|
pRequestObjStart: 'p-request-obj-',
|
||||||
|
pSimulationResponse: 'p-simulation-response',
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ $(document).ready(function(){
|
|||||||
ajaxTemp("swagger-mg-ui/http/request", "post", "json", paramSendToServer, function(result){
|
ajaxTemp("swagger-mg-ui/http/request", "post", "json", paramSendToServer, function(result){
|
||||||
//console.log(result);
|
//console.log(result);
|
||||||
var requestObj = result.data;
|
var requestObj = result.data;
|
||||||
setStorage('p-request-obj-' + docUrl, storeRequestParam);
|
setStorage(cacheKeys.pRequestObjStart + docUrl, storeRequestParam);
|
||||||
var afterSendTime = new Date().getTime();
|
var afterSendTime = new Date().getTime();
|
||||||
$("#httpRequestStatus").text(requestObj.status);
|
$("#httpRequestStatus").text(requestObj.status);
|
||||||
$("#httpRequestTime").text((afterSendTime - beforSendTime) + "ms");
|
$("#httpRequestTime").text((afterSendTime - beforSendTime) + "ms");
|
||||||
@@ -188,7 +188,7 @@ $(document).ready(function(){
|
|||||||
*/
|
*/
|
||||||
$(".tab-online-debug-page").on("click", ".del-all-param", function(){
|
$(".tab-online-debug-page").on("click", ".del-all-param", function(){
|
||||||
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
||||||
if(!key.startWith('p-request-obj-')) {
|
if(!key.startWith(cacheKeys.pRequestObjStart)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$.zui.store.remove(key);
|
$.zui.store.remove(key);
|
||||||
@@ -212,7 +212,7 @@ $(document).ready(function(){
|
|||||||
var value = $("#simulationResultText").val();
|
var value = $("#simulationResultText").val();
|
||||||
value = getNotEmptyStr(value, "");
|
value = getNotEmptyStr(value, "");
|
||||||
var docUrl = $("#simulationResultUrl").text();
|
var docUrl = $("#simulationResultUrl").text();
|
||||||
setStorage('p-simulation-response-' + docUrl, value, function() {
|
setStorage(cacheKeys.pSimulationResponse + docUrl, value, function() {
|
||||||
Toast.warn("提交成功!");
|
Toast.warn("提交成功!");
|
||||||
}, function(msg) {
|
}, function(msg) {
|
||||||
Toast.error("提交失败!" + msg);
|
Toast.error("提交失败!" + msg);
|
||||||
@@ -223,7 +223,7 @@ $(document).ready(function(){
|
|||||||
*/
|
*/
|
||||||
$("#simulationResultGet").click(function(){
|
$("#simulationResultGet").click(function(){
|
||||||
var docUrl = $("#simulationResultUrl").text();
|
var docUrl = $("#simulationResultUrl").text();
|
||||||
getStorage('p-simulation-response-' + docUrl, function(data){
|
getStorage(cacheKeys.pSimulationResponse + docUrl, function(data){
|
||||||
$("#simulationResultText").val(data);
|
$("#simulationResultText").val(data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -236,7 +236,7 @@ $(document).ready(function(){
|
|||||||
function createOnlineDebugParamTable() {
|
function createOnlineDebugParamTable() {
|
||||||
$("#onlineDebugParamTable tbody").empty();
|
$("#onlineDebugParamTable tbody").empty();
|
||||||
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
$.zui.store.forEach(function(key, value) {// 遍历所有本地存储的条目
|
||||||
if(!key.startWith('p-request-obj-')) {
|
if(!key.startWith(cacheKeys.pRequestObjStart)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var newKey = key.substring(14, key.length);
|
var newKey = key.substring(14, key.length);
|
||||||
@@ -257,7 +257,7 @@ function createOnlineDebugParamTable() {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function createOnlineDebugRequestParam(requestParamObj, url) {
|
function createOnlineDebugRequestParam(requestParamObj, url) {
|
||||||
getStorage('p-request-obj-' + url, function(data) {
|
getStorage(cacheKeys.pRequestObjStart + url, function(data) {
|
||||||
createOnlineDebugRequestParamFun(data, requestParamObj, url);
|
createOnlineDebugRequestParamFun(data, requestParamObj, url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -296,6 +296,27 @@ function createOnlineDebugRequestParamFun(pRequestObj, requestParamObj, url) {
|
|||||||
var onlyUseLastForm = onlyUseLastParam && !isEmptyObject(pRequestObj.form);
|
var onlyUseLastForm = onlyUseLastParam && !isEmptyObject(pRequestObj.form);
|
||||||
var onlyUseLastBody = onlyUseLastParam && !isEmptyObject(pRequestObj.body);
|
var onlyUseLastBody = onlyUseLastParam && !isEmptyObject(pRequestObj.body);
|
||||||
var headerValueCount = 0, formValueCount = 0;
|
var headerValueCount = 0, formValueCount = 0;
|
||||||
|
|
||||||
|
if(typeof pRequestObj != 'object') {
|
||||||
|
pRequestObj = {};
|
||||||
|
}
|
||||||
|
if(typeof pRequestObj.header != 'object') {
|
||||||
|
pRequestObj.header = {};
|
||||||
|
}
|
||||||
|
if(typeof pRequestObj.form != 'object') {
|
||||||
|
pRequestObj.form = {};
|
||||||
|
}
|
||||||
|
if(typeof pRequestObj.body != 'object') {
|
||||||
|
pRequestObj.body = {};
|
||||||
|
}
|
||||||
|
for (var i = 0; i < debugGlobalParam.length; i++) {
|
||||||
|
var item = debugGlobalParam[i];
|
||||||
|
if (item.paramIn == 'header') {
|
||||||
|
pRequestObj.header[item.key] = item.value;
|
||||||
|
} else if (item.paramIn == 'form') {
|
||||||
|
pRequestObj.form[item.key] = item.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
Object.keys(requestParamObj).forEach(function(key){
|
Object.keys(requestParamObj).forEach(function(key){
|
||||||
var tempParam = requestParamObj[key];
|
var tempParam = requestParamObj[key];
|
||||||
if (key == "p-body-obj") {
|
if (key == "p-body-obj") {
|
||||||
|
|||||||
@@ -10,5 +10,9 @@ var exports = {
|
|||||||
exportDocument: function(){
|
exportDocument: function(){
|
||||||
// 定义在mg-ui.js,用于打开导出文档框
|
// 定义在mg-ui.js,用于打开导出文档框
|
||||||
exportDocument();
|
exportDocument();
|
||||||
|
},
|
||||||
|
updateGlobalParam: function(param){
|
||||||
|
// 更新调试的全局参数变量
|
||||||
|
debugGlobalParam = param;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -19,6 +19,8 @@ var projectTreeIdIndex = 1;
|
|||||||
var projectLoadingIndex = 0;
|
var projectLoadingIndex = 0;
|
||||||
// 请求到的文档列表
|
// 请求到的文档列表
|
||||||
var documentJsonArr = [];
|
var documentJsonArr = [];
|
||||||
|
// 调试的全局参数变量
|
||||||
|
var debugGlobalParam = [];
|
||||||
// 用户的配置对象
|
// 用户的配置对象
|
||||||
var userSettings = {};
|
var userSettings = {};
|
||||||
// 默认用户的配置对象
|
// 默认用户的配置对象
|
||||||
@@ -86,7 +88,7 @@ function getDocumentListByService() {
|
|||||||
showGlobalLoadingMessage('等待选择需展示的文档,请选择...', true);
|
showGlobalLoadingMessage('等待选择需展示的文档,请选择...', true);
|
||||||
for (var i = 0; i < json.data.length; i++) {
|
for (var i = 0; i < json.data.length; i++) {
|
||||||
var item = json.data[i];
|
var item = json.data[i];
|
||||||
$("#choiseDocListUl").append('<li value="'+item+'">'+item+'</li>');
|
$("#choiseDocListUl").append('<li value="'+item.url+'">'+item.url+'</li>');
|
||||||
}
|
}
|
||||||
$('#choiseDocModal').modal({moveable:true, backdrop:'static', keyboard: false});
|
$('#choiseDocModal').modal({moveable:true, backdrop:'static', keyboard: false});
|
||||||
} else {
|
} else {
|
||||||
@@ -159,48 +161,6 @@ $("#changeContentWidth").click(function(){
|
|||||||
changeContentWidth(isMinWidth ? 360 : 120);
|
changeContentWidth(isMinWidth ? 360 : 120);
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改tree的class
|
|
||||||
*/
|
|
||||||
$("input[name='treeShowType']").change(function() {
|
|
||||||
userSettings.treeShowType = $("input[name='treeShowType']:checked").val();
|
|
||||||
updateTreeShowType();
|
|
||||||
storeUserSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 切换url分成一层一层的展示、整个url显示为一层展示
|
|
||||||
*/
|
|
||||||
$("input[name='catalogShowType']").change(function() {
|
|
||||||
userSettings.catalogShowType = $("input[name='catalogShowType']:checked").val();
|
|
||||||
regeneratePathTree();
|
|
||||||
storeUserSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否展示参数类型
|
|
||||||
*/
|
|
||||||
$("input[name='showParamType']").change(function() {
|
|
||||||
userSettings.showParamType = $("input[name='showParamType']:checked").val();
|
|
||||||
storeUserSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否仅使用上次请求参数
|
|
||||||
*/
|
|
||||||
$("input[name='onlyUseLastParam']").change(function() {
|
|
||||||
userSettings.onlyUseLastParam = $("input[name='onlyUseLastParam']:checked").val();
|
|
||||||
storeUserSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否自动填充请求参数
|
|
||||||
*/
|
|
||||||
$("input[name='autoFillParam']").change(function() {
|
|
||||||
userSettings.autoFillParam = $("input[name='autoFillParam']:checked").val();
|
|
||||||
storeUserSettings();
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索框回车事件
|
* 搜索框回车事件
|
||||||
*/
|
*/
|
||||||
@@ -1030,7 +990,7 @@ function updateTreeShowType() {
|
|||||||
* 存储用户设置
|
* 存储用户设置
|
||||||
*/
|
*/
|
||||||
function storeUserSettings() {
|
function storeUserSettings() {
|
||||||
setStorage('userSettings', userSettings);
|
setStorage(cacheKeys.userSettings, userSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1046,7 +1006,7 @@ function updateUserSettings(newSetting) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function initUserSettings() {
|
function initUserSettings() {
|
||||||
getStorage('userSettings', function(data) {
|
getStorage(cacheKeys.userSettings, function(data) {
|
||||||
userSettings = data;
|
userSettings = data;
|
||||||
if(isEmpty(userSettings) || isEmptyObject(userSettings)) {
|
if(isEmpty(userSettings) || isEmptyObject(userSettings)) {
|
||||||
userSettings = defaultUserSettings;
|
userSettings = defaultUserSettings;
|
||||||
@@ -1057,6 +1017,9 @@ function initUserSettings() {
|
|||||||
// 增加文档
|
// 增加文档
|
||||||
getDocumentListByService();
|
getDocumentListByService();
|
||||||
});
|
});
|
||||||
|
getStorage(cacheKeys.globalParamList, function(data) {
|
||||||
|
debugGlobalParam = data;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showGlobalLoadingMessage(text, loading) {
|
function showGlobalLoadingMessage(text, loading) {
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
var app = new Vue({
|
var app = new Vue({
|
||||||
el: '#app',
|
el: '#app',
|
||||||
data: {
|
data: {
|
||||||
|
initCount: 5,
|
||||||
catalogShowType: '',
|
catalogShowType: '',
|
||||||
treeShowType: '',
|
treeShowType: '',
|
||||||
showParamType:'',
|
showParamType:'',
|
||||||
@@ -124,10 +125,12 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 存储用户的配置信息
|
// 存储用户的配置信息
|
||||||
function storeUserSettings(){
|
function storeUserSettings() {
|
||||||
setStorage(cacheKeys.userSettings, app.userSettings, function(){
|
if (app.initCount-- <= 0) {
|
||||||
getExport().updateUserSettings(app.userSettings);
|
setStorage(cacheKeys.userSettings, app.userSettings, function () {
|
||||||
});
|
getExport().updateUserSettings(app.userSettings);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html>
|
<html xmlns:v-on="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
@@ -14,15 +14,18 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td style="width: 50px;">序号</td>
|
<td style="width: 50px;">序号</td>
|
||||||
<td>地址</td>
|
<td>地址</td>
|
||||||
|
<td>持久化时间</td>
|
||||||
<td>操作</td>
|
<td>操作</td>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(item,index) in swaggerResourcesList" :key="item.id" :data-id="item.id" :data-index="index" >
|
<tr v-for="(item,index) in swaggerResourcesList" :key="item.id" :data-id="item.id" :data-index="index" >
|
||||||
<td>{{index+1}}</td>
|
<td>{{index+1}}</td>
|
||||||
<td>{{item}}</td>
|
<td>{{item.url}}</td>
|
||||||
|
<td>{{item.lastSync}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-danger" type="button" v-on:click="deleteDocUrl($event)">删除</button>
|
<button class="btn btn-danger" type="button" v-on:click="deleteDocUrl($event)">删除</button>
|
||||||
|
<!--<button class="btn btn-danger" type="button" v-on:click="syncDocData($event)">持久化</button>-->
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -93,7 +96,8 @@
|
|||||||
ajaxTemp(urlBase + "swagger-mg-ui/document/addSwaggerResources", "post", "json", {resourcesUrl: addNewDocumentInput}, function(json){
|
ajaxTemp(urlBase + "swagger-mg-ui/document/addSwaggerResources", "post", "json", {resourcesUrl: addNewDocumentInput}, function(json){
|
||||||
if(validateResult(json)) {
|
if(validateResult(json)) {
|
||||||
//window.parent.document.location.reload();
|
//window.parent.document.location.reload();
|
||||||
app.swaggerResourcesList.push(addNewDocumentInput);
|
//app.swaggerResourcesList.push(addNewDocumentInput);
|
||||||
|
app.refreshList();
|
||||||
$('#addNewDocumentModal').modal('hide');
|
$('#addNewDocumentModal').modal('hide');
|
||||||
Toast.success("保存成功,刷新后生效!");
|
Toast.success("保存成功,刷新后生效!");
|
||||||
}
|
}
|
||||||
@@ -117,6 +121,17 @@
|
|||||||
setStorage(cacheKeys.swaggerResourcesList, newDocList, function(){
|
setStorage(cacheKeys.swaggerResourcesList, newDocList, function(){
|
||||||
app.swaggerResourcesList = newDocList;
|
app.swaggerResourcesList = newDocList;
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
syncDocData: function(event){
|
||||||
|
var tr = $(event.currentTarget).parents("tr");
|
||||||
|
var index = tr.data("index");
|
||||||
|
var newDocUrl = app.swaggerResourcesList[index].url;
|
||||||
|
ajaxTemp(urlBase + "swagger-mg-ui/document/syncDocData", "post", "json", {resourcesUrl: newDocUrl}, function(json){
|
||||||
|
if(validateResult(json)) {
|
||||||
|
app.refreshList();
|
||||||
|
Toast.success("持久化成功!");
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function(){
|
mounted: function(){
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr v-for="(item,index) in globalParamList" :key="item.id" :data-id="item.id" :data-index="index">
|
<tr v-for="(item,index) in globalParamList" :key="item.id" :data-id="item.id" :data-index="index">
|
||||||
<td>
|
<td>
|
||||||
<select class="form-control" v-model:value="item.position">
|
<select class="form-control" v-model:value="item.paramIn">
|
||||||
<option value="header">header</option>
|
<option value="header">header</option>
|
||||||
<option value="form">form</option>
|
<option value="form">form</option>
|
||||||
</select>
|
</select>
|
||||||
@@ -81,11 +81,12 @@
|
|||||||
},
|
},
|
||||||
addGlobalParamLine: function () {
|
addGlobalParamLine: function () {
|
||||||
app.globalParamList.push({
|
app.globalParamList.push({
|
||||||
position: 'header', key: '', value: ''
|
paramIn: 'header', key: '', value: ''
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
saveAllGlobalParam: function () {
|
saveAllGlobalParam: function () {
|
||||||
setStorage(cacheKeys.globalParamList, app.globalParamList, function(){
|
setStorage(cacheKeys.globalParamList, app.globalParamList, function(){
|
||||||
|
getExport().updateGlobalParam(app.globalParamList);
|
||||||
Toast.success("保存成功!");
|
Toast.success("保存成功!");
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user