Skip to content

Commit

Permalink
fix: [2361] 修复所有分类被删除时,同步问题. 解决方案: 增加 "默认分类"
Browse files Browse the repository at this point in the history
  • Loading branch information
ariesly15 committed Oct 12, 2021
1 parent 219fab4 commit 01207e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/controllers/open.js
Expand Up @@ -122,6 +122,22 @@ class openController extends baseController {
}

let menuList = await this.interfaceCatModel.list(project_id);
/**
* 防止分类被都被删除时取不到 selectCatid
* 如果没有分类,增加一个默认分类
*/
if (menuList.length === 0) {
const catInst = yapi.getInst(interfaceCatModel);
const menu = await catInst.save({
name: '默认分类',
project_id: project_id,
desc: '默认分类',
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
});
menuList.push(menu);
}
let selectCatid = menuList[0]._id;
let projectData = await this.projectModel.get(project_id);
let res = await importDataModule[type](content);
Expand Down

0 comments on commit 01207e2

Please sign in to comment.