MCPcopy
hub / github.com/YMFE/yapi / get

Method get

server/controllers/project.js:519–543  ·  view source on GitHub ↗

* 获取项目信息 * @interface /project/get * @method GET * @category project * @foldnumber 10 * @param {Number} id 项目id,不能为空 * @returns {Object} * @example ./api/project/get.json

(ctx)

Source from the content-addressed store, hash-verified

517 */
518
519 async get(ctx) {
520 let params = ctx.params;
521 let projectId= params.id || params.project_id; // 通过 token 访问
522 let result = await this.Model.getBaseInfo(projectId);
523
524 if (!result) {
525 return (ctx.body = yapi.commons.resReturn(null, 400, '不存在的项目'));
526 }
527 if (result.project_type === 'private') {
528 if ((await this.checkAuth(result._id, 'project', 'view')) !== true) {
529 return (ctx.body = yapi.commons.resReturn(null, 406, '没有权限'));
530 }
531 }
532 result = result.toObject();
533 let catInst = yapi.getInst(interfaceCatModel);
534 let cat = await catInst.list(params.id);
535 result.cat = cat;
536 if (result.env.length === 0) {
537 result.env.push({ name: 'local', domain: 'http://127.0.0.1' });
538 }
539 result.role = await this.getProjectRole(params.id, 'project');
540
541 yapi.emitHook('project_get', result).then();
542 ctx.body = yapi.commons.resReturn(result);
543 }
544
545 /**
546 * 获取项目列表

Callers 9

copyMethod · 0.45
getMemberListMethod · 0.45
listMethod · 0.45
upMethod · 0.45
upEnvMethod · 0.45
upTagMethod · 0.45
tokenMethod · 0.45
updateTokenMethod · 0.45
swaggerUrlMethod · 0.45

Calls 4

getBaseInfoMethod · 0.80
getProjectRoleMethod · 0.80
checkAuthMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected