fix: 高级mock 去重判断

This commit is contained in:
gaoxiaolin.gao 2018-09-20 17:38:22 +08:00
parent 3d3f80d0c1
commit e86cc553bb
2 changed files with 6 additions and 7 deletions

View File

@ -64,6 +64,7 @@ async function handle(
let existNum = 0;
if (len === 0) {
messageError(`解析数据为空`);
callback({ showLoading: false });
return;
}
for (let index = 0; index < res.length; index++) {

View File

@ -69,13 +69,13 @@ class advMockController extends baseController {
let userinfo = await this.userModel.findById(result[i].uid);
result[i] = result[i].toObject();
// if (userinfo) {
result[i].username = userinfo.username;
result[i].username = userinfo.username;
// }
}
ctx.body = yapi.commons.resReturn(result);
} catch (err) {
ctx.body = yapi.commons.resReturn(null, 400, err.message)
ctx.body = yapi.commons.resReturn(null, 400, err.message);
}
}
@ -137,8 +137,6 @@ class advMockController extends baseController {
for (let i in data.params) {
findRepeatParams['params.' + i] = data.params[i];
}
} else {
findRepeatParams.params = null;
}
if (data.ip_enable) {
@ -146,6 +144,7 @@ class advMockController extends baseController {
}
findRepeat = await this.caseModel.get(findRepeatParams);
if (findRepeat && findRepeat._id !== params.id) {
return (ctx.body = yapi.commons.resReturn(null, 400, '已存在的期望'));
}
@ -171,17 +170,16 @@ class advMockController extends baseController {
async hideCase(ctx) {
let id = ctx.request.body.id;
let enable = ctx.request.body.enable
let enable = ctx.request.body.enable;
if (!id) {
return (ctx.body = yapi.commons.resReturn(null, 408, '缺少 id'));
}
let data = {
id,
case_enable: enable
}
};
let result = await this.caseModel.up(data);
return (ctx.body = yapi.commons.resReturn(result));
}
}