MCPcopy Index your code
hub / github.com/YMFE/yapi / getCatMenu

Method getCatMenu

server/controllers/interface.js:1024–1043  ·  view source on GitHub ↗

* 获取分类列表 * @interface /interface/getCatMenu * @method GET * @category interface * @foldnumber 10 * @param {Number} project_id 项目id,不能为空 * @returns {Object} * @example ./api/interface/getCatMenu

(ctx)

Source from the content-addressed store, hash-verified

1022 * @example ./api/interface/getCatMenu
1023 */
1024 async getCatMenu(ctx) {
1025 let project_id = ctx.params.project_id;
1026
1027 if (!project_id || isNaN(project_id)) {
1028 return (ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'));
1029 }
1030
1031 try {
1032 let project = await this.projectModel.getBaseInfo(project_id);
1033 if (project.project_type === 'private') {
1034 if ((await this.checkAuth(project._id, 'project', 'edit')) !== true) {
1035 return (ctx.body = yapi.commons.resReturn(null, 406, '没有权限'));
1036 }
1037 }
1038 let res = await this.catModel.list(project_id);
1039 return (ctx.body = yapi.commons.resReturn(res));
1040 } catch (e) {
1041 yapi.commons.resReturn(null, 400, e.message);
1042 }
1043 }
1044
1045 /**
1046 * 获取自定义接口字段数据

Callers

nothing calls this directly

Calls 3

getBaseInfoMethod · 0.80
checkAuthMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected