wiki编辑器升级,api接口文档开发
This commit is contained in:
@@ -5,7 +5,9 @@ import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomFolder;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomFolderService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -28,6 +30,8 @@ public class ApiCustomFolderController {
|
||||
|
||||
@Resource
|
||||
ApiCustomFolderService apiCustomFolderService;
|
||||
@Resource
|
||||
ApiDocAuthJudgeService apiDocAuthJudgeService;
|
||||
|
||||
/**
|
||||
* 1. 新增文件夹
|
||||
@@ -44,4 +48,44 @@ public class ApiCustomFolderController {
|
||||
apiCustomFolderService.addFolder(apiCustomFolder);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/update")
|
||||
public ResponseJson<Object> update(ApiCustomFolder apiCustomFolder) {
|
||||
// 参数未传不处理
|
||||
if (apiCustomFolder.getId() == null || StringUtils.isBlank(apiCustomFolder.getFolderName())) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
ApiCustomFolder apiCustomFolderSel = apiCustomFolderService.getById(apiCustomFolder.getId());
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolderSel.getDocId());
|
||||
// 执行修改
|
||||
ApiCustomFolder folderUp = new ApiCustomFolder();
|
||||
folderUp.setId(apiCustomFolder.getId());
|
||||
folderUp.setFolderName(apiCustomFolder.getFolderName());
|
||||
apiCustomFolderService.updateById(folderUp);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
ApiCustomFolder apiCustomFolderSel = apiCustomFolderService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolderSel.getDocId());
|
||||
apiCustomFolderService.deleteFolder(id);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.zyplayer.doc.api.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.api.controller.vo.ApiCustomParamsVo;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.*;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomNodeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomParamsService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档分组 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
@AuthMan
|
||||
@Controller
|
||||
@RequestMapping("/api-custom-node")
|
||||
public class ApiCustomNodeController {
|
||||
|
||||
@Resource
|
||||
ApiCustomNodeService apiCustomNodeService;
|
||||
@Resource
|
||||
ApiCustomParamsService apiCustomParamsService;
|
||||
@Resource
|
||||
ApiDocAuthJudgeService apiDocAuthJudgeService;
|
||||
|
||||
/**
|
||||
* 1. 新增文件夹
|
||||
* 2. 修改文件夹名称说明等
|
||||
* 3. 修改父文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/add")
|
||||
public ResponseJson<Object> add(ApiCustomNode apiCustomNode, ApiCustomParams apiCustomParams) {
|
||||
apiCustomNodeService.addNode(apiCustomNode, apiCustomParams);
|
||||
return DocResponseJson.ok(apiCustomNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/update")
|
||||
public ResponseJson<Object> update(ApiCustomNode apiCustomNode) {
|
||||
// 参数未传不处理
|
||||
if (apiCustomNode.getId() == null) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
if (StringUtils.isBlank(apiCustomNode.getNodeName()) && StringUtils.isBlank(apiCustomNode.getNodeDesc())) {
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
ApiCustomNode apiCustomFolderSel = apiCustomNodeService.getById(apiCustomNode.getId());
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolderSel.getDocId());
|
||||
// 执行修改
|
||||
ApiCustomNode nodeUp = new ApiCustomNode();
|
||||
nodeUp.setId(apiCustomNode.getId());
|
||||
nodeUp.setNodeName(apiCustomNode.getNodeName());
|
||||
nodeUp.setNodeDesc(apiCustomNode.getNodeDesc());
|
||||
apiCustomNodeService.updateById(nodeUp);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
ApiCustomNode apiCustomFolderSel = apiCustomNodeService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolderSel.getDocId());
|
||||
apiCustomNodeService.deleteNode(id);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/changeParent")
|
||||
public ResponseJson<Object> changeParent(Long id, Long parentId, Integer targetType, Integer targetSeq) {
|
||||
ApiCustomNode apiCustomFolderSel = apiCustomNodeService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolderSel.getDocId());
|
||||
apiCustomNodeService.changeParent(id, parentId, targetType, targetSeq);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义接口详情
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2022年01月05日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/detail")
|
||||
public ResponseJson<Object> detail(Long id) {
|
||||
ApiCustomNode apiCustomNode = apiCustomNodeService.getById(id);
|
||||
if (apiCustomNode == null) {
|
||||
return DocResponseJson.warn("接口不存在");
|
||||
}
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomNode.getDocId());
|
||||
QueryWrapper<ApiCustomParams> paramsWrapper = new QueryWrapper<>();
|
||||
paramsWrapper.eq("yn", 1);
|
||||
paramsWrapper.eq("node_id", id);
|
||||
ApiCustomParams apiCustomParams = apiCustomParamsService.getOne(paramsWrapper);
|
||||
// 组装结果对象
|
||||
ApiCustomParamsVo customParamsVo = new ApiCustomParamsVo();
|
||||
customParamsVo.setId(apiCustomNode.getId());
|
||||
customParamsVo.setDocId(apiCustomNode.getDocId());
|
||||
customParamsVo.setParentId(apiCustomNode.getParentId());
|
||||
customParamsVo.setNodeType(apiCustomNode.getNodeType());
|
||||
customParamsVo.setNodeName(apiCustomNode.getNodeName());
|
||||
customParamsVo.setNodeDesc(apiCustomNode.getNodeDesc());
|
||||
customParamsVo.setSeqNo(apiCustomNode.getSeqNo());
|
||||
customParamsVo.setNodeId(apiCustomNode.getId());
|
||||
if (apiCustomParams != null) {
|
||||
customParamsVo.setMethod(apiCustomParams.getMethod());
|
||||
customParamsVo.setApiUrl(apiCustomParams.getApiUrl());
|
||||
customParamsVo.setFormData(apiCustomParams.getFormData());
|
||||
customParamsVo.setBodyData(apiCustomParams.getBodyData());
|
||||
customParamsVo.setHeaderData(apiCustomParams.getHeaderData());
|
||||
customParamsVo.setCookieData(apiCustomParams.getCookieData());
|
||||
}
|
||||
return DocResponseJson.ok(customParamsVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.zyplayer.doc.api.controller;
|
||||
|
||||
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomRequest;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomRequestService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/api-custom-params")
|
||||
public class ApiCustomParamsController {
|
||||
|
||||
@Resource
|
||||
ApiDocAuthJudgeService apiDocAuthJudgeService;
|
||||
@Resource
|
||||
ApiCustomRequestService apiCustomRequestService;
|
||||
|
||||
/**
|
||||
* 1. 新增接口
|
||||
* 2. 修改接口名等
|
||||
* 3. 修改父文件夹
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2021年12月22日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/add")
|
||||
public ResponseJson<Object> add(ApiCustomRequest apiCustomRequest) {
|
||||
ApiCustomRequest requestSaved = apiCustomRequestService.addRequest(apiCustomRequest);
|
||||
return DocResponseJson.ok(requestSaved);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义接口详情
|
||||
*
|
||||
* @return 文档内容
|
||||
* @author 暮光:城中城
|
||||
* @since 2022年01月05日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/detail")
|
||||
public ResponseJson<Object> detail(Long id) {
|
||||
ApiCustomRequest apiCustomRequest = apiCustomRequestService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomRequest.getDocId());
|
||||
return DocResponseJson.ok(apiCustomRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022年01月05日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
ApiCustomRequest apiCustomRequest = apiCustomRequestService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomRequest.getDocId());
|
||||
// 修改为删除状态
|
||||
ApiCustomRequest requestUp = new ApiCustomRequest();
|
||||
requestUp.setId(id);
|
||||
requestUp.setYn(0);
|
||||
apiCustomRequestService.updateById(requestUp);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
}
|
||||
@@ -60,4 +60,23 @@ public class ApiCustomRequestController {
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomRequest.getDocId());
|
||||
return DocResponseJson.ok(apiCustomRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除接口
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022年01月05日
|
||||
*/
|
||||
@ResponseBody
|
||||
@PostMapping(value = "/delete")
|
||||
public ResponseJson<Object> delete(Long id) {
|
||||
ApiCustomRequest apiCustomRequest = apiCustomRequestService.getById(id);
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomRequest.getDocId());
|
||||
// 修改为删除状态
|
||||
ApiCustomRequest requestUp = new ApiCustomRequest();
|
||||
requestUp.setId(id);
|
||||
requestUp.setYn(0);
|
||||
apiCustomRequestService.updateById(requestUp);
|
||||
return DocResponseJson.ok();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,12 @@ import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiDoc;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomDocVo;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomVo;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiDocVo;
|
||||
import com.zyplayer.doc.data.repository.support.consts.ApiAuthType;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomNodeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomRequestService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiDocService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -52,7 +54,7 @@ public class ApiDocumentController {
|
||||
@Resource
|
||||
private SwaggerHttpRequestService swaggerHttpRequestService;
|
||||
@Resource
|
||||
ApiCustomRequestService apiCustomRequestService;
|
||||
ApiCustomNodeService apiCustomNodeService;
|
||||
|
||||
/**
|
||||
* 获取所有的文档地址
|
||||
@@ -222,7 +224,7 @@ public class ApiDocumentController {
|
||||
return DocResponseJson.ok(apiDoc.getJsonContent());
|
||||
}
|
||||
if (Objects.equals(apiDoc.getDocType(), 5)) {
|
||||
List<ApiCustomVo> customVoList = apiCustomRequestService.buildCustomApiList(apiDoc);
|
||||
List<ApiCustomDocVo> customVoList = apiCustomNodeService.buildCustomApiList(apiDoc);
|
||||
return DocResponseJson.ok(customVoList);
|
||||
}
|
||||
return DocResponseJson.warn("暂不支持的文档类型");
|
||||
|
||||
@@ -6,21 +6,19 @@ import com.zyplayer.doc.core.json.ResponseJson;
|
||||
import com.zyplayer.doc.api.controller.param.ProxyRequestParam;
|
||||
import com.zyplayer.doc.api.controller.vo.ProxyRequestResultVo;
|
||||
import com.zyplayer.doc.api.service.SwaggerHttpRequestService;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomRequest;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomRequestService;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomNode;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomParams;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomNodeService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 请求参数控制器
|
||||
@@ -35,7 +33,7 @@ public class ApiPoxyRequestController {
|
||||
private static Logger logger = LoggerFactory.getLogger(ApiPoxyRequestController.class);
|
||||
|
||||
@Resource
|
||||
ApiCustomRequestService apiCustomRequestService;
|
||||
ApiCustomNodeService apiCustomNodeService;
|
||||
@Resource
|
||||
private SwaggerHttpRequestService swaggerHttpRequestService;
|
||||
|
||||
@@ -50,18 +48,20 @@ public class ApiPoxyRequestController {
|
||||
@PostMapping(value = "/request")
|
||||
public ResponseJson<ProxyRequestResultVo> request(HttpServletRequest request, ProxyRequestParam requestParam) {
|
||||
// 自建接口请求时保存信息
|
||||
if (requestParam.getCustomRequestId() != null) {
|
||||
ApiCustomRequest apiCustomRequest = new ApiCustomRequest();
|
||||
apiCustomRequest.setId(requestParam.getCustomRequestId());
|
||||
apiCustomRequest.setApiName(requestParam.getApiName());
|
||||
apiCustomRequest.setDocId(requestParam.getDocId());
|
||||
apiCustomRequest.setApiUrl(requestParam.getUrl());
|
||||
apiCustomRequest.setMethod(requestParam.getMethod());
|
||||
apiCustomRequest.setFormData(requestParam.getFormParam());
|
||||
apiCustomRequest.setBodyData(requestParam.getBodyParam());
|
||||
apiCustomRequest.setHeaderData(requestParam.getHeaderParam());
|
||||
apiCustomRequest.setCookieData(requestParam.getCookieParam());
|
||||
apiCustomRequestService.addRequest(apiCustomRequest);
|
||||
if (requestParam.getNodeId() != null) {
|
||||
ApiCustomNode apiCustomNode = new ApiCustomNode();
|
||||
apiCustomNode.setNodeType(1);
|
||||
apiCustomNode.setId(requestParam.getNodeId());
|
||||
apiCustomNode.setDocId(requestParam.getDocId());
|
||||
apiCustomNode.setNodeName(requestParam.getApiName());
|
||||
ApiCustomParams apiCustomParams = new ApiCustomParams();
|
||||
apiCustomParams.setApiUrl(requestParam.getUrl());
|
||||
apiCustomParams.setMethod(requestParam.getMethod());
|
||||
apiCustomParams.setFormData(requestParam.getFormParam());
|
||||
apiCustomParams.setBodyData(requestParam.getBodyParam());
|
||||
apiCustomParams.setHeaderData(requestParam.getHeaderParam());
|
||||
apiCustomParams.setCookieData(requestParam.getCookieParam());
|
||||
apiCustomNodeService.addNode(apiCustomNode, apiCustomParams);
|
||||
}
|
||||
ProxyRequestResultVo requestResult = swaggerHttpRequestService.proxyRequest(request, requestParam);
|
||||
return DocResponseJson.ok(requestResult);
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ProxyRequestParam {
|
||||
private Long docId;
|
||||
private Long customRequestId;
|
||||
private Long nodeId;
|
||||
private String url;
|
||||
private String host;
|
||||
private String method;
|
||||
@@ -112,14 +112,6 @@ public class ProxyRequestParam {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Long getCustomRequestId() {
|
||||
return customRequestId;
|
||||
}
|
||||
|
||||
public void setCustomRequestId(Long customRequestId) {
|
||||
this.customRequestId = customRequestId;
|
||||
}
|
||||
|
||||
public Long getDocId() {
|
||||
return docId;
|
||||
}
|
||||
@@ -135,4 +127,12 @@ public class ProxyRequestParam {
|
||||
public void setApiName(String apiName) {
|
||||
this.apiName = apiName;
|
||||
}
|
||||
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,187 @@
|
||||
package com.zyplayer.doc.api.controller.vo;
|
||||
|
||||
public class ApiCustomParamsVo {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 父文件夹ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 节点类型 0=目录 1=接口
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 节点说明
|
||||
*/
|
||||
private String nodeDesc;
|
||||
|
||||
/**
|
||||
* 节点顺序
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
/**
|
||||
* api_doc主键ID
|
||||
*/
|
||||
private Long docId;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* 请求方式:get、head、post、put、patch、delete、options、trace
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 接口url
|
||||
*/
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* form参数
|
||||
*/
|
||||
private String formData;
|
||||
|
||||
/**
|
||||
* body参数
|
||||
*/
|
||||
private String bodyData;
|
||||
|
||||
/**
|
||||
* header参数
|
||||
*/
|
||||
private String headerData;
|
||||
|
||||
/**
|
||||
* cookie参数
|
||||
*/
|
||||
private String cookieData;
|
||||
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
|
||||
public String getNodeName() {
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
public String getNodeDesc() {
|
||||
return nodeDesc;
|
||||
}
|
||||
|
||||
public void setNodeDesc(String nodeDesc) {
|
||||
this.nodeDesc = nodeDesc;
|
||||
}
|
||||
|
||||
public Integer getSeqNo() {
|
||||
return seqNo;
|
||||
}
|
||||
|
||||
public void setSeqNo(Integer seqNo) {
|
||||
this.seqNo = seqNo;
|
||||
}
|
||||
|
||||
public Long getDocId() {
|
||||
return docId;
|
||||
}
|
||||
|
||||
public void setDocId(Long docId) {
|
||||
this.docId = docId;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public String getApiUrl() {
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
public void setApiUrl(String apiUrl) {
|
||||
this.apiUrl = apiUrl;
|
||||
}
|
||||
|
||||
public String getFormData() {
|
||||
return formData;
|
||||
}
|
||||
|
||||
public void setFormData(String formData) {
|
||||
this.formData = formData;
|
||||
}
|
||||
|
||||
public String getBodyData() {
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public void setBodyData(String bodyData) {
|
||||
this.bodyData = bodyData;
|
||||
}
|
||||
|
||||
public String getHeaderData() {
|
||||
return headerData;
|
||||
}
|
||||
|
||||
public void setHeaderData(String headerData) {
|
||||
this.headerData = headerData;
|
||||
}
|
||||
|
||||
public String getCookieData() {
|
||||
return cookieData;
|
||||
}
|
||||
|
||||
public void setCookieData(String cookieData) {
|
||||
this.cookieData = cookieData;
|
||||
}
|
||||
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档节点
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
@TableName("api_custom_node")
|
||||
public class ApiCustomNode implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* api_doc主键ID
|
||||
*/
|
||||
private Long docId;
|
||||
|
||||
/**
|
||||
* 父文件夹ID
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 节点类型 0=目录 1=接口
|
||||
*/
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 节点说明
|
||||
*/
|
||||
private String nodeDesc;
|
||||
|
||||
/**
|
||||
* 节点顺序
|
||||
*/
|
||||
private Integer seqNo;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否有效 0=无效 1=有效
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getDocId() {
|
||||
return docId;
|
||||
}
|
||||
|
||||
public void setDocId(Long docId) {
|
||||
this.docId = docId;
|
||||
}
|
||||
public Long getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(Long parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
public String getNodeName() {
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
public String getNodeDesc() {
|
||||
return nodeDesc;
|
||||
}
|
||||
|
||||
public void setNodeDesc(String nodeDesc) {
|
||||
this.nodeDesc = nodeDesc;
|
||||
}
|
||||
public Integer getSeqNo() {
|
||||
return seqNo;
|
||||
}
|
||||
|
||||
public void setSeqNo(Integer seqNo) {
|
||||
this.seqNo = seqNo;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getYn() {
|
||||
return yn;
|
||||
}
|
||||
|
||||
public void setYn(Integer yn) {
|
||||
this.yn = yn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApiCustomNode{" +
|
||||
"id=" + id +
|
||||
", docId=" + docId +
|
||||
", parentId=" + parentId +
|
||||
", nodeType=" + nodeType +
|
||||
", nodeName=" + nodeName +
|
||||
", nodeDesc=" + nodeDesc +
|
||||
", seqNo=" + seqNo +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", yn=" + yn +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.zyplayer.doc.data.repository.manage.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
@TableName("api_custom_params")
|
||||
public class ApiCustomParams implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键自增ID
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* api_doc主键ID
|
||||
*/
|
||||
private Long docId;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* 请求方式:get、head、post、put、patch、delete、options、trace
|
||||
*/
|
||||
private String method;
|
||||
|
||||
/**
|
||||
* 接口url
|
||||
*/
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* form参数
|
||||
*/
|
||||
private String formData;
|
||||
|
||||
/**
|
||||
* body参数
|
||||
*/
|
||||
private String bodyData;
|
||||
|
||||
/**
|
||||
* header参数
|
||||
*/
|
||||
private String headerData;
|
||||
|
||||
/**
|
||||
* cookie参数
|
||||
*/
|
||||
private String cookieData;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private Long createUserId;
|
||||
|
||||
/**
|
||||
* 创建人名字
|
||||
*/
|
||||
private String createUserName;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否有效 0=无效 1=有效
|
||||
*/
|
||||
private Integer yn;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Long getDocId() {
|
||||
return docId;
|
||||
}
|
||||
|
||||
public void setDocId(Long docId) {
|
||||
this.docId = docId;
|
||||
}
|
||||
|
||||
public String getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
public void setMethod(String method) {
|
||||
this.method = method;
|
||||
}
|
||||
public String getApiUrl() {
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
public void setApiUrl(String apiUrl) {
|
||||
this.apiUrl = apiUrl;
|
||||
}
|
||||
public String getFormData() {
|
||||
return formData;
|
||||
}
|
||||
|
||||
public void setFormData(String formData) {
|
||||
this.formData = formData;
|
||||
}
|
||||
public String getBodyData() {
|
||||
return bodyData;
|
||||
}
|
||||
|
||||
public void setBodyData(String bodyData) {
|
||||
this.bodyData = bodyData;
|
||||
}
|
||||
public String getHeaderData() {
|
||||
return headerData;
|
||||
}
|
||||
|
||||
public void setHeaderData(String headerData) {
|
||||
this.headerData = headerData;
|
||||
}
|
||||
public String getCookieData() {
|
||||
return cookieData;
|
||||
}
|
||||
|
||||
public void setCookieData(String cookieData) {
|
||||
this.cookieData = cookieData;
|
||||
}
|
||||
public Long getCreateUserId() {
|
||||
return createUserId;
|
||||
}
|
||||
|
||||
public void setCreateUserId(Long createUserId) {
|
||||
this.createUserId = createUserId;
|
||||
}
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Integer getYn() {
|
||||
return yn;
|
||||
}
|
||||
|
||||
public void setYn(Integer yn) {
|
||||
this.yn = yn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ApiCustomParams{" +
|
||||
"id=" + id +
|
||||
", docId=" + docId +
|
||||
", nodeId=" + nodeId +
|
||||
", method=" + method +
|
||||
", apiUrl=" + apiUrl +
|
||||
", formData=" + formData +
|
||||
", bodyData=" + bodyData +
|
||||
", headerData=" + headerData +
|
||||
", cookieData=" + cookieData +
|
||||
", createUserId=" + createUserId +
|
||||
", createUserName=" + createUserName +
|
||||
", createTime=" + createTime +
|
||||
", yn=" + yn +
|
||||
"}";
|
||||
}
|
||||
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomNode;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档节点 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
public interface ApiCustomNodeMapper extends BaseMapper<ApiCustomNode> {
|
||||
|
||||
@Update("update api_custom_node set seq_no=seq_no + 1 where parent_id=#{parentId} and seq_no >= #{targetSeq} and yn=1")
|
||||
void updateAfterSeq(@Param("parentId") Long parentId, @Param("targetSeq") Integer targetSeq);
|
||||
|
||||
@Select("select max(seq_no) from api_custom_node where parent_id=#{parentId} and yn=1")
|
||||
Integer getLastSeq(@Param("parentId") Long parentId);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.repository.manage.mapper;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomParams;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
public interface ApiCustomParamsMapper extends BaseMapper<ApiCustomParams> {
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.zyplayer.doc.data.repository.manage.vo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* api自建文档信息
|
||||
@@ -13,19 +14,24 @@ public class ApiCustomDocVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 接口ID
|
||||
* 节点类型 0=目录 1=接口
|
||||
*/
|
||||
private Long requestId;
|
||||
private Integer nodeType;
|
||||
|
||||
/**
|
||||
* 文件夹ID
|
||||
* 接口ID
|
||||
*/
|
||||
private Long folderId;
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* 接口名称
|
||||
*/
|
||||
private String apiName;
|
||||
private String nodeName;
|
||||
|
||||
/**
|
||||
* 接口说明
|
||||
*/
|
||||
private String nodeDesc;
|
||||
|
||||
/**
|
||||
* 请求方式:get、head、post、put、patch、delete、options、trace
|
||||
@@ -57,13 +63,10 @@ public class ApiCustomDocVo implements Serializable {
|
||||
*/
|
||||
private String cookieData;
|
||||
|
||||
public String getApiName() {
|
||||
return apiName;
|
||||
}
|
||||
|
||||
public void setApiName(String apiName) {
|
||||
this.apiName = apiName;
|
||||
}
|
||||
/**
|
||||
* 子目录列表
|
||||
*/
|
||||
private List<ApiCustomDocVo> children;
|
||||
|
||||
public String getApiUrl() {
|
||||
return apiUrl;
|
||||
@@ -113,19 +116,43 @@ public class ApiCustomDocVo implements Serializable {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
public Long getRequestId() {
|
||||
return requestId;
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setRequestId(Long requestId) {
|
||||
this.requestId = requestId;
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
|
||||
public Long getFolderId() {
|
||||
return folderId;
|
||||
public String getNodeName() {
|
||||
return nodeName;
|
||||
}
|
||||
|
||||
public void setFolderId(Long folderId) {
|
||||
this.folderId = folderId;
|
||||
public void setNodeName(String nodeName) {
|
||||
this.nodeName = nodeName;
|
||||
}
|
||||
|
||||
public List<ApiCustomDocVo> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<ApiCustomDocVo> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getNodeDesc() {
|
||||
return nodeDesc;
|
||||
}
|
||||
|
||||
public void setNodeDesc(String nodeDesc) {
|
||||
this.nodeDesc = nodeDesc;
|
||||
}
|
||||
|
||||
public Integer getNodeType() {
|
||||
return nodeType;
|
||||
}
|
||||
|
||||
public void setNodeType(Integer nodeType) {
|
||||
this.nodeType = nodeType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,9 @@ public class ApiCustomVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 文件夹ID
|
||||
* 节点ID
|
||||
*/
|
||||
private Long folderId;
|
||||
private Long nodeId;
|
||||
|
||||
/**
|
||||
* 文件夹名称
|
||||
@@ -70,11 +70,11 @@ public class ApiCustomVo implements Serializable {
|
||||
this.apis = apis;
|
||||
}
|
||||
|
||||
public Long getFolderId() {
|
||||
return folderId;
|
||||
public Long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
public void setFolderId(Long folderId) {
|
||||
this.folderId = folderId;
|
||||
public void setNodeId(Long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.util.Collections;
|
||||
public class CodeGenerator {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String[] tableName = {"api_custom_request", "api_custom_folder"};
|
||||
final String[] tableName = {"api_custom_node", "api_custom_params"};
|
||||
String url = "jdbc:mysql://127.0.0.1:3306/zyplayer_doc_manage?useUnicode=true&useSSL=false&characterEncoding=utf8";
|
||||
String projectPath = System.getProperty("user.dir") + "/zyplayer-doc-data";
|
||||
String outputDir = projectPath + "/src/main/java";
|
||||
|
||||
@@ -21,4 +21,12 @@ public interface ApiCustomFolderService extends IService<ApiCustomFolder> {
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
void addFolder(ApiCustomFolder apiCustomFolder);
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
void deleteFolder(Long id);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomNode;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomParams;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiDoc;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomDocVo;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档节点 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
public interface ApiCustomNodeService extends IService<ApiCustomNode> {
|
||||
|
||||
/**
|
||||
* 增加文件夹
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
void addNode(ApiCustomNode apiCustomNode, ApiCustomParams apiCustomParams);
|
||||
|
||||
/**
|
||||
* 删除文件夹
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
void deleteNode(Long id);
|
||||
|
||||
/**
|
||||
* 修改父节点
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
void changeParent(Long id, Long parentId, Integer targetType, Integer targetSeq);
|
||||
|
||||
/**
|
||||
* 构建目录树
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
List<ApiCustomDocVo> buildCustomApiList(ApiDoc apiDoc);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.zyplayer.doc.data.service.manage;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomParams;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
public interface ApiCustomParamsService extends IService<ApiCustomParams> {
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
@@ -7,10 +9,13 @@ import com.zyplayer.doc.data.repository.manage.entity.ApiCustomFolder;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.ApiCustomFolderMapper;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomFolderService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -42,4 +47,40 @@ public class ApiCustomFolderServiceImpl extends ServiceImpl<ApiCustomFolderMappe
|
||||
}
|
||||
this.saveOrUpdate(apiCustomFolder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFolder(Long id) {
|
||||
this.deleteFolderRecursion(id);
|
||||
// 逻辑删除
|
||||
ApiCustomFolder folderDel = new ApiCustomFolder();
|
||||
folderDel.setId(id);
|
||||
folderDel.setYn(0);
|
||||
this.updateById(folderDel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归删除下级
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
public void deleteFolderRecursion(Long id) {
|
||||
QueryWrapper<ApiCustomFolder> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
wrapper.eq("parent_folder_id", id);
|
||||
List<ApiCustomFolder> childrenList = this.list(wrapper);
|
||||
if (CollectionUtils.isNotEmpty(childrenList)) {
|
||||
for (ApiCustomFolder folder : childrenList) {
|
||||
// 递归删除下级
|
||||
this.deleteFolderRecursion(folder.getId());
|
||||
}
|
||||
// 逻辑删除
|
||||
ApiCustomFolder folderDel = new ApiCustomFolder();
|
||||
folderDel.setYn(0);
|
||||
QueryWrapper<ApiCustomFolder> wrapperDel = new QueryWrapper<>();
|
||||
wrapperDel.in("id", childrenList.stream().map(ApiCustomFolder::getId).collect(Collectors.toSet()));
|
||||
this.update(folderDel, wrapperDel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zyplayer.doc.data.config.security.DocUserDetails;
|
||||
import com.zyplayer.doc.data.config.security.DocUserUtil;
|
||||
import com.zyplayer.doc.data.repository.manage.entity.*;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.ApiCustomNodeMapper;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomDocVo;
|
||||
import com.zyplayer.doc.data.repository.manage.vo.ApiCustomVo;
|
||||
import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomNodeService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomParamsService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档节点 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
@Service
|
||||
public class ApiCustomNodeServiceImpl extends ServiceImpl<ApiCustomNodeMapper, ApiCustomNode> implements ApiCustomNodeService {
|
||||
|
||||
@Resource
|
||||
ApiDocAuthJudgeService apiDocAuthJudgeService;
|
||||
@Resource
|
||||
ApiCustomNodeMapper apiCustomNodeMapper;
|
||||
@Resource
|
||||
ApiCustomParamsService apiCustomParamsService;
|
||||
|
||||
@Override
|
||||
public void addNode(ApiCustomNode apiCustomFolder, ApiCustomParams apiCustomParams) {
|
||||
apiDocAuthJudgeService.judgeDevelopAndThrow(apiCustomFolder.getDocId());
|
||||
DocUserDetails currentUser = DocUserUtil.getCurrentUser();
|
||||
Long parentId = Optional.ofNullable(apiCustomFolder.getParentId()).orElse(0L);
|
||||
apiCustomFolder.setParentId(parentId);
|
||||
if (apiCustomFolder.getId() == null) {
|
||||
apiCustomFolder.setYn(1);
|
||||
apiCustomFolder.setCreateTime(new Date());
|
||||
apiCustomFolder.setCreateUserId(currentUser.getUserId());
|
||||
apiCustomFolder.setCreateUserName(currentUser.getUsername());
|
||||
// 修改顺序值,新增放最后
|
||||
Integer lastSeq = apiCustomNodeMapper.getLastSeq(parentId);
|
||||
lastSeq = Optional.ofNullable(lastSeq).orElse(0);
|
||||
apiCustomFolder.setSeqNo(lastSeq + 1);
|
||||
} else {
|
||||
apiCustomFolder.setCreateTime(null);
|
||||
apiCustomFolder.setCreateUserId(null);
|
||||
apiCustomFolder.setCreateUserName(null);
|
||||
}
|
||||
this.saveOrUpdate(apiCustomFolder);
|
||||
// 保存参数
|
||||
if (Objects.equals(apiCustomFolder.getNodeType(), 1)) {
|
||||
apiCustomParams.setNodeId(apiCustomFolder.getId());
|
||||
QueryWrapper<ApiCustomParams> nodeParamsWrapper = new QueryWrapper<>();
|
||||
nodeParamsWrapper.eq("node_id", apiCustomFolder.getId());
|
||||
ApiCustomParams customParams = apiCustomParamsService.getOne(nodeParamsWrapper);
|
||||
if (customParams != null) {
|
||||
apiCustomParams.setId(customParams.getId());
|
||||
}
|
||||
apiCustomParams.setYn(1);
|
||||
apiCustomParamsService.saveOrUpdate(apiCustomParams);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNode(Long id) {
|
||||
Set<Long> deleteNodeIds = new HashSet<>();
|
||||
deleteNodeIds.add(id);
|
||||
this.getAllChildNodeId(deleteNodeIds, id);
|
||||
// 删除所有节点
|
||||
ApiCustomNode nodeDel = new ApiCustomNode();
|
||||
nodeDel.setYn(0);
|
||||
QueryWrapper<ApiCustomNode> nodeDelWrapper = new QueryWrapper<>();
|
||||
nodeDelWrapper.in("id", deleteNodeIds);
|
||||
this.update(nodeDel, nodeDelWrapper);
|
||||
// 删除所有参数
|
||||
ApiCustomParams nodeParamsDel = new ApiCustomParams();
|
||||
nodeParamsDel.setYn(0);
|
||||
QueryWrapper<ApiCustomParams> nodeParamsDelWrapper = new QueryWrapper<>();
|
||||
nodeParamsDelWrapper.in("node_id", deleteNodeIds);
|
||||
apiCustomParamsService.update(nodeParamsDel, nodeParamsDelWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeParent(Long id, Long parentId, Integer targetType, Integer targetSeq) {
|
||||
parentId = Optional.ofNullable(parentId).orElse(0L);
|
||||
ApiCustomNode apiCustomNode = new ApiCustomNode();
|
||||
apiCustomNode.setId(id);
|
||||
if (Objects.equals(targetType, 1)) {
|
||||
// 放入选中元素的后面
|
||||
if (parentId > 0) {
|
||||
ApiCustomNode customNodeSel = this.getById(parentId);
|
||||
apiCustomNode.setSeqNo(customNodeSel.getSeqNo() + 1);
|
||||
Long targetParentId = Optional.ofNullable(customNodeSel.getParentId()).orElse(0L);
|
||||
apiCustomNode.setParentId(targetParentId);
|
||||
apiCustomNodeMapper.updateAfterSeq(targetParentId, apiCustomNode.getSeqNo());
|
||||
} else {
|
||||
Integer lastSeq = apiCustomNodeMapper.getLastSeq(0L);
|
||||
lastSeq = Optional.ofNullable(lastSeq).orElse(0);
|
||||
apiCustomNode.setParentId(0L);
|
||||
apiCustomNode.setSeqNo(lastSeq + 1);
|
||||
}
|
||||
} else {
|
||||
// 放入选中元素的最前面
|
||||
ApiCustomNode customNodeSel = this.getById(parentId);
|
||||
// 目录才能移到里面去
|
||||
if (customNodeSel == null || Objects.equals(customNodeSel.getNodeType(), 0)) {
|
||||
apiCustomNode.setSeqNo(1);
|
||||
apiCustomNode.setParentId(parentId);
|
||||
apiCustomNodeMapper.updateAfterSeq(parentId, 1);
|
||||
} else {
|
||||
// 否则移动到目标元素后
|
||||
apiCustomNode.setSeqNo(customNodeSel.getSeqNo() + 1);
|
||||
apiCustomNode.setParentId(customNodeSel.getParentId());
|
||||
apiCustomNodeMapper.updateAfterSeq(customNodeSel.getParentId(), apiCustomNode.getSeqNo());
|
||||
}
|
||||
}
|
||||
this.updateById(apiCustomNode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiCustomDocVo> buildCustomApiList(ApiDoc apiDoc) {
|
||||
QueryWrapper<ApiCustomNode> nodeQueryWrapper = new QueryWrapper<>();
|
||||
nodeQueryWrapper.eq("yn", 1);
|
||||
nodeQueryWrapper.eq("doc_id", apiDoc.getId());
|
||||
List<ApiCustomNode> customNodeList = this.list(nodeQueryWrapper);
|
||||
|
||||
QueryWrapper<ApiCustomParams> paramsWrapper = new QueryWrapper<>();
|
||||
paramsWrapper.eq("yn", 1);
|
||||
paramsWrapper.eq("doc_id", apiDoc.getId());
|
||||
paramsWrapper.select("node_id", "method", "api_url");
|
||||
List<ApiCustomParams> customParamsList = apiCustomParamsService.list(paramsWrapper);
|
||||
Map<Long, ApiCustomParams> customParamsMap = customParamsList.stream().collect(Collectors.toMap(ApiCustomParams::getNodeId, val -> val));
|
||||
|
||||
Map<Long, List<ApiCustomNode>> nodeMap = customNodeList.stream()
|
||||
.peek(item -> item.setParentId(Optional.ofNullable(item.getParentId()).orElse(0L)))
|
||||
.collect(Collectors.groupingBy(ApiCustomNode::getParentId));
|
||||
|
||||
List<ApiCustomDocVo> customGroupChildren = this.getCustomGroupChildren(nodeMap.get(0L), nodeMap, customParamsMap);
|
||||
// 组装结果对象
|
||||
ApiCustomDocVo apiCustomVo = new ApiCustomDocVo();
|
||||
apiCustomVo.setChildren(customGroupChildren);
|
||||
apiCustomVo.setNodeName(apiDoc.getName());
|
||||
List<ApiCustomDocVo> apiCustomVoList = new LinkedList<>();
|
||||
apiCustomVoList.add(apiCustomVo);
|
||||
return apiCustomVoList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归删除下级
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
public void getAllChildNodeId(Set<Long> deleteNodeIds, Long id) {
|
||||
QueryWrapper<ApiCustomNode> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("yn", 1);
|
||||
wrapper.eq("parent_id", id);
|
||||
List<ApiCustomNode> childrenList = this.list(wrapper);
|
||||
if (CollectionUtils.isNotEmpty(childrenList)) {
|
||||
for (ApiCustomNode folder : childrenList) {
|
||||
// 递归删除下级
|
||||
this.getAllChildNodeId(deleteNodeIds, folder.getId());
|
||||
}
|
||||
deleteNodeIds.addAll(childrenList.stream().map(ApiCustomNode::getId).collect(Collectors.toSet()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归获取目录树
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2021-12-22
|
||||
*/
|
||||
private List<ApiCustomDocVo> getCustomGroupChildren(List<ApiCustomNode> apiFolderList, Map<Long, List<ApiCustomNode>> nodeMap, Map<Long, ApiCustomParams> customParamsMap) {
|
||||
if (CollectionUtils.isEmpty(apiFolderList)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ApiCustomDocVo> apiCustomVoList = new LinkedList<>();
|
||||
apiFolderList.sort(Comparator.comparingInt(ApiCustomNode::getSeqNo));
|
||||
for (ApiCustomNode apiCustomNode : apiFolderList) {
|
||||
List<ApiCustomNode> children = nodeMap.get(apiCustomNode.getId());
|
||||
List<ApiCustomDocVo> customGroupChildren = this.getCustomGroupChildren(children, nodeMap, customParamsMap);
|
||||
ApiCustomDocVo apiCustomVo = new ApiCustomDocVo();
|
||||
apiCustomVo.setNodeId(apiCustomNode.getId());
|
||||
apiCustomVo.setNodeType(apiCustomNode.getNodeType());
|
||||
apiCustomVo.setNodeName(apiCustomNode.getNodeName());
|
||||
apiCustomVo.setNodeDesc(apiCustomNode.getNodeDesc());
|
||||
apiCustomVo.setChildren(customGroupChildren);
|
||||
if (Objects.equals(apiCustomNode.getNodeType(), 1)) {
|
||||
ApiCustomParams apiCustomParams = customParamsMap.get(apiCustomNode.getId());
|
||||
if (apiCustomParams != null) {
|
||||
apiCustomVo.setMethod(apiCustomParams.getMethod());
|
||||
apiCustomVo.setApiUrl(apiCustomParams.getApiUrl());
|
||||
}
|
||||
}
|
||||
apiCustomVoList.add(apiCustomVo);
|
||||
}
|
||||
return apiCustomVoList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.zyplayer.doc.data.service.manage.impl;
|
||||
|
||||
import com.zyplayer.doc.data.repository.manage.entity.ApiCustomParams;
|
||||
import com.zyplayer.doc.data.repository.manage.mapper.ApiCustomParamsMapper;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomParamsService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 自建接口文档 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 暮光:城中城
|
||||
* @since 2022-01-29
|
||||
*/
|
||||
@Service
|
||||
public class ApiCustomParamsServiceImpl extends ServiceImpl<ApiCustomParamsMapper, ApiCustomParams> implements ApiCustomParamsService {
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import com.zyplayer.doc.data.service.common.ApiDocAuthJudgeService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomFolderService;
|
||||
import com.zyplayer.doc.data.service.manage.ApiCustomRequestService;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -57,7 +57,6 @@ public class ApiCustomRequestServiceImpl extends ServiceImpl<ApiCustomRequestMap
|
||||
Map<Long, List<ApiCustomFolder>> apiGroupMap = apiCustomGroupList.stream()
|
||||
.peek(item -> item.setParentFolderId(Optional.ofNullable(item.getParentFolderId()).orElse(0L)))
|
||||
.collect(Collectors.groupingBy(ApiCustomFolder::getParentFolderId));
|
||||
List<ApiCustomVo> apiCustomVoList = new LinkedList<>();
|
||||
List<ApiCustomDocVo> apis = this.buildApiCustomDocVo(apiMap.get(0L));
|
||||
List<ApiCustomVo> customGroupChildren = this.getCustomGroupChildren(apiGroupMap.get(0L), apiGroupMap, apiMap);
|
||||
// 组装结果对象
|
||||
@@ -65,6 +64,7 @@ public class ApiCustomRequestServiceImpl extends ServiceImpl<ApiCustomRequestMap
|
||||
apiCustomVo.setChildren(customGroupChildren);
|
||||
apiCustomVo.setName(apiDoc.getName());
|
||||
apiCustomVo.setApis(apis);
|
||||
List<ApiCustomVo> apiCustomVoList = new LinkedList<>();
|
||||
apiCustomVoList.add(apiCustomVo);
|
||||
return apiCustomVoList;
|
||||
}
|
||||
@@ -79,10 +79,13 @@ public class ApiCustomRequestServiceImpl extends ServiceImpl<ApiCustomRequestMap
|
||||
apiCustomRequest.setCreateUserId(currentUser.getUserId());
|
||||
apiCustomRequest.setCreateUserName(currentUser.getUsername());
|
||||
} else {
|
||||
apiCustomRequest.setDocId(null);
|
||||
apiCustomRequest.setCreateTime(null);
|
||||
apiCustomRequest.setCreateUserId(null);
|
||||
apiCustomRequest.setCreateUserName(null);
|
||||
}
|
||||
String apiName = StringUtils.defaultString(apiCustomRequest.getApiName(), "新建接口");
|
||||
apiCustomRequest.setApiName(apiName);
|
||||
this.saveOrUpdate(apiCustomRequest);
|
||||
return apiCustomRequest;
|
||||
}
|
||||
@@ -98,39 +101,39 @@ public class ApiCustomRequestServiceImpl extends ServiceImpl<ApiCustomRequestMap
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<ApiCustomVo> apiCustomVoList = new LinkedList<>();
|
||||
for (ApiCustomFolder customGroup : apiCustomGroups) {
|
||||
List<ApiCustomRequest> apiCustomList = apiMap.get(customGroup.getId());
|
||||
List<ApiCustomFolder> children = apiGroupMap.get(customGroup.getId());
|
||||
List<ApiCustomVo> customGroupChildren = this.getCustomGroupChildren(children, apiGroupMap, apiMap);
|
||||
List<ApiCustomDocVo> apis = this.buildApiCustomDocVo(apiCustomList);
|
||||
ApiCustomVo apiCustomVo = new ApiCustomVo();
|
||||
apiCustomVo.setFolderId(customGroup.getId());
|
||||
apiCustomVo.setName(customGroup.getFolderName());
|
||||
apiCustomVo.setDesc(customGroup.getFolderDesc());
|
||||
apiCustomVo.setChildren(customGroupChildren);
|
||||
apiCustomVo.setApis(apis);
|
||||
apiCustomVoList.add(apiCustomVo);
|
||||
}
|
||||
// for (ApiCustomFolder customGroup : apiCustomGroups) {
|
||||
// List<ApiCustomRequest> apiCustomList = apiMap.get(customGroup.getId());
|
||||
// List<ApiCustomFolder> children = apiGroupMap.get(customGroup.getId());
|
||||
// List<ApiCustomVo> customGroupChildren = this.getCustomGroupChildren(children, apiGroupMap, apiMap);
|
||||
// List<ApiCustomDocVo> apis = this.buildApiCustomDocVo(apiCustomList);
|
||||
// ApiCustomVo apiCustomVo = new ApiCustomVo();
|
||||
// apiCustomVo.setFolderId(customGroup.getId());
|
||||
// apiCustomVo.setName(customGroup.getFolderName());
|
||||
// apiCustomVo.setDesc(customGroup.getFolderDesc());
|
||||
// apiCustomVo.setChildren(customGroupChildren);
|
||||
// apiCustomVo.setApis(apis);
|
||||
// apiCustomVoList.add(apiCustomVo);
|
||||
// }
|
||||
return apiCustomVoList;
|
||||
}
|
||||
|
||||
private List<ApiCustomDocVo> buildApiCustomDocVo(List<ApiCustomRequest> apiCustomList) {
|
||||
List<ApiCustomDocVo> apis = new LinkedList<>();
|
||||
if (CollectionUtils.isNotEmpty(apiCustomList)) {
|
||||
for (ApiCustomRequest apiCustom : apiCustomList) {
|
||||
ApiCustomDocVo apiCustomDocVo = new ApiCustomDocVo();
|
||||
apiCustomDocVo.setRequestId(apiCustom.getId());
|
||||
apiCustomDocVo.setFolderId(apiCustom.getFolderId());
|
||||
apiCustomDocVo.setApiUrl(apiCustom.getApiUrl());
|
||||
apiCustomDocVo.setMethod(apiCustom.getMethod());
|
||||
apiCustomDocVo.setApiName(apiCustom.getApiName());
|
||||
apiCustomDocVo.setBodyData(apiCustom.getBodyData());
|
||||
apiCustomDocVo.setCookieData(apiCustom.getCookieData());
|
||||
apiCustomDocVo.setFormData(apiCustom.getFormData());
|
||||
apiCustomDocVo.setHeaderData(apiCustom.getHeaderData());
|
||||
apis.add(apiCustomDocVo);
|
||||
}
|
||||
}
|
||||
// if (CollectionUtils.isNotEmpty(apiCustomList)) {
|
||||
// for (ApiCustomRequest apiCustom : apiCustomList) {
|
||||
// ApiCustomDocVo apiCustomDocVo = new ApiCustomDocVo();
|
||||
// apiCustomDocVo.setRequestId(apiCustom.getId());
|
||||
// apiCustomDocVo.setFolderId(apiCustom.getFolderId());
|
||||
// apiCustomDocVo.setApiUrl(apiCustom.getApiUrl());
|
||||
// apiCustomDocVo.setMethod(apiCustom.getMethod());
|
||||
// apiCustomDocVo.setApiName(apiCustom.getApiName());
|
||||
// apiCustomDocVo.setBodyData(apiCustom.getBodyData());
|
||||
// apiCustomDocVo.setCookieData(apiCustom.getCookieData());
|
||||
// apiCustomDocVo.setFormData(apiCustom.getFormData());
|
||||
// apiCustomDocVo.setHeaderData(apiCustom.getHeaderData());
|
||||
// apis.add(apiCustomDocVo);
|
||||
// }
|
||||
// }
|
||||
return apis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.ApiCustomNodeMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zyplayer.doc.data.repository.manage.mapper.ApiCustomParamsMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -564,12 +564,29 @@ CREATE TABLE `api_global_param` (
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='api文档全局参数记录';
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_request`;
|
||||
CREATE TABLE `api_custom_request` (
|
||||
DROP TABLE IF EXISTS `api_custom_node`;
|
||||
CREATE TABLE `api_custom_node` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`folder_id` bigint(20) DEFAULT NULL COMMENT '文件夹ID',
|
||||
`api_name` varchar(250) DEFAULT NULL COMMENT '接口名称',
|
||||
`parent_id` bigint(20) DEFAULT NULL COMMENT '父文件夹ID',
|
||||
`node_type` tinyint(4) NOT NULL COMMENT '节点类型 0=目录 1=接口',
|
||||
`node_name` varchar(250) DEFAULT NULL COMMENT '节点名称',
|
||||
`node_desc` text DEFAULT NULL COMMENT '节点说明',
|
||||
`seq_no` int(11) DEFAULT NULL COMMENT '节点顺序',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档节点';
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_params`;
|
||||
CREATE TABLE `api_custom_params` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`node_id` bigint(20) DEFAULT NULL COMMENT '节点ID',
|
||||
`method` varchar(20) DEFAULT NULL COMMENT '请求方式:get、head、post、put、patch、delete、options、trace',
|
||||
`api_url` text DEFAULT NULL COMMENT '接口url',
|
||||
`form_data` text DEFAULT NULL COMMENT 'form参数',
|
||||
`body_data` text DEFAULT NULL COMMENT 'body参数',
|
||||
@@ -580,23 +597,8 @@ CREATE TABLE `api_custom_request` (
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档';
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_folder`;
|
||||
CREATE TABLE `api_custom_folder` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`parent_folder_id` bigint(20) DEFAULT NULL COMMENT '父文件夹ID',
|
||||
`folder_name` varchar(250) DEFAULT NULL COMMENT '文件夹名称',
|
||||
`folder_desc` text DEFAULT NULL COMMENT '文件夹说明',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档文件夹';
|
||||
|
||||
KEY `idx_doc_id` (`doc_id`),
|
||||
KEY `idx_node_id` (`node_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口参数';
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -9,12 +9,28 @@
|
||||
--
|
||||
-- ------------------------从1.1.0版本升级------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_request`;
|
||||
CREATE TABLE `api_custom_request` (
|
||||
DROP TABLE IF EXISTS `api_custom_node`;
|
||||
CREATE TABLE `api_custom_node` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`folder_id` bigint(20) DEFAULT NULL COMMENT '文件夹ID',
|
||||
`api_name` varchar(250) DEFAULT NULL COMMENT '接口名称',
|
||||
`parent_id` bigint(20) DEFAULT NULL COMMENT '父文件夹ID',
|
||||
`node_type` tinyint(4) NOT NULL COMMENT '节点类型 0=目录 1=接口',
|
||||
`node_name` varchar(250) DEFAULT NULL COMMENT '节点名称',
|
||||
`node_desc` text DEFAULT NULL COMMENT '节点说明',
|
||||
`seq_no` int(11) DEFAULT NULL COMMENT '节点顺序',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档节点';
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_params`;
|
||||
CREATE TABLE `api_custom_params` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`node_id` bigint(20) DEFAULT NULL COMMENT '节点ID',
|
||||
`method` varchar(20) DEFAULT NULL COMMENT '请求方式:get、head、post、put、patch、delete、options、trace',
|
||||
`api_url` text DEFAULT NULL COMMENT '接口url',
|
||||
`form_data` text DEFAULT NULL COMMENT 'form参数',
|
||||
@@ -26,23 +42,6 @@ CREATE TABLE `api_custom_request` (
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档';
|
||||
|
||||
|
||||
DROP TABLE IF EXISTS `api_custom_folder`;
|
||||
CREATE TABLE `api_custom_folder` (
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键自增ID',
|
||||
`doc_id` bigint(20) DEFAULT NULL COMMENT 'api_doc主键ID',
|
||||
`parent_folder_id` bigint(20) DEFAULT NULL COMMENT '父文件夹ID',
|
||||
`folder_name` varchar(250) DEFAULT NULL COMMENT '文件夹名称',
|
||||
`folder_desc` text DEFAULT NULL COMMENT '文件夹说明',
|
||||
`create_user_id` bigint(20) DEFAULT NULL COMMENT '创建人ID',
|
||||
`create_user_name` varchar(20) DEFAULT NULL COMMENT '创建人名字',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`yn` tinyint(4) DEFAULT NULL COMMENT '是否有效 0=无效 1=有效',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_doc_id` (`doc_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口文档文件夹';
|
||||
|
||||
|
||||
KEY `idx_doc_id` (`doc_id`),
|
||||
KEY `idx_node_id` (`node_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='自建接口参数';
|
||||
|
||||
9172
zyplayer-doc-ui/api-ui/package-lock.json
generated
9172
zyplayer-doc-ui/api-ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -24,7 +24,16 @@ export const zyplayerApi = {
|
||||
docAuthDelete: data => apiClient({url: '/doc-api/doc/auth/delete', method: 'post', data: data}),
|
||||
|
||||
apiCustomFolderAdd: data => apiClient({url: '/api-custom-folder/add', method: 'post', data: data}),
|
||||
apiCustomFolderUpdate: data => apiClient({url: '/api-custom-folder/update', method: 'post', data: data}),
|
||||
apiCustomFolderDelete: data => apiClient({url: '/api-custom-folder/delete', method: 'post', data: data}),
|
||||
apiCustomRequestAdd: data => apiClient({url: '/api-custom-request/add', method: 'post', data: data}),
|
||||
apiCustomRequestDetail: data => apiClient({url: '/api-custom-request/detail', method: 'post', data: data}),
|
||||
apiCustomRequestDelete: data => apiClient({url: '/api-custom-request/delete', method: 'post', data: data}),
|
||||
|
||||
apiCustomNodeAdd: data => apiClient({url: '/api-custom-node/add', method: 'post', data: data}),
|
||||
apiCustomNodeUpdate: data => apiClient({url: '/api-custom-node/update', method: 'post', data: data}),
|
||||
apiCustomNodeDelete: data => apiClient({url: '/api-custom-node/delete', method: 'post', data: data}),
|
||||
apiCustomNodeDetail: data => apiClient({url: '/api-custom-node/detail', method: 'post', data: data}),
|
||||
apiCustomNodeChangeParent: data => apiClient({url: '/api-custom-node/changeParent', method: 'post', data: data}),
|
||||
};
|
||||
|
||||
|
||||
@@ -8,19 +8,20 @@ const methodArray = ["get", "head", "post", "put", "patch", "delete", "options",
|
||||
* @param keywords 过滤关键字
|
||||
* @param metaInfo 接口元信息,点击时放入URL的参数
|
||||
*/
|
||||
export function getTreeDataForTag(customRequest, keywords, metaInfo) {
|
||||
export function getTreeDataForTag(customRequest, keywords, metaInfo, requestInfoMap) {
|
||||
let firstChild = customRequest[0];
|
||||
let treeData = getTreeDataChildren(firstChild, keywords, metaInfo, 1);
|
||||
let treeData = getTreeDataChildren(firstChild, keywords, metaInfo, requestInfoMap, 1);
|
||||
return [
|
||||
{
|
||||
key: 'main',
|
||||
isLeaf: false,
|
||||
title: firstChild.name || '自建API接口文档',
|
||||
children: treeData
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
function getTreeDataChildren(customRequest, keywords, metaInfo, treeIndex) {
|
||||
function getTreeDataChildren(customRequest, keywords, metaInfo, requestInfoMap, treeIndex) {
|
||||
let treeData = [];
|
||||
if (!customRequest) {
|
||||
return treeData;
|
||||
@@ -29,27 +30,37 @@ function getTreeDataChildren(customRequest, keywords, metaInfo, treeIndex) {
|
||||
let indexApi = 1;
|
||||
if (customRequest.children && customRequest.children.length > 0) {
|
||||
customRequest.children.forEach(item => {
|
||||
requestInfoMap.originNodeMap[item.nodeId] = item;
|
||||
let tempTreeId = treeIndex + "_" + indexFolder + "_" + indexApi;
|
||||
let treeChildren = getTreeDataChildren(item, keywords, metaInfo, tempTreeId);
|
||||
treeData.push({title: item.name, key: tempTreeId, folderId: item.folderId, isLeaf: false, children: treeChildren});
|
||||
indexApi++;
|
||||
});
|
||||
}
|
||||
if (customRequest.apis && customRequest.apis.length > 0) {
|
||||
customRequest.apis.forEach(item => {
|
||||
let tempTreeId = treeIndex + "_" + indexFolder + "_" + indexApi;
|
||||
if (item.nodeType === 1) {
|
||||
treeData.push({
|
||||
title: item.apiName,
|
||||
title: item.nodeName,
|
||||
key: tempTreeId,
|
||||
isLeaf: true,
|
||||
method: item.method,
|
||||
folderId: item.folderId,
|
||||
nodeId: item.nodeId,
|
||||
query: {
|
||||
...metaInfo,
|
||||
requestId: item.requestId,
|
||||
nodeId: item.nodeId,
|
||||
}
|
||||
});
|
||||
indexApi++;
|
||||
} else {
|
||||
let treeChildren = getTreeDataChildren(item, keywords, metaInfo, requestInfoMap, tempTreeId);
|
||||
let eureka = searchInCustomRequestFolder(item, keywords);
|
||||
if (treeChildren.length > 0 || eureka) {
|
||||
treeData.push({
|
||||
title: item.nodeName,
|
||||
key: tempTreeId,
|
||||
nodeId: item.nodeId,
|
||||
isLeaf: false,
|
||||
editing: false,
|
||||
titleEditing: item.nodeName,
|
||||
children: treeChildren
|
||||
});
|
||||
indexApi++;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
indexFolder++;
|
||||
@@ -63,16 +74,20 @@ function getTreeDataChildren(customRequest, keywords, metaInfo, treeIndex) {
|
||||
* @param keywords 关键字
|
||||
* @returns {*|boolean} 是否包含
|
||||
*/
|
||||
function searchInPathMethods(url, methodNode, keywords) {
|
||||
if (!keywords || !url) {
|
||||
function searchInCustomRequest(request, keywords) {
|
||||
if (!keywords || !request) {
|
||||
return true;
|
||||
}
|
||||
url = url.toLowerCase();
|
||||
keywords = keywords.toLowerCase();
|
||||
// 路径中有就不用再去找了
|
||||
if (url.indexOf(keywords) >= 0) {
|
||||
return true;
|
||||
}
|
||||
let searchData = methodNode.path + methodNode.method + methodNode.summary + methodNode.description + methodNode.tags;
|
||||
let searchData = request.apiUrl + request.method + request.nodeName;
|
||||
return (searchData && searchData.toLowerCase().indexOf(keywords) >= 0);
|
||||
}
|
||||
|
||||
function searchInCustomRequestFolder(folder, keywords) {
|
||||
if (!keywords || !folder) {
|
||||
return true;
|
||||
}
|
||||
keywords = keywords.toLowerCase();
|
||||
let searchData = folder.name;
|
||||
return (searchData && searchData.toLowerCase().indexOf(keywords) >= 0);
|
||||
}
|
||||
|
||||
@@ -42,8 +42,9 @@
|
||||
}
|
||||
},
|
||||
created() {
|
||||
let {name, path, fullPath} = this.$route;
|
||||
this.pageList.push({name, path, fullPath});
|
||||
let {name, path, fullPath, query} = this.$route;
|
||||
let checkedTab = {name, path, fullPath, query};
|
||||
this.pageList.push(checkedTab);
|
||||
let activePage = this.getRouteRealPath(this.$route);
|
||||
this.linkList.push(activePage);
|
||||
this.activePage = activePage;
|
||||
@@ -55,11 +56,12 @@
|
||||
this.activePage = activePage;
|
||||
if (this.linkList.indexOf(activePage) < 0) {
|
||||
this.linkList.push(activePage);
|
||||
let {name, path, fullPath} = newRoute;
|
||||
this.pageList.push({name, path, fullPath});
|
||||
let {name, path, fullPath, query} = newRoute;
|
||||
this.pageList.push({name, path, fullPath, query});
|
||||
}
|
||||
let pageRoute = this.pageList.find(item => this.getRouteRealPath(item) === activePage);
|
||||
pageRoute.fullPath = newRoute.fullPath;
|
||||
this.$store.commit('setActivePage', pageRoute);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
<template>
|
||||
<a-directory-tree :showIcon="false" :tree-data="treeData" v-model:expandedKeys="expandedKeys" @select="docChecked">
|
||||
<div class="doc-tree-box">
|
||||
<a-directory-tree :showIcon="false" :tree-data="treeData" v-model:expandedKeys="expandedKeys"
|
||||
v-model:selectedKeys="selectedKeys"
|
||||
draggable @drop="treeDataDragEnd"
|
||||
@select="docChecked">
|
||||
<template #title="record">
|
||||
<template v-if="record.key === 'info'">
|
||||
<!--说明-->
|
||||
<div v-if="record.key === 'info'" class="api-title-line">
|
||||
<file-text-outlined style="margin-right: 3px;"/>
|
||||
<span class="tree-title-text">{{record.title}}</span>
|
||||
</div>
|
||||
<div v-if="record.key === 'main'" class="api-title-line">
|
||||
<span class="tree-title-text">{{record.title}}</span>
|
||||
<a-badge :count="record.children.length" showZero :number-style="{backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset'}"/>
|
||||
<a-dropdown :trigger="['click']">
|
||||
<span @click.stop="" style="padding: 3px 10px;"><ellipsis-outlined /></span>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleFolderDropdownClick($event, record)">
|
||||
<a-menu-item key="newRequest"><plus-outlined /> 新建接口</a-menu-item>
|
||||
<a-menu-item key="newFolder"><folder-add-outlined /> 新建文件夹</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<template v-if="record.isLeaf">
|
||||
</a-dropdown>
|
||||
</div>
|
||||
<!--接口-->
|
||||
<div v-if="record.isLeaf" class="api-title-line">
|
||||
<a-tag color="pink" v-if="record.method === 'get'">get</a-tag>
|
||||
<a-tag color="red" v-else-if="record.method === 'post'">post</a-tag>
|
||||
<a-tag color="orange" v-else-if="record.method === 'put'">put</a-tag>
|
||||
@@ -13,41 +33,61 @@
|
||||
<a-tag color="blue" v-else-if="record.method === 'delete'">delete</a-tag>
|
||||
<a-tag color="purple" v-else-if="record.method === 'options'">options</a-tag>
|
||||
<a-tag color="purple" v-else-if="record.method === 'trace'">trace</a-tag>
|
||||
<span class="tree-title-text">
|
||||
{{record.title}}
|
||||
<a-dropdown :trigger="['click']" class="api-title-dropdown">
|
||||
<span @click.stop="" style="padding: 3px 10px;"><ellipsis-outlined /></span>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleApiTitleDropdownClick($event, record)">
|
||||
<a-menu-item key="delete"><delete-outlined /> 删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<span style="margin: 0 6px 0 3px;">{{record.title}}</span>
|
||||
<template v-if="record.children">
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</div>
|
||||
<!--文件夹-->
|
||||
<div v-else-if="record.nodeId" class="api-title-line">
|
||||
<a-popover v-model:visible="record.data.editing" placement="rightTop" title="编辑名称" trigger="click" @visibleChange="editFolderVisibleChange($event, record)">
|
||||
<template #content>
|
||||
<a-input v-model:value="record.data.titleEditing" v-autofocus></a-input>
|
||||
</template>
|
||||
<span class="tree-title-text">{{record.title}}</span>
|
||||
</a-popover>
|
||||
<a-badge :count="record.children.length" showZero :number-style="{backgroundColor: '#fff', color: '#999', boxShadow: '0 0 0 1px #d9d9d9 inset'}"/>
|
||||
<a-dropdown :trigger="['click']">
|
||||
<span @click.stop="" style="padding: 3px 10px;"><ellipsis-outlined /></span>
|
||||
<template #overlay>
|
||||
<a-menu @click="handleMenuClick($event, record)">
|
||||
<a-menu-item key="newRequest">
|
||||
<plus-outlined /> 新建接口
|
||||
</a-menu-item>
|
||||
<a-menu-item key="newFolder">
|
||||
<folder-add-outlined /> 新建文件夹
|
||||
</a-menu-item>
|
||||
<a-menu @click="handleFolderDropdownClick($event, record)">
|
||||
<a-menu-item key="newRequest"><plus-outlined /> 新建接口</a-menu-item>
|
||||
<a-menu-item key="newFolder"><folder-add-outlined /> 新建文件夹</a-menu-item>
|
||||
<a-menu-divider />
|
||||
<a-menu-item key="edit">
|
||||
<edit-outlined /> 编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item key="delete">
|
||||
<delete-outlined /> 删除
|
||||
</a-menu-item>
|
||||
<a-menu-item key="edit"><edit-outlined /> 编辑</a-menu-item>
|
||||
<a-menu-item key="delete"><delete-outlined /> 删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
</a-directory-tree>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {toRefs, ref, reactive, onMounted, watch, nextTick} from 'vue';
|
||||
import {toRefs, ref, reactive, onMounted, createVNode, watch, nextTick} from 'vue';
|
||||
import { useRouter, useRoute } from "vue-router";
|
||||
import {useStore} from 'vuex';
|
||||
import { message } from 'ant-design-vue';
|
||||
import {InfoCircleOutlined, FileTextOutlined, EllipsisOutlined, EditOutlined, DeleteOutlined, FolderAddOutlined, ApiOutlined, PlusOutlined} from '@ant-design/icons-vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
InfoCircleOutlined,
|
||||
FileTextOutlined,
|
||||
EllipsisOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
FolderAddOutlined,
|
||||
ApiOutlined,
|
||||
PlusOutlined,
|
||||
ExclamationCircleOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import {zyplayerApi} from '../../../api'
|
||||
import {getTreeDataForTag} from '../../../assets/core/CustomRequestTreeAnalysis.js'
|
||||
|
||||
@@ -58,10 +98,10 @@
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
let tagPathMap = ref({});
|
||||
let customRequestDoc = {};
|
||||
let treeData = ref([]);
|
||||
let expandedKeys = ref(['main']);
|
||||
let selectedKeys = ref([]);
|
||||
let choiceDocId = '';
|
||||
let searchKeyword = '';
|
||||
|
||||
@@ -71,7 +111,7 @@
|
||||
router.push({path: '/custom/request', query: dataRef.query});
|
||||
}
|
||||
};
|
||||
const loadDoc = (docId, keyword, callback) => {
|
||||
const loadDoc = (docId, keyword, callback = () => {}) => {
|
||||
choiceDocId = docId;
|
||||
zyplayerApi.apiDocApisDetail({id: docId}).then(res => {
|
||||
let v2Doc = res.data;
|
||||
@@ -87,82 +127,197 @@
|
||||
}).catch(() => {
|
||||
callback(false);
|
||||
});
|
||||
};
|
||||
let requestInfoMap = {
|
||||
// 渲染到界面的数据
|
||||
treeRequestMap: {},
|
||||
// 原始map,用于搜索后的重新渲染
|
||||
originNodeMap: {},
|
||||
};
|
||||
const getNodeIdMap = (tree) => {
|
||||
tree.forEach(item => {
|
||||
if (item.isLeaf && item.nodeId) {
|
||||
requestInfoMap.treeRequestMap[item.nodeId] = item;
|
||||
} else if (item.children) {
|
||||
getNodeIdMap(item.children);
|
||||
}
|
||||
});
|
||||
};
|
||||
const loadTreeData = async (keyword) => {
|
||||
let metaInfo = {id: choiceDocId};
|
||||
searchKeyword = keyword;
|
||||
treeData.value = getTreeDataForTag(customRequestDoc, keyword, metaInfo);
|
||||
treeData.value.unshift({key: 'info', title: '文档说明信息', isLeaf: true});
|
||||
treeData.value = getTreeDataForTag(customRequestDoc, keyword, metaInfo, requestInfoMap);
|
||||
getNodeIdMap(treeData.value);
|
||||
};
|
||||
const handleMenuClick = (event, record) => {
|
||||
// 监听自定义请求被修改了的事件
|
||||
watch(store.getters.getCustomRequestChange, () => {
|
||||
let requestChange = store.state.customRequestChange;
|
||||
if (requestChange && requestChange.nodeId && requestChange.nodeName) {
|
||||
// 展示的tree
|
||||
let requestItem = requestInfoMap.treeRequestMap[requestChange.nodeId];
|
||||
if (requestItem) {
|
||||
requestItem.method = requestChange.method;
|
||||
requestItem.title = requestChange.nodeName;
|
||||
}
|
||||
// 原始对象
|
||||
let requestOriginItem = requestInfoMap.originNodeMap[requestChange.nodeId];
|
||||
if (requestOriginItem) {
|
||||
requestOriginItem.method = requestChange.method;
|
||||
requestOriginItem.nodeName = requestChange.nodeName;
|
||||
}
|
||||
}
|
||||
});
|
||||
// 监听Tab页面切换
|
||||
watch(store.getters.getActivePage, () => {
|
||||
let activePage = store.state.activePage;
|
||||
changeSelectedRequestKeys(activePage.query.nodeId);
|
||||
});
|
||||
const editFolderVisibleChange = (visible, record) => {
|
||||
// 点击触发弹出事件不处理
|
||||
if (visible) {
|
||||
record.data.editing = false;
|
||||
return;
|
||||
}
|
||||
let title = record.data.titleEditing;
|
||||
// 没做修改不处理
|
||||
if (title === record.data.title) {
|
||||
return;
|
||||
}
|
||||
zyplayerApi.apiCustomNodeUpdate({id: record.data.nodeId, nodeName: title}).then(res => {
|
||||
record.data.title = title;
|
||||
// 修改原始的文件夹名称
|
||||
let folderItem = requestInfoMap.originNodeMap[record.data.nodeId];
|
||||
if (folderItem) {
|
||||
folderItem.name = title;
|
||||
}
|
||||
});
|
||||
};
|
||||
const handleApiTitleDropdownClick = (event, record) => {
|
||||
if (event.key === 'delete') {
|
||||
Modal.confirm({
|
||||
title: '删除确认',
|
||||
maskClosable: true,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '你确定要删除此接口吗?',
|
||||
okText: '删除',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
zyplayerApi.apiCustomNodeDelete({id: record.data.nodeId}).then(res => {
|
||||
message.success('删除成功');
|
||||
loadDoc(choiceDocId, searchKeyword);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
const handleFolderDropdownClick = (event, record) => {
|
||||
if (event.key === 'newFolder') {
|
||||
let params = {
|
||||
// id: '',
|
||||
nodeType: 0,
|
||||
docId: choiceDocId,
|
||||
parentFolderId: record.folderId,
|
||||
folderName: '新建文件夹',
|
||||
folderDesc: '',
|
||||
parentId: record.nodeId,
|
||||
nodeName: '新建文件夹',
|
||||
nodeDesc: '',
|
||||
};
|
||||
zyplayerApi.apiCustomFolderAdd(params).then(res => {
|
||||
zyplayerApi.apiCustomNodeAdd(params).then(res => {
|
||||
loadDoc(choiceDocId, searchKeyword);
|
||||
});
|
||||
} else if (event.key === 'newRequest') {
|
||||
let params = {
|
||||
// id: '',
|
||||
nodeType: 1,
|
||||
docId: choiceDocId,
|
||||
folderId: record.folderId,
|
||||
apiName: '新建接口',
|
||||
parentId: record.nodeId,
|
||||
nodeName: '新建接口',
|
||||
method: 'get',
|
||||
apiUrl: '',
|
||||
// formData: '测试xxx',
|
||||
// bodyData: '测试xxx',
|
||||
// headerData: '测试xxx',
|
||||
// cookieData: '测试xxx',
|
||||
};
|
||||
zyplayerApi.apiCustomRequestAdd(params).then(res => {
|
||||
loadDoc(choiceDocId, searchKeyword);
|
||||
zyplayerApi.apiCustomNodeAdd(params).then(res => {
|
||||
let requestSaved = res.data;
|
||||
let queryInfo = {
|
||||
id: choiceDocId,
|
||||
requestId: requestSaved.id,
|
||||
nodeId: requestSaved.id,
|
||||
};
|
||||
router.push({path: '/custom/request', query: queryInfo});
|
||||
loadDoc(choiceDocId, searchKeyword, () => {
|
||||
changeSelectedRequestKeys(requestSaved.id);
|
||||
});
|
||||
});
|
||||
} else if (event.key === 'edit') {
|
||||
record.data.editing = true;
|
||||
} else if (event.key === 'delete') {
|
||||
Modal.confirm({
|
||||
title: '删除确认',
|
||||
maskClosable: true,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: '你确定要删除此文件夹及目录下所有二级目录和接口吗?',
|
||||
okText: '删除',
|
||||
cancelText: '取消',
|
||||
onOk() {
|
||||
zyplayerApi.apiCustomNodeDelete({id: record.data.nodeId}).then(res => {
|
||||
message.success('删除成功');
|
||||
loadDoc(choiceDocId, searchKeyword);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
const toJsonObj = (value) => {
|
||||
if (typeof value !== 'string') {
|
||||
return value;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(value);
|
||||
} catch (e) {
|
||||
try {
|
||||
// 处理变态的单双引号共存字符串
|
||||
return eval('(' + value + ')');
|
||||
} catch (e) {
|
||||
return value || undefined;
|
||||
const changeSelectedRequestKeys = (nodeId) => {
|
||||
let treeData = requestInfoMap.treeRequestMap[nodeId];
|
||||
if (treeData) {
|
||||
selectedKeys.value = [treeData.key];
|
||||
}
|
||||
};
|
||||
const treeDataDragEnd = (event) => {
|
||||
let param = {
|
||||
id: event.dragNode.nodeId,
|
||||
parentId: event.node.nodeId,
|
||||
targetType: 0,
|
||||
};
|
||||
if (event.dropToGap) {
|
||||
// 放入event.node的后面
|
||||
console.log(`放入${event.node.key}的后面`);
|
||||
param.targetType = 1;
|
||||
} else {
|
||||
// 放入event.node文件夹的第一个位置
|
||||
console.log(`放入${event.node.key}文件夹内`);
|
||||
}
|
||||
zyplayerApi.apiCustomNodeChangeParent(param).then(res => {
|
||||
message.success('修改排序成功');
|
||||
loadDoc(choiceDocId, searchKeyword);
|
||||
});
|
||||
console.log(event);
|
||||
};
|
||||
return {
|
||||
expandedKeys,
|
||||
selectedKeys,
|
||||
editFolderVisibleChange,
|
||||
docChecked,
|
||||
treeDataDragEnd,
|
||||
loadDoc,
|
||||
loadTreeData,
|
||||
treeData,
|
||||
handleMenuClick,
|
||||
handleFolderDropdownClick,
|
||||
handleApiTitleDropdownClick,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.doc-tree{padding: 10px 4px;}
|
||||
.doc-tree .ant-tree-switcher{width: 15px;}
|
||||
.doc-tree .ant-tree-switcher-noop{width: 0;}
|
||||
.doc-tree .ant-tag{margin-right: 0;}
|
||||
.ant-badge-not-a-wrapper:not(.ant-badge-status) {
|
||||
vertical-align: text-top;
|
||||
/*.doc-tree{padding: 10px 4px;}*/
|
||||
/*.doc-tree .ant-tree-switcher{width: 15px;}*/
|
||||
/*.doc-tree .ant-tree-switcher-noop{width: 0;}*/
|
||||
/*.doc-tree .ant-tag{margin-right: 0;}*/
|
||||
/*.ant-badge-not-a-wrapper:not(.ant-badge-status) {*/
|
||||
/* vertical-align: text-top;*/
|
||||
/*}*/
|
||||
.api-title-line .tree-title-text{
|
||||
margin: 0 6px 0 3px;
|
||||
}
|
||||
.api-title-line .api-title-dropdown{
|
||||
display: none;
|
||||
}
|
||||
.api-title-line:hover .api-title-dropdown{
|
||||
display: unset;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -94,7 +94,6 @@
|
||||
});
|
||||
const propsParamInit = () => {
|
||||
paramListRef.value = props.paramList;
|
||||
console.log('paramListRef.value', paramListRef.value);
|
||||
// Query参数处理
|
||||
if (paramListRef.value.length <= 0 || !paramListRef.value[paramListRef.value.length - 1].isLastRow) {
|
||||
props.paramList.push({name: '', value: undefined, type: 'integer', key: ++nextIndex, isLastRow: true});
|
||||
|
||||
@@ -31,3 +31,11 @@ app.directive('highlight', {
|
||||
}
|
||||
});
|
||||
|
||||
// 聚焦元素
|
||||
app.directive('autofocus', {
|
||||
updated(el) {
|
||||
// 延迟等待弹窗初始完成
|
||||
setTimeout(() => el.focus(), 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -46,63 +46,46 @@ let routers = [
|
||||
]
|
||||
},
|
||||
// 以下是隐藏的菜单路由
|
||||
{
|
||||
path: '/swagger',
|
||||
name: 'swagger文档',
|
||||
meta: {
|
||||
hidden: true,
|
||||
icon: 'SettingOutlined'
|
||||
},
|
||||
component: EmptyKeepAliveLayout,
|
||||
children: [
|
||||
{
|
||||
path: '/swagger/info',
|
||||
name: 'Swagger文档信息',
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
component: () => import('./views/swagger/DocInfo.vue')
|
||||
},
|
||||
{
|
||||
path: '/swagger/view',
|
||||
name: 'Swagger文档展示',
|
||||
component: () => import('./views/swagger/DocView.vue')
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
]
|
||||
component: () => import('./views/swagger/DocView.vue')
|
||||
},
|
||||
// 以下是OpenApi的菜单路由
|
||||
{
|
||||
path: '/openapi',
|
||||
name: 'openApi文档',
|
||||
meta: {
|
||||
hidden: true,
|
||||
icon: 'SettingOutlined'
|
||||
},
|
||||
component: EmptyKeepAliveLayout,
|
||||
children: [
|
||||
{
|
||||
path: '/openapi/info',
|
||||
name: 'OpenApi文档信息',
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
component: () => import('./views/openapi/DocInfo.vue')
|
||||
},
|
||||
{
|
||||
path: '/openapi/view',
|
||||
name: 'OpenApi文档展示',
|
||||
component: () => import('./views/openapi/DocView.vue')
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/custom',
|
||||
name: 'API请求',
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
component: EmptyKeepAliveLayout,
|
||||
children: [
|
||||
component: () => import('./views/openapi/DocView.vue')
|
||||
},
|
||||
{
|
||||
path: '/custom/request',
|
||||
name: '接口请求',
|
||||
component: () => import('./views/customRequest/ApiRequest.vue')
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
]
|
||||
component: () => import('./views/customRequest/ApiRequest.vue')
|
||||
},
|
||||
]
|
||||
},
|
||||
@@ -127,24 +110,20 @@ let routers = [
|
||||
component: () => import('./views/share/ShareHome.vue')
|
||||
},
|
||||
{
|
||||
path: '/doc',
|
||||
name: '开放文档查看',
|
||||
path: '/share/swagger/view',
|
||||
name: 'Swagger开放文档展示',
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
component: EmptyKeepAliveLayout,
|
||||
children: [
|
||||
{
|
||||
path: '/share/swagger/view',
|
||||
name: 'Swagger开放文档展示',
|
||||
component: () => import('./views/swagger/share/DocView.vue')
|
||||
},
|
||||
{
|
||||
path: '/share/openapi/view',
|
||||
name: 'OpenApi开放文档展示',
|
||||
component: () => import('./views/openapi/share/DocView.vue')
|
||||
meta: {
|
||||
hidden: true,
|
||||
},
|
||||
]
|
||||
component: () => import('./views/openapi/share/DocView.vue')
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ export default createStore({
|
||||
return {
|
||||
// 文档改变事件,供其他页面watch
|
||||
docChangedNum: 1,
|
||||
customRequestChange: {},
|
||||
|
||||
// 用户信息
|
||||
userInfo: {},
|
||||
// tab多标签的标签名map{xxx: 'val'}
|
||||
@@ -38,9 +40,14 @@ export default createStore({
|
||||
|
||||
// 自建API原始文档
|
||||
customRequestDoc: {},
|
||||
// 当前选中的Tab页面
|
||||
activePage: {},
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
getCustomRequestChange: (state) => () => {
|
||||
return state.customRequestChange;
|
||||
},
|
||||
getDocChangedNum: (state) => () => {
|
||||
return state.docChangedNum;
|
||||
},
|
||||
@@ -50,6 +57,9 @@ export default createStore({
|
||||
getApiDoc: (state) => () => {
|
||||
return state.apiDoc;
|
||||
},
|
||||
getActivePage: (state) => () => {
|
||||
return state.activePage;
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
setUserInfo(state, userInfo) {
|
||||
@@ -111,6 +121,12 @@ export default createStore({
|
||||
sameObj[item.key] = item.val;
|
||||
state.pageTabNameMap = sameObj;
|
||||
},
|
||||
setCustomRequestChange(state, customRequestChange) {
|
||||
state.customRequestChange = customRequestChange;
|
||||
},
|
||||
setActivePage(state, activePage) {
|
||||
state.activePage = activePage;
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="api-name-box">
|
||||
<a-row type="flex">
|
||||
<a-col flex="auto"><a-input v-model:value="docInfoShow.apiName" :bordered="false" placeholder="请输入接口名称" /></a-col>
|
||||
<a-col flex="auto"><a-input v-model:value="docInfoShow.nodeName" :bordered="false" placeholder="请输入接口名称" /></a-col>
|
||||
<a-col flex="88px">
|
||||
<a-button @click="saveCustomRequest" type="dashed"><save-outlined /> 保存</a-button>
|
||||
</a-col>
|
||||
@@ -92,7 +92,7 @@
|
||||
let activePage = ref('urlParam');
|
||||
const route = useRoute();
|
||||
const store = useStore();
|
||||
const queryParam = {docId: route.query.id, requestId: route.query.requestId};
|
||||
const queryParam = {docId: route.query.id, nodeId: route.query.nodeId};
|
||||
let globalParam = store.state.globalParam || [];
|
||||
let nextIndex = 1;
|
||||
// URL参数处理
|
||||
@@ -125,6 +125,7 @@
|
||||
message.error('请输入请求的目标URL地址');
|
||||
return;
|
||||
}
|
||||
setCustomRequestDefaultValue();
|
||||
const formData = new FormData();
|
||||
let urlParamSelected = urlParamRef.value.getSelectedRowKeys();
|
||||
let urlParamStr = urlParamList.value.filter(item => urlParamSelected.indexOf(item.key) >= 0 && item.name && item.value).map(item => {
|
||||
@@ -164,8 +165,8 @@
|
||||
formData.append('method', docInfoShow.value.method);
|
||||
formData.append('contentType', '');
|
||||
formData.append('docId', queryParam.docId);
|
||||
formData.append('apiName', docInfoShow.value.apiName);
|
||||
formData.append('customRequestId', queryParam.requestId);
|
||||
formData.append('nodeName', docInfoShow.value.nodeName);
|
||||
formData.append('nodeId', queryParam.nodeId);
|
||||
formData.append('headerParam', JSON.stringify(headerParamArr));
|
||||
formData.append('cookieParam', JSON.stringify(cookieParamArr));
|
||||
formData.append('formParam', JSON.stringify(formParamArr));
|
||||
@@ -176,6 +177,7 @@
|
||||
zyplayerApi.requestUrl(formData).then(res => {
|
||||
requestResult.value = res;
|
||||
requestLoading.value = false;
|
||||
changeCustomRequest();
|
||||
}).catch(e => {
|
||||
requestLoading.value = false;
|
||||
});
|
||||
@@ -189,15 +191,24 @@
|
||||
}
|
||||
const activePageChange = () => {
|
||||
queryParamVisible.value = true;
|
||||
}
|
||||
// 改变侧边栏标题
|
||||
const changeCustomRequest = () => {
|
||||
store.commit('setCustomRequestChange', {
|
||||
method: docInfoShow.value.method,
|
||||
nodeId: docInfoShow.value.nodeId,
|
||||
nodeName: docInfoShow.value.nodeName,
|
||||
});
|
||||
store.commit('addTableName', {key: route.fullPath, val: docInfoShow.value.nodeName});
|
||||
}
|
||||
onMounted(async () => {
|
||||
let detailRes = await zyplayerApi.apiCustomRequestDetail({id: route.query.requestId});
|
||||
let detailRes = await zyplayerApi.apiCustomNodeDetail({id: route.query.nodeId});
|
||||
let requestDetail = detailRes.data;
|
||||
if (!requestDetail) {
|
||||
console.log('文档加载失败', detailRes);
|
||||
}
|
||||
docInfoShow.value = requestDetail;
|
||||
store.commit('addTableName', {key: route.fullPath, val: requestDetail.apiName});
|
||||
store.commit('addTableName', {key: route.fullPath, val: requestDetail.nodeName});
|
||||
// Header参数处理
|
||||
let headerParamListProp = [];
|
||||
let headerParamListGlobal = globalParam.filter(item => item.paramType === 2);
|
||||
@@ -234,10 +245,17 @@
|
||||
});
|
||||
// 保存请求内容
|
||||
const saveCustomRequest = () => {
|
||||
zyplayerApi.apiCustomRequestAdd(docInfoShow.value).then(res => {
|
||||
setCustomRequestDefaultValue();
|
||||
zyplayerApi.apiCustomNodeAdd(docInfoShow.value).then(res => {
|
||||
message.success('保存成功');
|
||||
changeCustomRequest();
|
||||
});
|
||||
}
|
||||
const setCustomRequestDefaultValue = () => {
|
||||
if (!docInfoShow.value.nodeName) {
|
||||
docInfoShow.value.nodeName = '新建接口';
|
||||
}
|
||||
}
|
||||
return {
|
||||
activePage,
|
||||
activePageChange,
|
||||
|
||||
24418
zyplayer-doc-ui/wiki-ui/package-lock.json
generated
24418
zyplayer-doc-ui/wiki-ui/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -7,14 +7,16 @@
|
||||
"build": "vue-cli-service build --mode production"
|
||||
},
|
||||
"dependencies": {
|
||||
"@wangeditor/editor": "^0.14.2",
|
||||
"@wangeditor/editor-for-vue": "^0.6.13",
|
||||
"axios": "^0.19.0",
|
||||
"core-js": "^3.3.2",
|
||||
"echarts": "^4.5.0",
|
||||
"element-ui": "^2.15.0",
|
||||
"highlight.js": "^11.3.1",
|
||||
"jquery": "^3.5.1",
|
||||
"js-cookie": "^2.2.1",
|
||||
"mavon-editor": "^2.10.0",
|
||||
"highlight.js": "^11.3.1",
|
||||
"mavon-editor": "^2.10.4",
|
||||
"pouchdb": "^7.1.1",
|
||||
"qrcodejs2": "0.0.2",
|
||||
"sql-formatter": "^2.3.3",
|
||||
|
||||
@@ -174,7 +174,8 @@
|
||||
}
|
||||
},
|
||||
changeWikiPageExpandedKeys(pageId) {
|
||||
this.wikiPageExpandedKeys = [pageId];
|
||||
// 展开没有触发子节点的加载,如果去加载子节点有还找不到当前的node,暂不展开
|
||||
// this.wikiPageExpandedKeys = [pageId];
|
||||
},
|
||||
searchByKeywords() {
|
||||
this.$refs.wikiPageTree.filter(this.searchKeywords);
|
||||
@@ -187,6 +188,7 @@
|
||||
console.log("点击节点:", data);
|
||||
this.nowPageId = data.id;
|
||||
this.$router.push({path: '/page/show', query: {pageId: data.id}});
|
||||
this.handleNodeExpand(data);
|
||||
},
|
||||
handleNodeExpand(node) {
|
||||
if (node.children.length > 0 && node.children[0].needLoad) {
|
||||
@@ -304,26 +306,30 @@
|
||||
},
|
||||
doGetPageList(parentId, node) {
|
||||
let param = {spaceId: this.choiceSpace, parentId: parentId || 0};
|
||||
if (this.nowSpaceShow.treeLazyLoad == 0) {
|
||||
if (this.nowSpaceShow.treeLazyLoad === 0) {
|
||||
param.parentId = null;
|
||||
}
|
||||
pageApi.pageList(param).then(json => {
|
||||
let result = json.data || [];
|
||||
let pathIndex = [];
|
||||
if (this.nowSpaceShow.treeLazyLoad == 0) {
|
||||
pathIndex = result;
|
||||
let treeData = [];
|
||||
if (this.nowSpaceShow.treeLazyLoad === 0) {
|
||||
treeData = result;
|
||||
} else {
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
let item = result[i];
|
||||
item.parentId = item.parentId || 0;
|
||||
item.children = [{label: '', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
|
||||
pathIndex.push(item);
|
||||
item.children = [{name: '加载中...', needLoad: true}];// 初始化一个对象,点击展开时重新查询加载
|
||||
treeData.push(item);
|
||||
}
|
||||
}
|
||||
if (parentId > 0) {
|
||||
node.children = pathIndex;
|
||||
node.children = treeData;
|
||||
} else {
|
||||
this.wikiPageList = pathIndex;
|
||||
this.wikiPageList = treeData;
|
||||
}
|
||||
}).catch(() => {
|
||||
if (parentId > 0) {
|
||||
node.children = [];
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<template>
|
||||
<div style="height: 100%;" class="page-edit-vue">
|
||||
<el-row type="border-card" style="height: 100%;overflow: auto;padding: 20px;box-sizing: border-box;">
|
||||
<el-row :gutter="20">
|
||||
<div style="box-sizing: border-box;background: #f5f5f5;overflow: hidden;">
|
||||
<div style="padding: 8px;font-size: 14px;background: #fff;">
|
||||
<el-row>
|
||||
<el-col :span="16">
|
||||
<template v-if="pageId">
|
||||
<span>编辑方式:</span>
|
||||
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId">
|
||||
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId" size="mini">
|
||||
<el-option label="Markdown" :value="2"></el-option>
|
||||
<el-option label="HTML" :value="1"></el-option>
|
||||
</el-select>
|
||||
@@ -13,39 +14,45 @@
|
||||
<template v-else>
|
||||
<span style="margin-right: 20px;">父级:{{parentWikiPage.name || '/'}}</span>
|
||||
<el-tooltip class="item" content="在根目录创建文档" v-if="parentId">
|
||||
<el-button type="text" @click="changeToRootPath" style="padding: 0 10px;">根目录</el-button>
|
||||
<el-button type="text" @click="changeToRootPath" size="mini" style="padding: 0 10px;">根目录</el-button>
|
||||
</el-tooltip>
|
||||
<span style="margin-left: 50px;">编辑方式:</span>
|
||||
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId">
|
||||
<el-select v-model="wikiPageEdit.editorType" v-on:change="editorTypeChange" :disabled="!!pageId" size="mini">
|
||||
<el-option label="Markdown" :value="2"></el-option>
|
||||
<el-option label="HTML" :value="1"></el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-col>
|
||||
<el-col :span="8" style="text-align: right;">
|
||||
<el-button type="primary" v-on:click="createWikiSave(1)" icon="el-icon-document-checked">保存并查看</el-button>
|
||||
<el-button type="success" v-on:click="createWikiSave(0)" icon="el-icon-check">仅保存</el-button>
|
||||
<el-button v-on:click="createWikiCancel" icon="el-icon-back">取消</el-button>
|
||||
<el-button type="primary" v-on:click="createWikiSave(1)" size="mini" icon="el-icon-document-checked">保存并查看</el-button>
|
||||
<el-button type="success" v-on:click="createWikiSave(0)" size="mini" icon="el-icon-check">仅保存</el-button>
|
||||
<el-button v-on:click="createWikiCancel" size="mini" icon="el-icon-back">取消</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
<div v-show="wikiPageEdit.editorType===2" style="padding: 0 10px 10px 10px;background: #fff;">
|
||||
<el-input v-model="wikiPageEdit.pageTitle" placeholder="请输入标题" class="page-title-input"></el-input>
|
||||
<mavon-editor v-show="wikiPageEdit.editorType===2" ref="mavonEditor" v-model="markdownContent" :toolbars="toolbars"
|
||||
<mavon-editor ref="mavonEditor" v-model="markdownContent" :toolbars="toolbars"
|
||||
:externalLink="false"
|
||||
style="height: calc(100vh - 165px);"
|
||||
@save="createWikiSave(0)" @imgAdd="addMarkdownImage"
|
||||
placeholder="请录入文档内容" class="page-content-editor wang-editor-body"/>
|
||||
<div v-show="wikiPageEdit.editorType===1" id="newPageContentDiv" class="page-content-editor" style="height: calc(100vh - 250px);"></div>
|
||||
</el-row>
|
||||
</div>
|
||||
<div v-show="wikiPageEdit.editorType===1">
|
||||
<WangEditor ref="wangEditor"></WangEditor>
|
||||
</div>
|
||||
<!-- <div v-show="wikiPageEdit.editorType===1" id="newPageContentDiv" class="page-content-editor" style="height: calc(100vh - 250px);"></div>-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import WangEditor from 'wangeditor'
|
||||
import pageApi from '../../common/api/page'
|
||||
import {mavonEditor, markdownIt} from 'mavon-editor'
|
||||
import {mavonEditor} from 'mavon-editor'
|
||||
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
||||
import 'mavon-editor/dist/css/index.css'
|
||||
import "../../common/lib/wangEditor.css";
|
||||
import axios from 'axios'
|
||||
import WangEditor from './editor/WangEditor.vue'
|
||||
|
||||
export default {
|
||||
props: ['spaceId'],
|
||||
@@ -102,7 +109,7 @@
|
||||
};
|
||||
},
|
||||
components: {
|
||||
'mavon-editor': mavonEditor
|
||||
WangEditor, mavonEditor,
|
||||
},
|
||||
destroyed: function () {
|
||||
this.unlockPage();
|
||||
@@ -156,8 +163,10 @@
|
||||
content = this.markdownContent;
|
||||
preview = this.markdownContent;
|
||||
} else {
|
||||
content = this.editor.txt.html();
|
||||
preview = this.editor.txt.text();
|
||||
let pageData = this.$refs.wangEditor.getPageData();
|
||||
content = pageData.html;
|
||||
preview = pageData.text;
|
||||
this.wikiPageEdit.pageTitle = pageData.title;
|
||||
}
|
||||
// 修改内容时强制不能修改父路径,只能在目录上拖动修改
|
||||
let parentId = (this.pageId > 0) ? '' : this.parentId;
|
||||
@@ -193,7 +202,11 @@
|
||||
if (this.wikiPageEdit.editorType === 2) {
|
||||
this.markdownContent = this.pageContent.content || "";
|
||||
} else {
|
||||
this.editor.txt.html(this.pageContent.content || "");
|
||||
// this.editor.txt.html(this.pageContent.content || "");
|
||||
setTimeout(() => {
|
||||
this.$refs.wangEditor.setTitle(this.wikiPage.name || "");
|
||||
this.$refs.wangEditor.setHtml(this.pageContent.content || "");
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -254,14 +267,14 @@
|
||||
});
|
||||
},
|
||||
initEditor() {
|
||||
this.editor = new WangEditor('#newPageContentDiv');
|
||||
this.editor.customConfig.uploadImgServer = process.env.VUE_APP_BASE_API + '/zyplayer-doc-wiki/page/file/wangEditor/upload';
|
||||
this.editor.customConfig.zIndex = 100;
|
||||
this.editor.customConfig.uploadFileName = 'files';
|
||||
this.editor.customConfig.uploadImgMaxLength = 1;
|
||||
this.editor.customConfig.pasteFilterStyle = false;
|
||||
this.editor.customConfig.withCredentials = true;
|
||||
this.editor.create();
|
||||
// this.editor = new WangEditor('#newPageContentDiv');
|
||||
// this.editor.customConfig.uploadImgServer = process.env.VUE_APP_BASE_API + '/zyplayer-doc-wiki/page/file/wangEditor/upload';
|
||||
// this.editor.customConfig.zIndex = 100;
|
||||
// this.editor.customConfig.uploadFileName = 'files';
|
||||
// this.editor.customConfig.uploadImgMaxLength = 1;
|
||||
// this.editor.customConfig.pasteFilterStyle = false;
|
||||
// this.editor.customConfig.withCredentials = true;
|
||||
// this.editor.create();
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -288,7 +301,7 @@
|
||||
padding: 10px 0;
|
||||
}
|
||||
.page-edit-vue .page-title-input{
|
||||
padding: 10px 0;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="showPageHistory" icon="el-icon-time">查看历史版本</el-dropdown-item>
|
||||
<el-dropdown-item command="deletePage" v-if="wikiPageAuth.canDelete==1" icon="el-icon-delete">删除</el-dropdown-item>
|
||||
<el-dropdown-item command="editAuth" v-if="wikiPageAuth.canConfigAuth==1" icon="el-icon-s-check">权限设置</el-dropdown-item>
|
||||
<el-dropdown-item command="showOpenPage" v-if="spaceInfo.openDoc == 1" icon="el-icon-share">查看开放文档</el-dropdown-item>
|
||||
<el-dropdown-item command="showMobileView" v-if="spaceInfo.openDoc == 1" icon="el-icon-mobile-phone">手机端查看</el-dropdown-item>
|
||||
<el-dropdown-item command="deletePage" v-if="wikiPageAuth.canDelete==1" icon="el-icon-delete">删除</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
@@ -196,7 +196,7 @@ import htmlUtil from '../../common/lib/HtmlUtil.js'
|
||||
import pageApi from '../../common/api/page'
|
||||
import userApi from '../../common/api/user'
|
||||
import Navigation from './components/Navigation.vue'
|
||||
import {markdownIt, mavonEditor} from 'mavon-editor'
|
||||
import {mavonEditor} from 'mavon-editor'
|
||||
import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
|
||||
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
||||
import 'mavon-editor/dist/css/index.css'
|
||||
@@ -463,7 +463,7 @@ var page = {
|
||||
history.loading = 2;
|
||||
history.content = json.data || '--';
|
||||
if (this.wikiPage.editorType === 2) {
|
||||
history.content = markdownIt.render(history.content);
|
||||
history.content = mavonEditor.getMarkdownIt().render(history.content);
|
||||
}
|
||||
this.pageHistoryDetail = history.content;
|
||||
this.pageShowDetail = history.content;
|
||||
@@ -505,7 +505,7 @@ var page = {
|
||||
canConfigAuth: result.canConfigAuth,
|
||||
};
|
||||
if (this.wikiPage.editorType === 2) {
|
||||
this.pageContent.content = markdownIt.render(this.pageContent.content);
|
||||
this.pageContent.content = mavonEditor.getMarkdownIt().render(this.pageContent.content);
|
||||
}
|
||||
this.pageShowDetail = this.pageContent.content;
|
||||
// 修改标题
|
||||
|
||||
163
zyplayer-doc-ui/wiki-ui/src/views/page/editor/WangEditor.vue
Normal file
163
zyplayer-doc-ui/wiki-ui/src/views/page/editor/WangEditor.vue
Normal file
@@ -0,0 +1,163 @@
|
||||
<template>
|
||||
<div class="wang-editor-box">
|
||||
<div class="editor-toolbar-box fix-top">
|
||||
<Toolbar class="editor-toolbar"
|
||||
:editorId="editorId"
|
||||
:defaultConfig="toolbarConfig"
|
||||
:mode="mode"
|
||||
/>
|
||||
</div>
|
||||
<div class="wang-editor-content">
|
||||
<div class="editor-container">
|
||||
<div class="title-container">
|
||||
<input v-model="pageTitle" placeholder="请输入标题">
|
||||
</div>
|
||||
<Editor ref="editorTextArea" class="editor-text-area"
|
||||
:editorId="editorId"
|
||||
:defaultConfig="editorConfig"
|
||||
:mode="mode"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import '@wangeditor/editor/dist/css/style.css'
|
||||
import { Editor, Toolbar, getEditor, removeEditor } from '@wangeditor/editor-for-vue'
|
||||
export default {
|
||||
props: ['spaceId'],
|
||||
data() {
|
||||
return {
|
||||
editorId: `w-e-${Math.random().toString().slice(-5)}`,
|
||||
toolbarConfig: {
|
||||
excludeKeys: [
|
||||
"fullScreen", "undo" , "redo"
|
||||
],
|
||||
},
|
||||
editorConfig: {
|
||||
placeholder: '请输入文档内容',
|
||||
scroll: false,
|
||||
MENU_CONF: {
|
||||
uploadImage: {
|
||||
server: process.env.VUE_APP_BASE_API + '/zyplayer-doc-wiki/page/file/wangEditor/upload',
|
||||
fieldName: 'files',
|
||||
// 最大支持50M图片上传
|
||||
maxFileSize: 50 * 1024 * 1024,
|
||||
withCredentials: true,
|
||||
}
|
||||
}
|
||||
},
|
||||
mode: 'default', // or 'simple'
|
||||
defaultHtml: '',
|
||||
editor: {},
|
||||
pageTitle: '',
|
||||
};
|
||||
},
|
||||
components: {
|
||||
Editor, Toolbar,
|
||||
},
|
||||
beforeDestroy() {
|
||||
let editor = getEditor(this.editorId);
|
||||
if (editor == null) return;
|
||||
editor.destroy();
|
||||
removeEditor(this.editorId);
|
||||
},
|
||||
mounted: function () {
|
||||
setTimeout(() => {
|
||||
this.initEditor();
|
||||
}, 0);
|
||||
},
|
||||
methods: {
|
||||
initEditor() {
|
||||
// 点击空白处 focus 编辑器
|
||||
let editorTextArea = this.$refs.editorTextArea.$el;
|
||||
editorTextArea.addEventListener('click', e => {
|
||||
if (e.target.className === 'editor-text-area') {
|
||||
let editor = getEditor(this.editorId);
|
||||
editor.blur();
|
||||
editor.focus(true); // focus 到末尾
|
||||
}
|
||||
});
|
||||
},
|
||||
getPageData() {
|
||||
let editor = getEditor(this.editorId);
|
||||
return {
|
||||
title: this.pageTitle,
|
||||
html: editor.getHtml(),
|
||||
text: editor.getText(),
|
||||
};
|
||||
},
|
||||
setTitle(title) {
|
||||
this.pageTitle = title;
|
||||
},
|
||||
setHtml(content) {
|
||||
let editor = getEditor(this.editorId);
|
||||
editor.select([]);
|
||||
editor.deleteFragment();
|
||||
editor.dangerouslyInsertHtml(content);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.wang-editor-box {
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
.wang-editor-box .top-container {
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
padding-left: 30px;
|
||||
}
|
||||
|
||||
.wang-editor-box .editor-toolbar {
|
||||
width: 1200px;
|
||||
background-color: #FCFCFC;
|
||||
margin: 0 auto;
|
||||
}
|
||||
.wang-editor-box .editor-toolbar-box {
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
background-color: #FCFCFC;
|
||||
}
|
||||
.wang-editor-box .editor-toolbar-box.fix-top {
|
||||
/*position: fixed;*/
|
||||
/*top: 40px;*/
|
||||
/*z-index: 1;*/
|
||||
/*text-align: center;*/
|
||||
/*background: #fff;*/
|
||||
/*width: 100%;*/
|
||||
}
|
||||
.wang-editor-box .wang-editor-content {
|
||||
padding: 20px 0;
|
||||
overflow: auto;
|
||||
height: calc(100vh - 170px);
|
||||
}
|
||||
|
||||
.wang-editor-box .editor-container {
|
||||
width: 850px;
|
||||
margin: 0 auto;
|
||||
background-color: #fff;
|
||||
padding: 20px 50px 50px 50px;
|
||||
border: 1px solid #e8e8e8;
|
||||
box-shadow: 0 2px 10px rgb(0 0 0 / 12%);
|
||||
}
|
||||
|
||||
.wang-editor-box .title-container {
|
||||
padding: 20px 0;
|
||||
border-bottom: 1px solid #e8e8e8;
|
||||
}
|
||||
|
||||
.wang-editor-box .title-container input {
|
||||
font-size: 30px;
|
||||
border: 0;
|
||||
outline: none;
|
||||
width: 100%;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.wang-editor-box .editor-text-area {
|
||||
margin-top: 20px;
|
||||
min-height: 600px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
<script>
|
||||
import pageApi from '../../../../common/api/page'
|
||||
import {mavonEditor, markdownIt} from 'mavon-editor'
|
||||
import {mavonEditor} from 'mavon-editor'
|
||||
import ElImageViewer from 'element-ui/packages/image/src/image-viewer'
|
||||
import { ImagePreview } from 'vant';
|
||||
import 'mavon-editor/dist/markdown/github-markdown.min.css'
|
||||
@@ -75,7 +75,7 @@
|
||||
let pageContent = json.data.pageContent || {};
|
||||
this.pageFileList = json.data.fileList || [];
|
||||
if (this.wikiPage.editorType === 2) {
|
||||
pageContent.content = markdownIt.render(pageContent.content);
|
||||
pageContent.content = mavonEditor.getMarkdownIt().render(pageContent.content);
|
||||
}
|
||||
this.pageShowDetail = pageContent.content;
|
||||
document.title = wikiPage.name || 'WIKI-内容展示';
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
<script>
|
||||
import pageApi from '../../../../common/api/page'
|
||||
import {mavonEditor, markdownIt} from 'mavon-editor'
|
||||
import {mavonEditor} from 'mavon-editor'
|
||||
import unitUtil from '../../../../common/lib/UnitUtil.js'
|
||||
import htmlUtil from '../../../../common/lib/HtmlUtil.js'
|
||||
import Navigation from '../../components/Navigation.vue'
|
||||
@@ -84,7 +84,7 @@
|
||||
let pageContent = json.data.pageContent || {};
|
||||
this.pageFileList = json.data.fileList || [];
|
||||
if (this.wikiPage.editorType === 2) {
|
||||
pageContent.content = markdownIt.render(pageContent.content);
|
||||
pageContent.content = mavonEditor.getMarkdownIt().render(pageContent.content);
|
||||
}
|
||||
this.pageShowDetail = pageContent.content;
|
||||
let wikiTile = wikiPage.name || 'WIKI-内容展示';
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.zyplayer.doc.wiki.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.zyplayer.doc.core.annotation.AuthMan;
|
||||
import com.zyplayer.doc.core.json.DocResponseJson;
|
||||
import com.zyplayer.doc.core.json.ResponseJson;
|
||||
@@ -105,11 +106,11 @@ public class WikiPageFileController {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
DocResponseJson docResponseJson = this.uploadFile(wikiPageFile, file);
|
||||
if (!docResponseJson.isOk()) {
|
||||
resultMap.put("errno", "1");
|
||||
resultMap.put("err", docResponseJson.getErrMsg());
|
||||
resultMap.put("errno", 1);
|
||||
resultMap.put("message", docResponseJson.getErrMsg());
|
||||
} else {
|
||||
resultMap.put("errno", "0");
|
||||
resultMap.put("data", new String[]{wikiPageFile.getFileUrl()});
|
||||
resultMap.put("errno", 0);
|
||||
resultMap.put("data", new JSONObject().fluentPut("url", wikiPageFile.getFileUrl()));
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user