mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-18 13:04:46 +08:00
fix: case path , add basepath
This commit is contained in:
parent
2d85dfd5cb
commit
2af93c7278
@ -1,6 +1,7 @@
|
||||
import interfaceColModel from '../models/interfaceCol.js';
|
||||
import interfaceCaseModel from '../models/interfaceCase.js';
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import projectModel from '../models/project.js';
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
|
||||
@ -10,6 +11,7 @@ class interfaceColController extends baseController{
|
||||
this.colModel = yapi.getInst(interfaceColModel);
|
||||
this.caseModel = yapi.getInst(interfaceCaseModel);
|
||||
this.interfaceModel = yapi.getInst(interfaceModel);
|
||||
this.projectModel = yapi.getInst(projectModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,7 +116,8 @@ class interfaceColController extends baseController{
|
||||
|
||||
result[index] = result[index].toObject();
|
||||
let interfaceData = await this.interfaceModel.getBaseinfo(result[index].interface_id);
|
||||
result[index].path = interfaceData.path;
|
||||
let projectData = await this.projectModel.getBaseInfo(interfaceData.project_id);
|
||||
result[index].path = projectData.basepath + interfaceData.path;
|
||||
result[index].method = interfaceData.method;
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
@ -293,7 +296,8 @@ class interfaceColController extends baseController{
|
||||
}
|
||||
result = result.toObject();
|
||||
let data = await this.interfaceModel.get(result.interface_id);
|
||||
result.path = data.path;
|
||||
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;
|
||||
result.req_headers = data.req_headers;
|
||||
|
@ -73,7 +73,7 @@ class interfaceModel extends baseModel {
|
||||
getBaseinfo(id){
|
||||
return this.model.findOne({
|
||||
_id: id,
|
||||
}).select('path method uid title').exec()
|
||||
}).select('path method uid title project_id cat_id status').exec()
|
||||
}
|
||||
|
||||
getVar(project_id, method){
|
||||
|
@ -40,6 +40,10 @@ var _interface = require('../models/interface.js');
|
||||
|
||||
var _interface2 = _interopRequireDefault(_interface);
|
||||
|
||||
var _project = require('../models/project.js');
|
||||
|
||||
var _project2 = _interopRequireDefault(_project);
|
||||
|
||||
var _base = require('./base.js');
|
||||
|
||||
var _base2 = _interopRequireDefault(_base);
|
||||
@ -61,6 +65,7 @@ var interfaceColController = function (_baseController) {
|
||||
_this.colModel = _yapi2.default.getInst(_interfaceCol2.default);
|
||||
_this.caseModel = _yapi2.default.getInst(_interfaceCase2.default);
|
||||
_this.interfaceModel = _yapi2.default.getInst(_interface2.default);
|
||||
_this.projectModel = _yapi2.default.getInst(_project2.default);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@ -261,7 +266,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'getCaseList',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var id, inst, result, index, interfaceData;
|
||||
var id, inst, result, index, interfaceData, projectData;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
@ -278,7 +283,7 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 7:
|
||||
if (!(index < result.length)) {
|
||||
_context3.next = 17;
|
||||
_context3.next = 20;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -288,32 +293,37 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 11:
|
||||
interfaceData = _context3.sent;
|
||||
|
||||
result[index].path = interfaceData.path;
|
||||
result[index].method = interfaceData.method;
|
||||
_context3.next = 14;
|
||||
return this.projectModel.getBaseInfo(interfaceData.project_id);
|
||||
|
||||
case 14:
|
||||
projectData = _context3.sent;
|
||||
|
||||
result[index].path = projectData.basepath + interfaceData.path;
|
||||
result[index].method = interfaceData.method;
|
||||
|
||||
case 17:
|
||||
index++;
|
||||
_context3.next = 7;
|
||||
break;
|
||||
|
||||
case 17:
|
||||
case 20:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 23;
|
||||
_context3.next = 26;
|
||||
break;
|
||||
|
||||
case 20:
|
||||
_context3.prev = 20;
|
||||
case 23:
|
||||
_context3.prev = 23;
|
||||
_context3.t0 = _context3['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
|
||||
|
||||
case 23:
|
||||
case 26:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[0, 20]]);
|
||||
}, _callee3, this, [[0, 23]]);
|
||||
}));
|
||||
|
||||
function getCaseList(_x3) {
|
||||
@ -601,7 +611,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'getCase',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var id, result, data;
|
||||
var id, result, data, projectData;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
@ -628,8 +638,13 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 10:
|
||||
data = _context6.sent;
|
||||
_context6.next = 13;
|
||||
return this.projectModel.getBaseInfo(data.project_id);
|
||||
|
||||
result.path = data.path;
|
||||
case 13:
|
||||
projectData = _context6.sent;
|
||||
|
||||
result.path = projectData.basepath + data.path;
|
||||
result.method = data.method;
|
||||
result.req_body_type = data.req_body_type;
|
||||
result.req_headers = data.req_headers;
|
||||
@ -639,21 +654,21 @@ var interfaceColController = function (_baseController) {
|
||||
result.req_params = this.handleParamsValue(data.req_params, result.req_params);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 24;
|
||||
_context6.next = 27;
|
||||
break;
|
||||
|
||||
case 21:
|
||||
_context6.prev = 21;
|
||||
case 24:
|
||||
_context6.prev = 24;
|
||||
_context6.t0 = _context6['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context6.t0.message);
|
||||
|
||||
case 24:
|
||||
case 27:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[0, 21]]);
|
||||
}, _callee6, this, [[0, 24]]);
|
||||
}));
|
||||
|
||||
function getCase(_x6) {
|
||||
|
@ -114,7 +114,7 @@ var interfaceModel = function (_baseModel) {
|
||||
value: function getBaseinfo(id) {
|
||||
return this.model.findOne({
|
||||
_id: id
|
||||
}).select('path method uid title').exec();
|
||||
}).select('path method uid title project_id cat_id status').exec();
|
||||
}
|
||||
}, {
|
||||
key: 'getVar',
|
||||
|
Loading…
Reference in New Issue
Block a user