fix: 解决冲突

This commit is contained in:
zwjamnsss 2017-08-24 21:11:06 +08:00
parent be5e2077e9
commit 4f28b9f82d
10 changed files with 978 additions and 38 deletions

View File

@ -72,7 +72,7 @@ app.use(compress({
})); }));
app.use(function () { app.use(function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {

View File

@ -59,7 +59,7 @@ var baseController = function () {
(0, _createClass3.default)(baseController, [{ (0, _createClass3.default)(baseController, [{
key: 'init', key: 'init',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var ignoreRouter; var ignoreRouter;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
@ -103,7 +103,7 @@ var baseController = function () {
}, { }, {
key: 'checkLogin', key: 'checkLogin',
value: function () { value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) { var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var token, uid, userInst, result, decoded; var token, uid, userInst, result, decoded;
return _regenerator2.default.wrap(function _callee2$(_context2) { return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) { while (1) {
@ -170,7 +170,7 @@ var baseController = function () {
}, { }, {
key: 'getLoginStatus', key: 'getLoginStatus',
value: function () { value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) { var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var result; var result;
return _regenerator2.default.wrap(function _callee3$(_context3) { return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) { while (1) {
@ -222,7 +222,7 @@ var baseController = function () {
}, { }, {
key: 'getProjectRole', key: 'getProjectRole',
value: function () { value: function () {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(id, type) { var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(id, type) {
var _this = this; var _this = this;
var result, interfaceInst, interfaceData, projectInst, projectData, memberData, groupInst, groupData, groupMemberData; var result, interfaceInst, interfaceData, projectInst, projectData, memberData, groupInst, groupData, groupMemberData;
@ -379,7 +379,7 @@ var baseController = function () {
}, { }, {
key: 'checkAuth', key: 'checkAuth',
value: function () { value: function () {
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(id, type, action) { var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(id, type, action) {
var role; var role;
return _regenerator2.default.wrap(function _callee5$(_context5) { return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) { while (1) {

View File

@ -74,7 +74,7 @@ var followController = function (_baseController) {
(0, _createClass3.default)(followController, [{ (0, _createClass3.default)(followController, [{
key: 'list', key: 'list',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var uid, page, limit, result; var uid, page, limit, result;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
@ -139,7 +139,7 @@ var followController = function (_baseController) {
}, { }, {
key: 'del', key: 'del',
value: function () { value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) { var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var params, uid, checkRepeat, result; var params, uid, checkRepeat, result;
return _regenerator2.default.wrap(function _callee2$(_context2) { return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) { while (1) {
@ -217,7 +217,7 @@ var followController = function (_baseController) {
}, { }, {
key: 'add', key: 'add',
value: function () { value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) { var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var params, uid, checkRepeat, project, data, result; var params, uid, checkRepeat, project, data, result;
return _regenerator2.default.wrap(function _callee3$(_context3) { return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) { while (1) {

View File

@ -88,7 +88,7 @@ var groupController = function (_baseController) {
(0, _createClass3.default)(groupController, [{ (0, _createClass3.default)(groupController, [{
key: 'get', key: 'get',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var params, groupInst, result; var params, groupInst, result;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
@ -160,7 +160,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'add', key: 'add',
value: function () { value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) { var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var params, groupUserdata, groupInst, checkRepeat, data, result; var params, groupUserdata, groupInst, checkRepeat, data, result;
return _regenerator2.default.wrap(function _callee2$(_context2) { return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) { while (1) {
@ -272,7 +272,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'getUserdata', key: 'getUserdata',
value: function () { value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(uid, role) { var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
var userInst, userData; var userInst, userData;
return _regenerator2.default.wrap(function _callee3$(_context3) { return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) { while (1) {
@ -333,7 +333,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'addMember', key: 'addMember',
value: function () { value: function () {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) { var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
var params, groupInst, check, groupUserdata, result; var params, groupInst, check, groupUserdata, result;
return _regenerator2.default.wrap(function _callee4$(_context4) { return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) { while (1) {
@ -446,7 +446,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'changeMemberRole', key: 'changeMemberRole',
value: function () { value: function () {
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) { var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
var params, groupInst, check, result; var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee5$(_context5) { return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) { while (1) {
@ -547,7 +547,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'getMemberList', key: 'getMemberList',
value: function () { value: function () {
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) { var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var params, groupInst, group; var params, groupInst, group;
return _regenerator2.default.wrap(function _callee6$(_context6) { return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) { while (1) {
@ -611,7 +611,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'delMember', key: 'delMember',
value: function () { value: function () {
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) { var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
var params, groupInst, check, result; var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee7$(_context7) { return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) { while (1) {
@ -709,7 +709,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'list', key: 'list',
value: function () { value: function () {
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) { var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var groupInst, result; var groupInst, result;
return _regenerator2.default.wrap(function _callee8$(_context8) { return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) { while (1) {
@ -762,7 +762,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'del', key: 'del',
value: function () { value: function () {
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) { var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _this2 = this; var _this2 = this;
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, _id, projectList, result; var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, _id, projectList, result;
@ -802,7 +802,7 @@ var groupController = function (_baseController) {
projectList = _context10.sent; projectList = _context10.sent;
projectList.forEach(function () { projectList.forEach(function () {
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(p) { var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
return _regenerator2.default.wrap(function _callee9$(_context9) { return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) { while (1) {
switch (_context9.prev = _context9.next) { switch (_context9.prev = _context9.next) {
@ -881,7 +881,7 @@ var groupController = function (_baseController) {
}, { }, {
key: 'up', key: 'up',
value: function () { value: function () {
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) { var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var groupInst, _id2, data, result; var groupInst, _id2, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) { return _regenerator2.default.wrap(function _callee11$(_context11) {

View File

@ -0,0 +1,940 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
var _interfaceCol = require('../models/interfaceCol.js');
var _interfaceCol2 = _interopRequireDefault(_interfaceCol);
var _interfaceCase = require('../models/interfaceCase.js');
var _interfaceCase2 = _interopRequireDefault(_interfaceCase);
var _base = require('./base.js');
var _base2 = _interopRequireDefault(_base);
var _yapi = require('../yapi.js');
var _yapi2 = _interopRequireDefault(_yapi);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var interfaceColController = function (_baseController) {
(0, _inherits3.default)(interfaceColController, _baseController);
function interfaceColController(ctx) {
(0, _classCallCheck3.default)(this, interfaceColController);
var _this = (0, _possibleConstructorReturn3.default)(this, (interfaceColController.__proto__ || (0, _getPrototypeOf2.default)(interfaceColController)).call(this, ctx));
_this.colModel = _yapi2.default.getInst(_interfaceCol2.default);
_this.caseModel = _yapi2.default.getInst(_interfaceCase2.default);
return _this;
}
/**
* 获取所有接口集
* @interface /col/list
* @method GET
* @category col
* @foldnumber 10
* @param {String} project_id email名称不能为空
* @returns {Object}
* @example
*/
(0, _createClass3.default)(interfaceColController, [{
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var id, result, i;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
id = ctx.query.project_id;
_context.next = 4;
return this.colModel.list(id);
case 4:
result = _context.sent;
i = 0;
case 6:
if (!(i < result.length)) {
_context.next = 14;
break;
}
result[i] = result[i].toObject();
_context.next = 10;
return this.caseModel.list(result[i]._id);
case 10:
result[i].caseList = _context.sent;
case 11:
i++;
_context.next = 6;
break;
case 14:
ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 20;
break;
case 17:
_context.prev = 17;
_context.t0 = _context['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 20:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[0, 17]]);
}));
function list(_x) {
return _ref.apply(this, arguments);
}
return list;
}()
/**
* 增加接口集
* @interface /col/add_col
* @method POST
* @category col
* @foldnumber 10
* @param {Number} project_id
* @param {String} name
* @param {String} desc
* @returns {Object}
* @example
*/
}, {
key: 'addCol',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var params, auth, result, username;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
params = ctx.request.body;
params = _yapi2.default.commons.handleParams(params, {
name: 'string',
project_id: 'number',
desc: 'string'
});
if (params.project_id) {
_context2.next = 5;
break;
}
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
case 5:
if (params.name) {
_context2.next = 7;
break;
}
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '名称不能为空'));
case 7:
_context2.next = 9;
return this.checkAuth(params.project_id, 'project', 'edit');
case 9:
auth = _context2.sent;
if (auth) {
_context2.next = 12;
break;
}
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 12:
_context2.next = 14;
return this.colModel.save({
name: params.name,
project_id: params.project_id,
desc: params.desc,
uid: this.getUid(),
add_time: _yapi2.default.commons.time(),
up_time: _yapi2.default.commons.time()
});
case 14:
result = _context2.sent;
username = this.getUsername();
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u6DFB\u52A0\u4E86\u63A5\u53E3\u96C6 "' + params.name + '"',
type: 'project',
uid: this.getUid(),
username: username,
typeid: params.project_id
});
ctx.body = _yapi2.default.commons.resReturn(result);
_context2.next = 23;
break;
case 20:
_context2.prev = 20;
_context2.t0 = _context2['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t0.message);
case 23:
case 'end':
return _context2.stop();
}
}
}, _callee2, this, [[0, 20]]);
}));
function addCol(_x2) {
return _ref2.apply(this, arguments);
}
return addCol;
}()
/**
* 获取一个接口集下的所有的接口用例
* @interface /col/case_list
* @method GET
* @category col
* @foldnumber 10
* @param {String} col_id 接口集id
* @returns {Object}
* @example
*/
}, {
key: 'getCaseList',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var id, inst, result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
id = ctx.query.col_id;
inst = _yapi2.default.getInst(_interfaceCase2.default);
_context3.next = 5;
return inst.list(id, 'all');
case 5:
result = _context3.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context3.next = 12;
break;
case 9:
_context3.prev = 9;
_context3.t0 = _context3['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
case 12:
case 'end':
return _context3.stop();
}
}
}, _callee3, this, [[0, 9]]);
}));
function getCaseList(_x3) {
return _ref3.apply(this, arguments);
}
return getCaseList;
}()
/**
* 增加一个接口用例
* @interface /col/add_case
* @method POST
* @category col
* @foldnumber 10
* @param {String} casename
* @param {Number} col_id
* @param {Number} project_id
* @param {String} domain
* @param {String} path
* @param {String} method
* @param {Object} req_query
* @param {Object} req_headers
* @param {String} req_body_type
* @param {Array} req_body_form
* @param {String} req_body_other
* @returns {Object}
* @example
*/
}, {
key: 'addCase',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
var _this2 = this;
var params, auth, result, username;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.prev = 0;
params = ctx.request.body;
params = _yapi2.default.commons.handleParams(params, {
casename: 'string',
project_id: 'number',
col_id: 'number',
domain: 'string',
method: 'string'
});
if (params.project_id) {
_context4.next = 5;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
case 5:
_context4.next = 7;
return this.checkAuth(params.project_id, 'project', 'edit');
case 7:
auth = _context4.sent;
if (auth) {
_context4.next = 10;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 10:
if (params.col_id) {
_context4.next = 12;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口集id不能为空'));
case 12:
if (params.casename) {
_context4.next = 14;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
case 14:
params.uid = this.getUid();
params.index = 0;
params.add_time = _yapi2.default.commons.time();
params.up_time = _yapi2.default.commons.time();
_context4.next = 20;
return this.caseModel.save(params);
case 20:
result = _context4.sent;
username = this.getUsername();
this.colModel.get(params.col_id).then(function (col) {
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u5728\u63A5\u53E3\u96C6 "' + col.name + '" \u4E0B\u6DFB\u52A0\u4E86\u63A5\u53E3\u7528\u4F8B "' + params.casename + '"',
type: 'project',
uid: _this2.getUid(),
username: username,
typeid: params.project_id
});
});
ctx.body = _yapi2.default.commons.resReturn(result);
_context4.next = 29;
break;
case 26:
_context4.prev = 26;
_context4.t0 = _context4['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
case 29:
case 'end':
return _context4.stop();
}
}
}, _callee4, this, [[0, 26]]);
}));
function addCase(_x4) {
return _ref4.apply(this, arguments);
}
return addCase;
}()
/**
* 更新一个接口用例
* @interface /col/up_case
* @method POST
* @category col
* @foldnumber 10
* @param {number} id
* @param {String} casename
* @param {String} domain
* @param {String} path
* @param {String} method
* @param {Object} req_query
* @param {Object} req_headers
* @param {String} req_body_type
* @param {Array} req_body_form
* @param {String} req_body_other
* @returns {Object}
* @example
*/
}, {
key: 'upCase',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
var _this3 = this;
var params, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.prev = 0;
params = ctx.request.body;
params = _yapi2.default.commons.handleParams(params, {
id: 'number',
casename: 'string',
domain: 'string',
method: 'string'
});
if (params.id) {
_context5.next = 5;
break;
}
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例id不能为空'));
case 5:
if (params.casename) {
_context5.next = 7;
break;
}
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
case 7:
_context5.next = 9;
return this.caseModel.get(params.id);
case 9:
caseData = _context5.sent;
_context5.next = 12;
return this.checkAuth(caseData.project_id, 'project', 'edit');
case 12:
auth = _context5.sent;
if (auth) {
_context5.next = 15;
break;
}
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 15:
params.uid = this.getUid();
_context5.next = 18;
return this.caseModel.up(params.id, params);
case 18:
result = _context5.sent;
username = this.getUsername();
this.colModel.get(caseData.col_id).then(function (col) {
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u5728\u63A5\u53E3\u96C6 "' + col.name + '" \u66F4\u65B0\u4E86\u63A5\u53E3\u7528\u4F8B "' + params.casename + '"',
type: 'project',
uid: _this3.getUid(),
username: username,
typeid: caseData.project_id
});
});
ctx.body = _yapi2.default.commons.resReturn(result);
_context5.next = 27;
break;
case 24:
_context5.prev = 24;
_context5.t0 = _context5['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context5.t0.message);
case 27:
case 'end':
return _context5.stop();
}
}
}, _callee5, this, [[0, 24]]);
}));
function upCase(_x5) {
return _ref5.apply(this, arguments);
}
return upCase;
}()
/**
* 获取一个接口用例详情
* @interface /col/case
* @method GET
* @category col
* @foldnumber 10
* @param {String} caseid
* @returns {Object}
* @example
*/
}, {
key: 'getCase',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var id, result;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.prev = 0;
id = ctx.query.caseid;
_context6.next = 4;
return this.caseModel.get(id);
case 4:
result = _context6.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context6.next = 11;
break;
case 8:
_context6.prev = 8;
_context6.t0 = _context6['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context6.t0.message);
case 11:
case 'end':
return _context6.stop();
}
}
}, _callee6, this, [[0, 8]]);
}));
function getCase(_x6) {
return _ref6.apply(this, arguments);
}
return getCase;
}()
/**
* 更新一个接口集name或描述
* @interface /col/up_col
* @method POST
* @category col
* @foldnumber 10
* @param {String} name
* @param {String} desc
* @returns {Object}
* @example
*/
}, {
key: 'upCol',
value: function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
var params, id, colData, auth, result, username;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.prev = 0;
params = ctx.request.body;
id = params.col_id;
_context7.next = 5;
return this.colModel.get(id);
case 5:
colData = _context7.sent;
_context7.next = 8;
return this.checkAuth(colData.project_id, 'project', 'edit');
case 8:
auth = _context7.sent;
if (auth) {
_context7.next = 11;
break;
}
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 11:
_context7.next = 13;
return this.colModel.up(params.col_id, {
name: params.name,
desc: params.desc,
up_time: _yapi2.default.commons.time()
});
case 13:
result = _context7.sent;
username = this.getUsername();
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u63A5\u53E3\u96C6 "' + params.name + '" \u7684\u4FE1\u606F',
type: 'project',
uid: this.getUid(),
username: username,
typeid: colData.project_id
});
ctx.body = _yapi2.default.commons.resReturn(result);
_context7.next = 22;
break;
case 19:
_context7.prev = 19;
_context7.t0 = _context7['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context7.t0.message);
case 22:
case 'end':
return _context7.stop();
}
}
}, _callee7, this, [[0, 19]]);
}));
function upCol(_x7) {
return _ref7.apply(this, arguments);
}
return upCol;
}()
/**
* 更新多个接口case index
* @interface /col/up_col_index
* @method POST
* @category col
* @foldnumber 10
* @param {Array} [id, index]
* @returns {Object}
* @example
*/
}, {
key: 'upCaseIndex',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var _this4 = this;
var params;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.prev = 0;
params = ctx.request.body;
if (!params || !Array.isArray(params)) {
ctx.body = _yapi2.default.commons.resReturn(null, 400, "请求参数必须是数组");
}
// let caseName = "";
params.forEach(function (item) {
if (item.id && item.index) {
_this4.caseModel.upCaseIndex(item.id, item.index).then(function (res) {}, function (err) {
_yapi2.default.commons.log(err.message, 'error');
});
}
});
// let username = this.getUsername();
// yapi.commons.saveLog({
// content: `用户 "${username}" 更新了接口集 "${params.col_name}"`,
// type: 'project',
// uid: this.getUid(),
// username: username,
// typeid: params.project_id
// });
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn('success'));
case 7:
_context8.prev = 7;
_context8.t0 = _context8['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context8.t0.message);
case 10:
case 'end':
return _context8.stop();
}
}
}, _callee8, this, [[0, 7]]);
}));
function upCaseIndex(_x8) {
return _ref8.apply(this, arguments);
}
return upCaseIndex;
}()
/**
* 删除一个接口集
* @interface /col/del_col
* @method GET
* @category col
* @foldnumber 10
* @param {String}
* @returns {Object}
* @example
*/
}, {
key: 'delCol',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
var id, colData, auth, result, username;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.prev = 0;
id = ctx.query.col_id;
_context9.next = 4;
return this.colModel.get(id);
case 4:
colData = _context9.sent;
if (!colData) {
ctx.body = _yapi2.default.commons.resReturn(null, 400, "不存在的id");
}
if (!(colData.uid !== this.getUid())) {
_context9.next = 12;
break;
}
_context9.next = 9;
return this.checkAuth(colData.project_id, 'project', 'danger');
case 9:
auth = _context9.sent;
if (auth) {
_context9.next = 12;
break;
}
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 12:
_context9.next = 14;
return this.colModel.del(id);
case 14:
result = _context9.sent;
_context9.next = 17;
return this.caseModel.delByCol(id);
case 17:
username = this.getUsername();
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u63A5\u53E3\u96C6 "' + colData.name + '" \u53CA\u5176\u4E0B\u9762\u7684\u63A5\u53E3',
type: 'project',
uid: this.getUid(),
username: username,
typeid: colData.project_id
});
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
case 22:
_context9.prev = 22;
_context9.t0 = _context9['catch'](0);
_yapi2.default.commons.resReturn(null, 400, _context9.t0.message);
case 25:
case 'end':
return _context9.stop();
}
}
}, _callee9, this, [[0, 22]]);
}));
function delCol(_x9) {
return _ref9.apply(this, arguments);
}
return delCol;
}()
/**
*
* @param {*} ctx
*/
}, {
key: 'delCase',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _this5 = this;
var caseid, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
_context10.prev = 0;
caseid = ctx.query.caseid;
_context10.next = 4;
return this.caseModel.get(caseid);
case 4:
caseData = _context10.sent;
if (!caseData) {
ctx.body = _yapi2.default.commons.resReturn(null, 400, "不存在的caseid");
}
if (!(caseData.uid !== this.getUid())) {
_context10.next = 12;
break;
}
_context10.next = 9;
return this.checkAuth(caseData.project_id, 'project', 'danger');
case 9:
auth = _context10.sent;
if (auth) {
_context10.next = 12;
break;
}
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 12:
_context10.next = 14;
return this.caseModel.del(caseid);
case 14:
result = _context10.sent;
username = this.getUsername();
this.colModel.get(caseData.col_id).then(function (col) {
_yapi2.default.commons.saveLog({
content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u63A5\u53E3\u96C6 "' + col.name + '" \u4E0B\u7684\u63A5\u53E3 "' + caseData.casename + '"',
type: 'project',
uid: _this5.getUid(),
username: username,
typeid: caseData.project_id
});
});
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
case 20:
_context10.prev = 20;
_context10.t0 = _context10['catch'](0);
_yapi2.default.commons.resReturn(null, 400, _context10.t0.message);
case 23:
case 'end':
return _context10.stop();
}
}
}, _callee10, this, [[0, 20]]);
}));
function delCase(_x10) {
return _ref10.apply(this, arguments);
}
return delCase;
}()
}]);
return interfaceColController;
}(_base2.default);
module.exports = interfaceColController;

View File

@ -75,7 +75,7 @@ var logController = function (_baseController) {
(0, _createClass3.default)(logController, [{ (0, _createClass3.default)(logController, [{
key: 'list', key: 'list',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var typeid, page, limit, type, result, count; var typeid, page, limit, type, result, count;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {

View File

@ -99,7 +99,7 @@ var userController = function (_baseController) {
(0, _createClass3.default)(userController, [{ (0, _createClass3.default)(userController, [{
key: 'login', key: 'login',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var userInst, email, password, result; var userInst, email, password, result;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
@ -190,7 +190,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'logout', key: 'logout',
value: function () { value: function () {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) { var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
return _regenerator2.default.wrap(function _callee2$(_context2) { return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
@ -248,7 +248,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'loginByToken', key: 'loginByToken',
value: function () { value: function () {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) { var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var config, token, ret, login; var config, token, ret, login;
return _regenerator2.default.wrap(function _callee3$(_context3) { return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) { while (1) {
@ -300,7 +300,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'handleThirdLogin', key: 'handleThirdLogin',
value: function () { value: function () {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(email, username) { var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(email, username) {
var user, data, passsalt, userInst; var user, data, passsalt, userInst;
return _regenerator2.default.wrap(function _callee4$(_context4) { return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) { while (1) {
@ -384,7 +384,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'changePassword', key: 'changePassword',
value: function () { value: function () {
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) { var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
var params, userInst, user, passsalt, data, result; var params, userInst, user, passsalt, data, result;
return _regenerator2.default.wrap(function _callee5$(_context5) { return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) { while (1) {
@ -512,7 +512,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'reg', key: 'reg',
value: function () { value: function () {
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) { var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var userInst, params, checkRepeat, passsalt, data, user; var userInst, params, checkRepeat, passsalt, data, user;
return _regenerator2.default.wrap(function _callee6$(_context6) { return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) { while (1) {
@ -636,7 +636,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'list', key: 'list',
value: function () { value: function () {
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) { var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
var page, limit, userInst, user, count; var page, limit, userInst, user, count;
return _regenerator2.default.wrap(function _callee7$(_context7) { return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) { while (1) {
@ -694,7 +694,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'findById', key: 'findById',
value: function () { value: function () {
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) { var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var userInst, id, result; var userInst, id, result;
return _regenerator2.default.wrap(function _callee8$(_context8) { return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) { while (1) {
@ -770,7 +770,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'del', key: 'del',
value: function () { value: function () {
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) { var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
var userInst, id, result; var userInst, id, result;
return _regenerator2.default.wrap(function _callee9$(_context9) { return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) { while (1) {
@ -846,7 +846,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'update', key: 'update',
value: function () { value: function () {
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) { var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var params, userInst, id, data, checkRepeat, result; var params, userInst, id, data, checkRepeat, result;
return _regenerator2.default.wrap(function _callee10$(_context10) { return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) { while (1) {
@ -952,7 +952,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'uploadAvatar', key: 'uploadAvatar',
value: function () { value: function () {
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) { var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var basecode, pngPrefix, jpegPrefix, type, strLength, avatarInst, result; var basecode, pngPrefix, jpegPrefix, type, strLength, avatarInst, result;
return _regenerator2.default.wrap(function _callee11$(_context11) { return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) { while (1) {
@ -1054,7 +1054,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'avatar', key: 'avatar',
value: function () { value: function () {
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) { var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
var uid, avatarInst, data, dataBuffer, type; var uid, avatarInst, data, dataBuffer, type;
return _regenerator2.default.wrap(function _callee12$(_context12) { return _regenerator2.default.wrap(function _callee12$(_context12) {
while (1) { while (1) {
@ -1118,7 +1118,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'search', key: 'search',
value: function () { value: function () {
var _ref13 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee13(ctx) { var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
var q, queryList, rules, filteredRes; var q, queryList, rules, filteredRes;
return _regenerator2.default.wrap(function _callee13$(_context13) { return _regenerator2.default.wrap(function _callee13$(_context13) {
while (1) { while (1) {
@ -1190,7 +1190,7 @@ var userController = function (_baseController) {
}, { }, {
key: 'project', key: 'project',
value: function () { value: function () {
var _ref14 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee14(ctx) { var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(ctx) {
var _ctx$request$query, id, type, result, interfaceInst, interfaceData, projectInst, projectData, ownerAuth, devAuth, groupInst, groupData, _ownerAuth, _devAuth; var _ctx$request$query, id, type, result, interfaceInst, interfaceData, projectInst, projectData, ownerAuth, devAuth, groupInst, groupData, _ownerAuth, _devAuth;
return _regenerator2.default.wrap(function _callee14$(_context14) { return _regenerator2.default.wrap(function _callee14$(_context14) {

View File

@ -47,7 +47,7 @@ function matchApi(apiPath, apiRule) {
} }
module.exports = function () { module.exports = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
var hostname, config, path, paths, projectId, projectInst, project, interfaceData, newData, newpath, interfaceInst, _newData, findInterface, res; var hostname, config, path, paths, projectId, projectInst, project, interfaceData, newData, newpath, interfaceInst, _newData, findInterface, res;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {

View File

@ -355,7 +355,7 @@ function createAction(controller, action, path, method) {
var _this = this; var _this = this;
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () { router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var inst; var inst;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {

View File

@ -26,7 +26,7 @@ function websocket(app) {
return next(ctx); return next(ctx);
}); });
router.get('/api/interface/solve_conflict', function () { router.get('/api/interface/solve_conflict', function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var inst; var inst;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {