fix: interfaceCol 数据不同步问题

This commit is contained in:
suxiaoxin 2017-09-08 11:12:33 +08:00
parent 6633b47800
commit bd10b24586
2 changed files with 10 additions and 1 deletions

View File

@ -116,6 +116,11 @@ class interfaceColController extends baseController{
result[index] = result[index].toObject();
let interfaceData = await this.interfaceModel.getBaseinfo(result[index].interface_id);
if(!interfaceData){
await this.caseModel.del(result[index]._id);
result[index] = undefined;
continue;
}
let projectData = await this.projectModel.getBaseInfo(interfaceData.project_id);
result[index].path = projectData.basepath + interfaceData.path;
result[index].method = interfaceData.method;
@ -295,8 +300,11 @@ class interfaceColController extends baseController{
}
result = result.toObject();
let data = await this.interfaceModel.get(result.interface_id);
if(!data){
return ctx.body = yapi.commons.resReturn(null, 400, '找不到对应的接口,请联系管理员')
}
data = data.toObject();
let projectData = await this.projectModel.getBaseInfo(data.project_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;

View File

@ -76,6 +76,7 @@ class interfaceCase extends baseModel {
}
delByInterfaceId(id){
console.log("delCase", id);
return this.model.deleteMany({
interface_id: id
})