增加自建API接口操作

This commit is contained in:
暮光:城中城
2021-12-22 23:00:10 +08:00
parent 956b3b7c19
commit 7110ce45cc
24 changed files with 1013 additions and 90 deletions

View File

@@ -0,0 +1,41 @@
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.service.manage.ApiCustomFolderService;
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-folder")
public class ApiCustomFolderController {
@Resource
ApiCustomFolderService apiCustomFolderService;
/**
* 获取所有的文档地址
*
* @return 文档内容
* @author 暮光:城中城
* @since 2021年10月16日
*/
@ResponseBody
@PostMapping(value = "/add")
public ResponseJson<Object> add(Long docId, Long parentFolderId) {
return DocResponseJson.ok();
}
}

View File

@@ -0,0 +1,19 @@
package com.zyplayer.doc.api.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
/**
* <p>
* 自建接口文档 前端控制器
* </p>
*
* @author 暮光:城中城
* @since 2021-12-22
*/
@Controller
@RequestMapping("/api-custom")
public class ApiCustomRequestController {
}

View File

@@ -13,8 +13,10 @@ 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.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.manage.ApiCustomRequestService;
import com.zyplayer.doc.data.service.manage.ApiDocService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
@@ -49,6 +51,8 @@ public class ApiDocumentController {
private ApiDocService apiDocService;
@Resource
private SwaggerHttpRequestService swaggerHttpRequestService;
@Resource
ApiCustomRequestService apiCustomRequestService;
/**
* 获取所有的文档地址
@@ -78,7 +82,7 @@ public class ApiDocumentController {
if (!apiDocAuthJudgeService.haveDevelopAuth(apiDoc)) {
return DocResponseJson.warn("没有此文档的查看权限");
}
ApiDocVo apiDocVo = new ApiDocVo();
ApiDocVo apiDocVo = new ApiDocVo();
BeanUtil.copyProperties(apiDoc, apiDocVo);
Integer authType = apiDocAuthJudgeService.haveManageAuth(apiDoc) ? ApiAuthType.MANAGE.getType() : ApiAuthType.DEVELOPER.getType();
apiDocVo.setAuthType(authType);
@@ -148,6 +152,8 @@ public class ApiDocumentController {
}
} else if (Objects.equals(apiDoc.getDocType(), 2) || Objects.equals(apiDoc.getDocType(), 4)) {
apiDocService.saveOrUpdate(apiDoc);
} else if (Objects.equals(apiDoc.getDocType(), 5)) {
apiDocService.saveOrUpdate(apiDoc);
} else {
return DocResponseJson.warn("暂不支持的文档类型");
}
@@ -214,6 +220,10 @@ public class ApiDocumentController {
if (Objects.equals(apiDoc.getDocType(), 2) || Objects.equals(apiDoc.getDocType(), 4)) {
return DocResponseJson.ok(apiDoc.getJsonContent());
}
if (Objects.equals(apiDoc.getDocType(), 5)) {
List<ApiCustomVo> customVoList = apiCustomRequestService.buildCustomApiList(apiDoc.getId());
return DocResponseJson.ok(customVoList);
}
return DocResponseJson.warn("暂不支持的文档类型");
}
}