MCPcopy Index your code
hub / github.com/YMFE/yapi / list

Method list

server/controllers/interfaceCol.js:28–63  ·  view source on GitHub ↗

* 获取所有接口集 * @interface /col/list * @method GET * @category col * @foldnumber 10 * @param {String} project_id email名称,不能为空 * @returns {Object} * @example

(ctx)

Source from the content-addressed store, hash-verified

26 * @example
27 */
28 async list(ctx) {
29 try {
30 let id = ctx.query.project_id;
31 let project = await this.projectModel.getBaseInfo(id);
32 if (project.project_type === 'private') {
33 if ((await this.checkAuth(project._id, 'project', 'view')) !== true) {
34 return (ctx.body = yapi.commons.resReturn(null, 406, '没有权限'));
35 }
36 }
37 let result = await this.colModel.list(id);
38 result = result.sort((a, b) => {
39 return a.index - b.index;
40 });
41
42 for (let i = 0; i < result.length; i++) {
43 result[i] = result[i].toObject();
44 let caseList = await this.caseModel.list(result[i]._id);
45
46 for(let j=0; j< caseList.length; j++){
47 let item = caseList[j].toObject();
48 let interfaceData = await this.interfaceModel.getBaseinfo(item.interface_id);
49 item.path = interfaceData.path;
50 caseList[j] = item;
51 }
52
53 caseList = caseList.sort((a, b) => {
54 return a.index - b.index;
55 });
56 result[i].caseList = caseList;
57
58 }
59 ctx.body = yapi.commons.resReturn(result);
60 } catch (e) {
61 ctx.body = yapi.commons.resReturn(null, 402, e.message);
62 }
63 }
64
65 /**
66 * 增加接口集

Callers 3

getCaseEnvListMethod · 0.45
cloneCaseListMethod · 0.45

Calls 3

getBaseInfoMethod · 0.80
getBaseinfoMethod · 0.80
checkAuthMethod · 0.45

Tested by

no test coverage detected