mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
docs: 文档更新
This commit is contained in:
parent
244fa0003d
commit
280dc96d9d
@ -2092,7 +2092,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#149" target="_blank">./server/controllers/project.js:149</a>
|
||||
<a href="./static/server/controllers/project.js.html#148" target="_blank">./server/controllers/project.js:148</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2176,7 +2176,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#202" target="_blank">./server/controllers/project.js:202</a>
|
||||
<a href="./static/server/controllers/project.js.html#201" target="_blank">./server/controllers/project.js:201</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2260,7 +2260,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#265" target="_blank">./server/controllers/project.js:265</a>
|
||||
<a href="./static/server/controllers/project.js.html#264" target="_blank">./server/controllers/project.js:264</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2338,7 +2338,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#290" target="_blank">./server/controllers/project.js:290</a>
|
||||
<a href="./static/server/controllers/project.js.html#289" target="_blank">./server/controllers/project.js:289</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2421,7 +2421,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#322" target="_blank">./server/controllers/project.js:322</a>
|
||||
<a href="./static/server/controllers/project.js.html#321" target="_blank">./server/controllers/project.js:321</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3032,7 +3032,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#581" target="_blank">./server/controllers/project.js:581</a>
|
||||
<a href="./static/server/controllers/project.js.html#585" target="_blank">./server/controllers/project.js:585</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3127,7 +3127,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#635" target="_blank">./server/controllers/project.js:635</a>
|
||||
<a href="./static/server/controllers/project.js.html#639" target="_blank">./server/controllers/project.js:639</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3192,7 +3192,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#15" target="_blank">./server/controllers/interface.js:15</a>
|
||||
<a href="./static/server/controllers/interface.js.html#18" target="_blank">./server/controllers/interface.js:18</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3513,7 +3513,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#134" target="_blank">./server/controllers/interface.js:134</a>
|
||||
<a href="./static/server/controllers/interface.js.html#137" target="_blank">./server/controllers/interface.js:137</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3578,7 +3578,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#159" target="_blank">./server/controllers/interface.js:159</a>
|
||||
<a href="./static/server/controllers/interface.js.html#162" target="_blank">./server/controllers/interface.js:162</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3643,7 +3643,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#221" target="_blank">./server/controllers/interface.js:221</a>
|
||||
<a href="./static/server/controllers/interface.js.html#224" target="_blank">./server/controllers/interface.js:224</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3876,7 +3876,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#376" target="_blank">./server/controllers/interface.js:376</a>
|
||||
<a href="./static/server/controllers/interface.js.html#379" target="_blank">./server/controllers/interface.js:379</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4181,7 +4181,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#12" target="_blank">./server/controllers/interfaceCol.js:12</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#16" target="_blank">./server/controllers/interfaceCol.js:16</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4243,7 +4243,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#37" target="_blank">./server/controllers/interfaceCol.js:37</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#41" target="_blank">./server/controllers/interfaceCol.js:41</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4329,7 +4329,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#94" target="_blank">./server/controllers/interfaceCol.js:94</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#98" target="_blank">./server/controllers/interfaceCol.js:98</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4391,7 +4391,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#116" target="_blank">./server/controllers/interfaceCol.js:116</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#128" target="_blank">./server/controllers/interfaceCol.js:128</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4573,7 +4573,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#192" target="_blank">./server/controllers/interfaceCol.js:192</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#208" target="_blank">./server/controllers/interfaceCol.js:208</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4743,7 +4743,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#259" target="_blank">./server/controllers/interfaceCol.js:259</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#277" target="_blank">./server/controllers/interfaceCol.js:277</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4805,7 +4805,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#280" target="_blank">./server/controllers/interfaceCol.js:280</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#327" target="_blank">./server/controllers/interfaceCol.js:327</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4879,7 +4879,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#321" target="_blank">./server/controllers/interfaceCol.js:321</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#368" target="_blank">./server/controllers/interfaceCol.js:368</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4939,7 +4939,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#363" target="_blank">./server/controllers/interfaceCol.js:363</a>
|
||||
<a href="./static/server/controllers/interfaceCol.js.html#410" target="_blank">./server/controllers/interfaceCol.js:410</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
@ -27,6 +27,8 @@
|
||||
<pre class="brush: js;">
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import interfaceCatModel from '../models/interfaceCat.js';
|
||||
import interfaceCaseModel from '../models/interfaceCase.js'
|
||||
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
import userModel from '../models/user.js';
|
||||
@ -38,6 +40,7 @@ class interfaceController extends baseController {
|
||||
this.Model = yapi.getInst(interfaceModel);
|
||||
this.catModel = yapi.getInst(interfaceCatModel);
|
||||
this.projectModel = yapi.getInst(projectModel);
|
||||
this.caseModel = yapi.getInst(interfaceCaseModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -431,7 +434,7 @@ class interfaceController extends baseController {
|
||||
|
||||
let inter = await this.Model.get(id);
|
||||
let result = await this.Model.del(id);
|
||||
|
||||
await this.caseModel.delByInterfaceId(id);
|
||||
let username = this.getUsername();
|
||||
this.catModel.get(inter.catid).then((cate)=>{
|
||||
yapi.commons.saveLog({
|
||||
|
@ -27,6 +27,8 @@
|
||||
<pre class="brush: js;">
|
||||
import interfaceColModel from '../models/interfaceCol.js';
|
||||
import interfaceCaseModel from '../models/interfaceCase.js';
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import projectModel from '../models/project.js';
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
|
||||
@ -35,6 +37,8 @@ class interfaceColController extends baseController{
|
||||
super(ctx);
|
||||
this.colModel = yapi.getInst(interfaceColModel);
|
||||
this.caseModel = yapi.getInst(interfaceCaseModel);
|
||||
this.interfaceModel = yapi.getInst(interfaceModel);
|
||||
this.projectModel = yapi.getInst(projectModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,6 +139,14 @@ class interfaceColController extends baseController{
|
||||
let id = ctx.query.col_id;
|
||||
let inst = yapi.getInst(interfaceCaseModel);
|
||||
let result = await inst.list(id, 'all');
|
||||
for(let index=0; index< result.length; index++){
|
||||
|
||||
result[index] = result[index].toObject();
|
||||
let interfaceData = await this.interfaceModel.getBaseinfo(result[index].interface_id);
|
||||
let projectData = await this.projectModel.getBaseInfo(interfaceData.project_id);
|
||||
result[index].path = projectData.basepath + interfaceData.path;
|
||||
result[index].method = interfaceData.method;
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -169,8 +181,8 @@ class interfaceColController extends baseController{
|
||||
casename: 'string',
|
||||
project_id: 'number',
|
||||
col_id: 'number',
|
||||
domain: 'string',
|
||||
method: 'string'
|
||||
interface_id: 'number',
|
||||
case_env: 'string'
|
||||
});
|
||||
|
||||
|
||||
@ -178,7 +190,11 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if(!params.interface_id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit');
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
@ -242,9 +258,7 @@ class interfaceColController extends baseController{
|
||||
let params = ctx.request.body;
|
||||
params = yapi.commons.handleParams(params, {
|
||||
id: 'number',
|
||||
casename: 'string',
|
||||
domain: 'string',
|
||||
method: 'string'
|
||||
casename: 'string'
|
||||
});
|
||||
|
||||
if (!params.id) {
|
||||
@ -263,6 +277,10 @@ class interfaceColController extends baseController{
|
||||
|
||||
params.uid = this.getUid();
|
||||
|
||||
delete params.interface_id;
|
||||
delete params.project_id;
|
||||
delete params.col_id;
|
||||
|
||||
let result = await this.caseModel.up(params.id, params);
|
||||
let username = this.getUsername();
|
||||
this.colModel.get(caseData.col_id).then((col)=>{
|
||||
@ -299,12 +317,41 @@ class interfaceColController extends baseController{
|
||||
try{
|
||||
let id = ctx.query.caseid;
|
||||
let result = await this.caseModel.get(id);
|
||||
if(!result){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '不存在的case');
|
||||
}
|
||||
result = result.toObject();
|
||||
let data = await this.interfaceModel.get(result.interface_id);
|
||||
let projectData = await this.projectModel.getBaseInfo(data.project_id);
|
||||
result.path = projectData.basepath + data.path;
|
||||
result.method = data.method;
|
||||
result.req_body_type = data.req_body_type;
|
||||
result.req_headers = data.req_headers;
|
||||
|
||||
result.req_body_form = this.handleParamsValue(data.req_body_form, result.req_body_form)
|
||||
result.req_query = this.handleParamsValue(data.req_query, result.req_query)
|
||||
result.req_params = this.handleParamsValue(data.req_params, result.req_params)
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
}catch(e){
|
||||
ctx.body = yapi.commons.resReturn(null, 400, e.message)
|
||||
}
|
||||
}
|
||||
|
||||
handleParamsValue(params, val){
|
||||
let value = {};
|
||||
if(params.length === 0 || val.length === 0){
|
||||
return params;
|
||||
}
|
||||
val.forEach((item, index)=>{
|
||||
value[item.name] = item;
|
||||
})
|
||||
params.forEach((item, index)=>{
|
||||
params[index].value = value[item.name].value;
|
||||
})
|
||||
return params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新一个接口集name或描述
|
||||
* @interface /col/up_col
|
||||
|
@ -165,8 +165,7 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id,
|
||||
typename: params.group_name
|
||||
typeid: params.group_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -359,7 +358,7 @@ class projectController extends baseController {
|
||||
*/
|
||||
|
||||
async list(ctx) {
|
||||
let group_id = ctx.request.query.group_id
|
||||
let group_id = ctx.request.query.group_id, project_list = [];
|
||||
|
||||
if (!group_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
|
||||
@ -367,30 +366,31 @@ class projectController extends baseController {
|
||||
|
||||
let auth = await this.checkAuth(group_id, 'group', 'edit')
|
||||
try {
|
||||
let result = await this.Model.list(group_id, auth);
|
||||
let result = await this.Model.list(group_id);
|
||||
let follow = await this.followModel.list(this.getUid());
|
||||
let uids = [];
|
||||
result.forEach((item, index) => {
|
||||
result[index] = item.toObject();
|
||||
for(let index=0, item, r = 1; index< result.length; index++){
|
||||
item = result[index].toObject();
|
||||
if(item.project_type === 'private' && auth === false){
|
||||
r = await this.Model.checkMemberRepeat(this.getUid());
|
||||
if(r === 0){
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let f = _.find(follow, (fol) => {
|
||||
return fol.projectid === item._id
|
||||
})
|
||||
if (f) {
|
||||
result[index].follow = true;
|
||||
item.follow = true;
|
||||
} else {
|
||||
result[index].follow = false;
|
||||
}
|
||||
if (uids.indexOf(item.uid) === -1) {
|
||||
uids.push(item.uid);
|
||||
item.follow = false;
|
||||
}
|
||||
project_list.push(item);
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
|
||||
users.forEach((item) => {
|
||||
_users[item._id] = item;
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
list: result
|
||||
list: project_list
|
||||
});
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -579,9 +579,13 @@ class projectController extends baseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let data = {
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
if(params.project_type){
|
||||
data.project_type = params.project_type
|
||||
}
|
||||
|
||||
if (params.name) data.name = params.name;
|
||||
if (params.desc) data.desc = params.desc;
|
||||
|
@ -175,7 +175,7 @@ class userController extends baseController {
|
||||
user = await userInst.save(data);
|
||||
yapi.commons.sendMail({
|
||||
to: email,
|
||||
contents: `<h3>亲爱的用户:</h3><p>您好,感谢使用YApi平台.</p>`
|
||||
contents: `<h3>亲爱的用户:</h3><p>您好,感谢使用YApi平台,你的邮箱账号是:${email}</p>`
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user