fix: merge

This commit is contained in:
wenbo.dong 2017-08-10 17:08:39 +08:00
parent 1ea95bbdf8
commit 774d456dbd
9 changed files with 1560 additions and 116 deletions

View File

@ -527,26 +527,35 @@ class projectController extends baseController {
async download(ctx) {
const project_id = ctx.request.query.project_id;
let interfaceInst = yapi.getInst(interfaceModel);
// 根据 project_id 获取接口数据
let count = await interfaceInst.list(project_id);
console.log(count);
if (!project_id) {
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
} else if (!count) {
return ctx.body = yapi.commons.resReturn(null, 401, '项目id不存在');
}
console.log('cont',count);
const arr = JSON.stringify(count.map(function(item) {
// 返回的json模板数据: item.res_body
const mockData = Mock.mock(
yapi.commons.json_parse(item.res_body)
);
return {
path: item.path,
mock: mockData
}
}));
// console.log(arr);
// 返回的json模板数据: item.res_body
const mockData = Mock.mock(
yapi.commons.json_parse(item.res_body)
);
return {
path: item.path,
mock: mockData
}
}));
// console.log(arr);
const fileName = 'mock.js';
ctx.attachment(fileName);
await send(ctx, fileName, { root: __dirname + '/public' });
const res = `
var data = ${arr}`
var data = ${arr};
module.exports = data;`
.trim();
return ctx.body = res;
}

View File

@ -1192,13 +1192,32 @@ var projectController = function (_baseController) {
case 0:
project_id = ctx.request.query.project_id;
interfaceInst = _yapi2.default.getInst(_interface2.default);
// 根据 project_id 获取接口数据
_context12.next = 4;
return interfaceInst.list(project_id);
case 4:
count = _context12.sent;
console.log(count);
if (project_id) {
_context12.next = 9;
break;
}
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
case 9:
if (count) {
_context12.next = 11;
break;
}
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目id不存在'));
case 11:
console.log('cont', count);
arr = (0, _stringify2.default)(count.map(function (item) {
// 返回的json模板数据: item.res_body
var mockData = _mockjs2.default.mock(_yapi2.default.commons.json_parse(item.res_body));
@ -1212,14 +1231,14 @@ var projectController = function (_baseController) {
fileName = 'mock.js';
ctx.attachment(fileName);
_context12.next = 11;
_context12.next = 17;
return send(ctx, fileName, { root: __dirname + '/public' });
case 11:
res = ('\n var data = ' + arr).trim();
case 17:
res = ('\n var data = ' + arr + ';\n module.exports = data;').trim();
return _context12.abrupt('return', ctx.body = res);
case 13:
case 19:
case 'end':
return _context12.stop();
}

View File

@ -191,6 +191,10 @@
<li >
<a href="#-project-search">/project/search</a>
</li>
<li >
<a href="#-project-download">/project/download</a>
</li>
</ul>
@ -224,6 +228,48 @@
</ul>
<!-- <li > -->
<li >
<a href="#col">col</a>
</li>
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#-col-list">/col/list</a>
</li>
<li >
<a href="#-col-add_col">/col/add_col</a>
</li>
<li >
<a href="#-col-case_list">/col/case_list</a>
</li>
<li >
<a href="#-col-add_case">/col/add_case</a>
</li>
<li >
<a href="#-col-case">/col/case</a>
</li>
<li >
<a href="#-col-up_col">/col/up_col</a>
</li>
<li >
<a href="#-col-up_col_index">/col/up_col_index</a>
</li>
<li >
<a href="#-col-del_col">/col/del_col</a>
</li>
</ul>
<!-- <li > -->
<li >
@ -266,7 +312,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/group.js.html#10" target="_blank">./server/controllers/group.js:10</a>
<a href="./static/server/controllers/group.js.html#11" target="_blank">./server/controllers/group.js:11</a>
</p>
@ -313,6 +359,18 @@
<td></td>
</tr>
<tr>
<td>owner_uid</td>
<td>String</td>
<td>组长uid</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
@ -349,7 +407,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/group.js.html#64" target="_blank">./server/controllers/group.js:64</a>
<a href="./static/server/controllers/group.js.html#184" target="_blank">./server/controllers/group.js:184</a>
</p>
@ -411,7 +469,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/group.js.html#83" target="_blank">./server/controllers/group.js:83</a>
<a href="./static/server/controllers/group.js.html#203" target="_blank">./server/controllers/group.js:203</a>
</p>
@ -483,7 +541,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/group.js.html#120" target="_blank">./server/controllers/group.js:120</a>
<a href="./static/server/controllers/group.js.html#240" target="_blank">./server/controllers/group.js:240</a>
</p>
@ -1351,7 +1409,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#35" target="_blank">./server/controllers/project.js:35</a>
<a href="./static/server/controllers/project.js.html#37" target="_blank">./server/controllers/project.js:37</a>
</p>
@ -1492,7 +1550,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#116" target="_blank">./server/controllers/project.js:116</a>
<a href="./static/server/controllers/project.js.html#126" target="_blank">./server/controllers/project.js:126</a>
</p>
@ -1576,7 +1634,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#148" target="_blank">./server/controllers/project.js:148</a>
<a href="./static/server/controllers/project.js.html#169" target="_blank">./server/controllers/project.js:169</a>
</p>
@ -1660,7 +1718,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#181" target="_blank">./server/controllers/project.js:181</a>
<a href="./static/server/controllers/project.js.html#222" target="_blank">./server/controllers/project.js:222</a>
</p>
@ -1738,7 +1796,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#209" target="_blank">./server/controllers/project.js:209</a>
<a href="./static/server/controllers/project.js.html#247" target="_blank">./server/controllers/project.js:247</a>
</p>
@ -1821,7 +1879,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#233" target="_blank">./server/controllers/project.js:233</a>
<a href="./static/server/controllers/project.js.html#271" target="_blank">./server/controllers/project.js:271</a>
</p>
@ -1858,26 +1916,6 @@
<td></td>
</tr>
<tr>
<td>page</td>
<td>Number</td>
<td>分页页码</td>
<td>
</td>
<td></td>
</tr>
<tr>
<td>limit</td>
<td>Number</td>
<td>每页数据条目默认为10</td>
<td>
</td>
<td></td>
</tr>
</table>
</div>
@ -2068,7 +2106,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#279" target="_blank">./server/controllers/project.js:279</a>
<a href="./static/server/controllers/project.js.html#312" target="_blank">./server/controllers/project.js:312</a>
</p>
@ -2140,7 +2178,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#312" target="_blank">./server/controllers/project.js:312</a>
<a href="./static/server/controllers/project.js.html#372" target="_blank">./server/controllers/project.js:372</a>
</p>
@ -2300,7 +2338,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#404" target="_blank">./server/controllers/project.js:404</a>
<a href="./static/server/controllers/project.js.html#463" target="_blank">./server/controllers/project.js:463</a>
</p>
@ -2375,6 +2413,68 @@
<span class="token punctuation">}</span></code></pre>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-project-download" class="page-header subject">
/project/download
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-project-download">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
下载项目的 Mock 数据
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#518" target="_blank">./server/controllers/project.js:518</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>project_id</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
@ -3124,6 +3224,671 @@
<span class="token punctuation">}</span></code></pre>
</div>
<h2 id="col" class="page-header subject">col<a class="hashlink" href="#col">#</a></h2>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-list" class="page-header subject">
/col/list
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-col-list">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取所有接口集
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#12" target="_blank">./server/controllers/interfaceCol.js:12</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>project_id</td>
<td>String</td>
<td>email名称不能为空</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-add_col" class="page-header subject">
/col/add_col
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-col-add_col">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
增加接口集
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#33" target="_blank">./server/controllers/interfaceCol.js:33</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>project_id</td>
<td>Number</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>name</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>desc</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-case_list" class="page-header subject">
/col/case_list
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-col-case_list">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取一个接口集下的所有的接口用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#77" target="_blank">./server/controllers/interfaceCol.js:77</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>col_id</td>
<td>String</td>
<td>接口集id</td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-add_case" class="page-header subject">
/col/add_case
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-col-add_case">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
增加一个接口用例
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#99" target="_blank">./server/controllers/interfaceCol.js:99</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>casename</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>col_id</td>
<td>Number</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>project_id</td>
<td>Number</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>env</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>domain</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>path</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>method</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>req_query</td>
<td>Object</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>req_headers</td>
<td>Object</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>req_body_type</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>req_body_form</td>
<td>Array</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>req_body_other</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-case" class="page-header subject">
/col/case
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-col-case">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
获取一个接口用例详情
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#164" target="_blank">./server/controllers/interfaceCol.js:164</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>caseid</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-up_col" class="page-header subject">
/col/up_col
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-col-up_col">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新一个接口集name或描述
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#185" target="_blank">./server/controllers/interfaceCol.js:185</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>name</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>desc</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-up_col_index" class="page-header subject">
/col/up_col_index
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-col-up_col_index">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
更新多个接口case index
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#211" target="_blank">./server/controllers/interfaceCol.js:211</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id, index</td>
<td>Array</td>
<td></td>
<td>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-col-del_col" class="page-header subject">
/col/del_col
<span class="ui-badge">GET</span>
<a class="hashlink" href="#-col-del_col">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
删除一个接口集
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/interfaceCol.js.html#243" target="_blank">./server/controllers/interfaceCol.js:243</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td></td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
@ -3147,7 +3912,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/log.js.html#12" target="_blank">./server/controllers/log.js:12</a>
<a href="./static/server/controllers/log.js.html#28" target="_blank">./server/controllers/log.js:28</a>
</p>

View File

@ -28,6 +28,10 @@
import yapi from '../yapi.js';
import projectModel from '../models/project.js';
import userModel from '../models/user.js';
import interfaceModel from '../models/interface.js'
import groupModel from '../models/group.js'
import _ from 'underscore'
const jwt = require('jsonwebtoken');
class baseController {
@ -87,7 +91,7 @@ class baseController {
async getLoginStatus(ctx) {
if (await this.checkLogin(ctx) === true) {
let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time','role']);
let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role']);
result.server_ip = yapi.WEBCONFIG.server_ip;
return ctx.body = yapi.commons.resReturn(result);
}
@ -98,44 +102,77 @@ class baseController {
return this.$user.role;
}
async jungeProjectAuth(id) {
let model = yapi.getInst(projectModel);
/**
*
* @param {*} id type对应的id
* @param {*} type enum[interface, project, group]
* @param {*} action enum[ danger , edit ] danger只有owner或管理员才能操作,edit只要是dev或以上就能执行
*/
async checkAuth(id, type, action) {
let result = {};
try {
if (this.getRole() === 'admin') {
return true;
}
if (type === 'interface') {
let interfaceInst = yapi.getInst(interfaceModel);
let interfaceData = await interfaceInst.get(id)
result.interfaceData = interfaceData;
if (interfaceData.uid === this.getUid()) {
return true;
}
type = 'project';
id = interfaceData.project_id;
}
if (this.getRole() === 'admin') {
return true;
}
if (type === 'project') {
let projectInst = yapi.getInst(projectModel);
let projectData = await projectInst.get(id);
if(projectData.uid === this.getUid()){
return true;
}
let memberData = _.find(projectData.members, (m) => {
if (m.uid === this.getUid()) {
return true;
}
})
if (memberData && memberData.role) {
if(action === 'danger' && memberData.role === 'owner'){
return true;
}
if(action === 'edit'){
return true;
}
}
type = 'group';
id = projectData.group_id
}
if (type === 'group') {
let groupInst = yapi.getInst(groupModel);
let groupData = await groupInst.get(id);
let groupMemberData = _.find(groupData.members, (m) => {
if (m.uid === this.getUid()) {
return true;
}
})
if (groupMemberData && groupMemberData.role) {
if(action === 'danger' && groupMemberData.role === 'owner'){
return true;
}
if(action === 'edit'){
return true;
}
}
}
if (!id) {
return false;
}
let result = await model.get(id);
if (result.uid === this.getUid()) {
return true;
}
return false;
}
async jungeMemberAuth(id, member_uid) {
let model = yapi.getInst(projectModel);
if (this.getRole() === 'admin') {
return true;
}
if (!id || !member_uid) {
catch (e) {
yapi.commons.log(e.message, 'error')
return false;
}
let result = await model.checkMemberRepeat(id, member_uid);
if (result > 0) {
return true;
}
return false;
}
}

View File

@ -29,6 +29,7 @@
import yapi from '../yapi.js';
import baseController from './base.js';
import projectModel from '../models/project.js';
import userModel from '../models/user.js';
class groupController extends baseController {
constructor(ctx) {
@ -42,7 +43,8 @@ class groupController extends baseController {
* @category group
* @foldnumber 10
* @param {String} group_name 项目分组名称,不能为空
* @param {String} [group_desc] 项目分组描述
* @param {String} [group_desc] 项目分组描述
* @param {String} owner_uid 组长uid
* @returns {Object}
* @example ./api/group/add.json
*/
@ -51,7 +53,8 @@ class groupController extends baseController {
params = yapi.commons.handleParams(params, {
group_name: 'string',
group_desc: 'string'
group_desc: 'string',
owner_uid: 'number'
});
if (this.getRole() !== 'admin') {
@ -62,6 +65,14 @@ class groupController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组名不能为空');
}
if(!params.owner_uid){
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组必须添加一个组长');
}
let groupUserdata = await this.getUserdata(params.owner_uid, 'owner');
if(groupUserdata === null){
return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
}
let groupInst = yapi.getInst(groupModel);
let checkRepeat = await groupInst.checkRepeat(params.group_name);
@ -75,13 +86,14 @@ class groupController extends baseController {
group_desc: params.group_desc,
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
up_time: yapi.commons.time(),
members: [groupUserdata]
};
try {
let result = await groupInst.save(data);
result = yapi.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid']);
result = yapi.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid', 'members']);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -89,6 +101,114 @@ class groupController extends baseController {
}
async getUserdata(uid, role){
role = role || 'dev';
let userInst = yapi.getInst(userModel);
let userData = await userInst.findById(uid);
if(!userData){
return null;
}
return {
role: role,
uid: userData._id,
username: userData.username,
email: userData.email
}
}
async addMember(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
if (!params.member_uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空');
}
if (!params.id) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
}
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
if (check > 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '成员已存在');
}
let groupUserdata = await this.getUserdata(params.member_uid);
if(groupUserdata === null){
return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
}
try {
let result = await groupInst.addMember(params.id, groupUserdata);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
async changeMemberRole(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
if (!params.member_uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空');
}
if (!params.id) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
}
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
params.role = params.role === 'owner' ? 'owner' : 'dev';
try {
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
async getMemberList(ctx) {
let params = ctx.request.query;
if (!params.id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
try {
let groupInst = yapi.getInst(groupModel);
let group = await groupInst.get(params.id);
ctx.body = yapi.commons.resReturn(group.members);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
async delMember(ctx) {
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
if (!params.member_uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空');
}
if (!params.id) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
}
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
try {
let result = await groupInst.delMember(params.id, params.member_uid);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 获取项目分组列表
* @interface /group/list
@ -158,12 +278,10 @@ class groupController extends baseController {
* @example ./api/group/up.json
*/
async up(ctx) {
if (this.getRole() !== 'admin') {
return ctx.body = yapi.commons.resReturn(null, 401, '没有权限');
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
try {
ctx.request.body = yapi.commons.handleParams(ctx.request.body, {
id: 'number',
group_name: 'string',

View File

@ -0,0 +1,376 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<title>YApi : ./server/controllers/interfaceCol.js</title>
<link type="text/css" rel="stylesheet" href="../../../source/code.css"/>
<script type="text/javascript" src="../../../source/shCore.js"></script>
<script type="text/javascript" src="../../../source/shBrush-js.js"></script>
<style>
.syntaxhighlighter .number1 .spaces,.syntaxhighlighter .toolbar{ display: none;}
.syntaxhighlighter table td.gutter .line.highlight { background-color: #6ce26c !important; color: white; }
</style>
</head>
<body>
<div class="ydoc">
<div class="ydoc-banner-bg">
<div class="ydoc-banner" id="content" tabindex="-1">
<div class="ydoc-banner-area">
<h1>YApi : ./server/controllers/interfaceCol.js</h1>
<p>源代码</p>
</div>
</div>
<div class="ydoc-container">
<div class="ydoc-container-content">
<div class="static-code-content" role="main">
<pre class="brush: js;">
import interfaceColModel from '../models/interfaceCol.js';
import interfaceCaseModel from '../models/interfaceCase.js';
import baseController from './base.js';
import yapi from '../yapi.js';
class interfaceColController extends baseController{
constructor(ctx) {
super(ctx);
this.colModel = yapi.getInst(interfaceColModel);
this.caseModel = yapi.getInst(interfaceCaseModel);
}
/**
* 获取所有接口集
* @interface /col/list
* @method GET
* @category col
* @foldnumber 10
* @param {String} project_id email名称不能为空
* @returns {Object}
* @example
*/
async list(ctx){
try {
let id = ctx.query.project_id;
let inst = this.colModel(interfaceColModel);
let result = await inst.list(id);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 增加接口集
* @interface /col/add_col
* @method POST
* @category col
* @foldnumber 10
* @param {Number} project_id
* @param {String} name
* @param {String} desc
* @returns {Object}
* @example
*/
async addCol(ctx){
try{
let params = ctx.request.body;
params = yapi.commons.handleParams(params, {
name: 'string',
project_id: 'number',
desc: 'string'
});
if (!params.project_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
if(!params.name){
return ctx.body = yapi.commons.resReturn(null, 400, '名称不能为空');
}
let result = await this.colModel.save({
name: params.name,
project_id: params.project_id,
desc: params.desc,
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
})
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 获取一个接口集下的所有的接口用例
* @interface /col/case_list
* @method GET
* @category col
* @foldnumber 10
* @param {String} col_id 接口集id
* @returns {Object}
* @example
*/
async getCaseList(ctx){
try {
let id = ctx.query.col_id;
let inst = yapi.getInst(interfaceCaseModel);
let result = await inst.list(id);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 增加一个接口用例
* @interface /col/add_case
* @method POST
* @category col
* @foldnumber 10
* @param {String} casename
* @param {Number} col_id
* @param {Number} project_id
* @param {String} env
* @param {String} domain
* @param {String} path
* @param {String} method
* @param {Object} req_query
* @param {Object} req_headers
* @param {String} req_body_type
* @param {Array} req_body_form
* @param {String} req_body_other
* @returns {Object}
* @example
*/
async addCase(ctx){
try{
let params = ctx.request.body;
params = yapi.commons.handleParams(params, {
casename: 'string',
project_id: 'number',
col_id: 'number',
env: 'string',
domain: 'string',
method: 'string'
});
if (!params.project_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
if (!params.col_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
if (!params.env) {
return ctx.body = yapi.commons.resReturn(null, 400, '缺少环境配置');
}
if (!params.path) {
return ctx.body = yapi.commons.resReturn(null, 400, 'path 不能为空');
}
if(!params.casename){
return ctx.body = yapi.commons.resReturn(null, 400, '用例名称不能为空');
}
params.uid = this.getUid();
params.index = 0;
params.add_time = yapi.commons.time();
params.up_time = yapi.commons.time();
let result = await this.caseModel.save(params);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 获取一个接口用例详情
* @interface /col/case
* @method GET
* @category col
* @foldnumber 10
* @param {String} caseid
* @returns {Object}
* @example
*/
async getCase(ctx){
try{
let id = ctx.query.caseid;
let result = await this.caseModel.get(id);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
/**
* 更新一个接口集name或描述
* @interface /col/up_col
* @method POST
* @category col
* @foldnumber 10
* @param {String} name
* @param {String} desc
* @returns {Object}
* @example
*/
async upCol(ctx){
try{
let params = ctx.request.body;
let result = await this.caseModel.up(params.col_id, {
name: params.col_name,
desc: params.col_desc,
up_time: yapi.commons.time()
})
ctx.body = yapi.commons.resReturn(result)
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
/**
* 更新多个接口case index
* @interface /col/up_col_index
* @method POST
* @category col
* @foldnumber 10
* @param {Array} [id, index]
* @returns {Object}
* @example
*/
async upCaseIndex(ctx){
try{
let params = ctx.request.body;
if(!params || !Array.isArray(params)){
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
params.forEach((item) => {
if(item.id && item.index){
this.caseModel.upCaseIndex(item.id, item.index).then((res) => {}, (err) => {
yapi.commons.log(err.message, 'error')
})
}
})
return ctx.body = yapi.commons.resReturn('success')
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
}
}
/**
* 删除一个接口集
* @interface /col/del_col
* @method GET
* @category col
* @foldnumber 10
* @param {String}
* @returns {Object}
* @example
*/
async delCol(ctx){
try{
let id = ctx.request.body.colid;
let colData = await this.colModel.get(id);
if(!colData){
ctx.body = yapi.commons.resReturn(null, 400, "不存在的id")
}
if(colData.uid !== this.getUid()){
let auth = await this.checkAuth(colData.project_id, 'project', 'danger')
if(!auth){
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
}
let result = await this.colModel.del(caseid);
return ctx.body = yapi.commons.resReturn(result);
}catch(e){
yapi.commons.resReturn(null, 400, e.message)
}
}
/**
*
* @param {*} ctx
*/
async delCase(ctx){
try{
let caseid = ctx.request.body.caseid;
let caseData = await this.caseModel.get(caseid);
if(!caseData){
ctx.body = yapi.commons.resReturn(null, 400, "不存在的caseid")
}
if(caseData.uid !== this.getUid()){
let auth = await this.checkAuth(caseData.project_id, 'project', 'danger')
if(!auth){
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
}
let result = await this.caseModel.del(caseid);
return ctx.body = yapi.commons.resReturn(result);
}catch(e){
yapi.commons.resReturn(null, 400, e.message)
}
}
}
module.exports = interfaceColController
</pre>
</div>
</div>
</div>
</div>
<!-- <div class="docs-header" id="content" tabindex="-1">
<div class="container">
<h1>YApi : ./server/controllers/interfaceCol.js</h1>
<p>源代码</p>
</div>
</div> -->
<footer class="docs-footer" role="contentinfo">
<div class="container">
<p></p>
</div>
</footer>
</div>
<script type="text/javascript">
SyntaxHighlighter.all();
function getTop(node){
return node.offsetTop + (node.offsetParent ? getTop(node.offsetParent) : 0);
}
document.addEventListener('DOMContentLoaded', function() {
setTimeout(function() {
try {
var lineNum = (parseInt(location.hash.replace(/#/g, '')) - 1) || 0,
node = document.querySelectorAll('div.line')[lineNum];
document.body.scrollTop = getTop(node);
node.className += ' highlight';
} catch(e) {}
}, 500);
}, false);
</script>
</body>
</html>

View File

@ -35,6 +35,22 @@ class logController extends baseController {
super(ctx);
this.Model = yapi.getInst(logModel);
this.groupModel = yapi.getInst(groupModel);
try{
// var res = this.Model.save({
// uid: 107,
// typeid: 21,
// type: 'project',
// username: '小明明宝宝',
// content: '小明应该修改了的项目宝宝',
// time: yapi.commons.time()
// });
// var res = this.Model.del(107);
// ctx.body = yapi.commons.resReturn(null, 200,res);
}catch(err){
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
}
}
/**
@ -49,19 +65,19 @@ class logController extends baseController {
* @returns {Object}
* @example ./api/project/list.json
*/
async list(ctx) {
let uid = ctx.request.query.uid,
let typeid = ctx.request.query.typeid,
page = ctx.request.query.page || 1,
limit = ctx.request.query.limit || 10;
if (!uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '用户id不能为空');
if (!typeid) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
try {
let result = await this.Model.listWithPaging(uid, page, limit);
let count = await this.Model.listCount(uid);
let result = await this.Model.listWithPaging(typeid, page, limit);
let count = await this.Model.listCount(typeid);
ctx.body = yapi.commons.resReturn({
total: Math.ceil(count / limit),

View File

@ -32,6 +32,8 @@ import interfaceModel from '../models/interface.js';
import groupModel from '../models/group';
import commons from '../utils/commons.js';
import userModel from '../models/user.js';
import Mock from 'mockjs';
const send = require('koa-send');
class projectController extends baseController {
@ -85,6 +87,11 @@ class projectController extends baseController {
group_id: 'number',
desc: 'string'
});
if (await this.checkAuth(params.group_id, 'group', 'edit') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
if (!params.group_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
}
@ -99,7 +106,7 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的项目名');
}
if (!params.prd_host) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目domain不能为空');
}
@ -120,13 +127,16 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 401, '已存在domain和basepath');
}
let data = {
name: params.name,
desc: params.desc,
prd_host: params.prd_host,
basepath: params.basepath,
protocol: params.protocol || 'http',
members: [this.getUid()],
members: [],
project_type: params.project_type || 'private',
uid: this.getUid(),
group_id: params.group_id,
add_time: yapi.commons.time(),
@ -161,12 +171,23 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
}
if (await this.checkAuth(params.id, 'project', 'edit') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
var check = await this.Model.checkMemberRepeat(params.id, params.member_uid);
if (check > 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员已存在');
}
let userdata = await this.getUserdata(params.member_uid);
if(userdata === null){
return ctx.body = yapi.commons.resReturn(null, 400, '成员uid不存在')
}
try {
let result = await this.Model.addMember(params.id, params.member_uid);
let result = await this.Model.addMember(params.id, userdata);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -198,6 +219,10 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员不存在');
}
if (await this.checkAuth(params.id, 'project', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
try {
let result = await this.Model.delMember(params.id, params.member_uid);
ctx.body = yapi.commons.resReturn(result);
@ -206,6 +231,22 @@ class projectController extends baseController {
}
}
async getUserdata(uid, role){
role = role || 'dev';
let userInst = yapi.getInst(userModel);
let userData = await userInst.findById(uid);
if(!userData){
return null;
}
return {
role: role,
uid: userData._id,
username: userData.username,
email: userData.email
}
}
/**
* 获取项目成员列表
* @interface /project/get_member_list
@ -225,10 +266,7 @@ class projectController extends baseController {
try {
let project = await this.Model.get(params.id);
let userInst = yapi.getInst(userModel);
let result = await userInst.findByUids(project.members);
ctx.body = yapi.commons.resReturn(result);
ctx.body = yapi.commons.resReturn(project.members);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
@ -265,24 +303,20 @@ class projectController extends baseController {
* @category project
* @foldnumber 10
* @param {Number} group_id 项目group_id不能为空
* @param {Number} [page] 分页页码
* @param {Number} [limit] 每页数据条目默认为10
* @returns {Object}
* @example ./api/project/list.json
*/
async list(ctx) {
let group_id = ctx.request.query.group_id,
page = ctx.request.query.page || 1,
limit = ctx.request.query.limit || 10;
let group_id = ctx.request.query.group_id
if (!group_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
}
let auth =await this.checkAuth(group_id, 'group', 'edit')
try {
let result = await this.Model.listWithPaging(group_id, page, limit);
let count = await this.Model.listCount(group_id);
let result = await this.Model.list(group_id, auth);
let uids = [];
result.forEach((item) => {
if (uids.indexOf(item.uid) === -1) {
@ -295,7 +329,6 @@ class projectController extends baseController {
_users[item._id] = item;
});
ctx.body = yapi.commons.resReturn({
total: Math.ceil(count / limit),
list: result,
userinfo: _users
});
@ -327,7 +360,7 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 400, '请先删除该项目下所有接口');
}
if (await this.jungeProjectAuth(id) !== true) {
if (await this.checkAuth(id, 'project', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
let result = await this.Model.del(id);
@ -337,6 +370,33 @@ class projectController extends baseController {
}
}
async changeMemberRole(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
if (!params.member_uid) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空');
}
if (!params.id) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
}
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
params.role = params.role === 'owner' ? 'owner' : 'dev';
try {
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 编辑项目
* @interface /project/up
@ -372,7 +432,7 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
if (await this.jungeMemberAuth(id, this.getUid()) !== true) {
if (await this.checkAuth(id, 'project', 'edit') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@ -409,7 +469,6 @@ class projectController extends baseController {
}
let data = {
uid: this.getUid(),
up_time: yapi.commons.time()
};
@ -483,6 +542,50 @@ class projectController extends baseController {
return ctx.body = yapi.commons.resReturn(queryList, 0, 'ok');
}
/**
* 下载项目的 Mock 数据
* @interface /project/download
* @method GET
* @category project
* @foldnumber 10
* @param {String} project_id
*/
async download(ctx) {
const project_id = ctx.request.query.project_id;
let interfaceInst = yapi.getInst(interfaceModel);
// 根据 project_id 获取接口数据
let count = await interfaceInst.list(project_id);
if (!project_id) {
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
} else if (!count) {
return ctx.body = yapi.commons.resReturn(null, 401, '项目id不存在');
}
console.log('cont',count);
const arr = JSON.stringify(count.map(function(item) {
// 返回的json模板数据: item.res_body
const mockData = Mock.mock(
yapi.commons.json_parse(item.res_body)
);
return {
path: item.path,
mock: mockData
}
}));
// console.log(arr);
const fileName = 'mock.js';
ctx.attachment(fileName);
await send(ctx, fileName, { root: __dirname + '/public' });
const res = `
var data = ${arr};
module.exports = data;`
.trim();
return ctx.body = res;
}
}
module.exports = projectController;

View File

@ -548,6 +548,7 @@ class userController extends baseController {
let interfaceData = await interfaceInst.get(id)
result["interface_id"] = interfaceData._id;
result["interface_name"] = interfaceData.path;
type = 'project';
id = interfaceData.project_id;
}