2017-07-04 16:43:07 +08:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2017-07-04 17:19:20 +08:00
|
|
|
|
var _keys = require('babel-runtime/core-js/object/keys');
|
|
|
|
|
|
|
|
|
|
var _keys2 = _interopRequireDefault(_keys);
|
|
|
|
|
|
2017-07-04 16:43:07 +08:00
|
|
|
|
var _regenerator = require('babel-runtime/regenerator');
|
|
|
|
|
|
|
|
|
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
|
|
|
|
|
|
|
|
|
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
|
|
|
|
|
|
|
|
|
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
|
|
|
|
|
2017-07-05 17:47:51 +08:00
|
|
|
|
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
|
|
|
|
|
|
|
|
|
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
|
|
|
|
|
|
|
|
|
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
|
|
|
|
|
|
|
|
|
var _createClass2 = require('babel-runtime/helpers/createClass');
|
|
|
|
|
|
|
|
|
|
var _createClass3 = _interopRequireDefault(_createClass2);
|
|
|
|
|
|
2017-07-05 17:47:51 +08:00
|
|
|
|
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
|
|
|
|
|
|
|
|
|
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
|
|
|
|
|
|
|
|
|
var _inherits2 = require('babel-runtime/helpers/inherits');
|
|
|
|
|
|
|
|
|
|
var _inherits3 = _interopRequireDefault(_inherits2);
|
|
|
|
|
|
2017-07-04 16:43:07 +08:00
|
|
|
|
var _group = require('../models/group.js');
|
|
|
|
|
|
|
|
|
|
var _group2 = _interopRequireDefault(_group);
|
|
|
|
|
|
|
|
|
|
var _yapi = require('../yapi.js');
|
|
|
|
|
|
|
|
|
|
var _yapi2 = _interopRequireDefault(_yapi);
|
|
|
|
|
|
2017-07-05 17:47:51 +08:00
|
|
|
|
var _base = require('./base.js');
|
|
|
|
|
|
|
|
|
|
var _base2 = _interopRequireDefault(_base);
|
|
|
|
|
|
2017-07-10 20:02:44 +08:00
|
|
|
|
var _project = require('../models/project.js');
|
|
|
|
|
|
|
|
|
|
var _project2 = _interopRequireDefault(_project);
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
var _user = require('../models/user.js');
|
|
|
|
|
|
|
|
|
|
var _user2 = _interopRequireDefault(_user);
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
var _interface = require('../models/interface.js');
|
|
|
|
|
|
|
|
|
|
var _interface2 = _interopRequireDefault(_interface);
|
|
|
|
|
|
|
|
|
|
var _interfaceCol = require('../models/interfaceCol.js');
|
|
|
|
|
|
|
|
|
|
var _interfaceCol2 = _interopRequireDefault(_interfaceCol);
|
|
|
|
|
|
|
|
|
|
var _interfaceCase = require('../models/interfaceCase.js');
|
|
|
|
|
|
|
|
|
|
var _interfaceCase2 = _interopRequireDefault(_interfaceCase);
|
|
|
|
|
|
2017-07-04 16:43:07 +08:00
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
2017-07-05 17:47:51 +08:00
|
|
|
|
var groupController = function (_baseController) {
|
|
|
|
|
(0, _inherits3.default)(groupController, _baseController);
|
|
|
|
|
|
2017-07-06 19:21:54 +08:00
|
|
|
|
function groupController(ctx) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
(0, _classCallCheck3.default)(this, groupController);
|
2017-07-14 17:00:30 +08:00
|
|
|
|
return (0, _possibleConstructorReturn3.default)(this, (groupController.__proto__ || (0, _getPrototypeOf2.default)(groupController)).call(this, ctx));
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-07-06 19:21:54 +08:00
|
|
|
|
/**
|
|
|
|
|
* 添加项目分组
|
2017-08-15 18:36:48 +08:00
|
|
|
|
* @interface /group/get
|
|
|
|
|
* @method GET
|
2017-07-06 19:21:54 +08:00
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
2017-08-15 18:36:48 +08:00
|
|
|
|
* @param {String} id 项目分组ID
|
2017-07-06 19:21:54 +08:00
|
|
|
|
* @returns {Object}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
* @example
|
2017-07-06 19:21:54 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
(0, _createClass3.default)(groupController, [{
|
2017-08-15 18:36:48 +08:00
|
|
|
|
key: 'get',
|
2017-07-05 16:17:58 +08:00
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
var params, groupInst, result;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
|
while (1) {
|
|
|
|
|
switch (_context.prev = _context.next) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
case 0:
|
|
|
|
|
_context.prev = 0;
|
|
|
|
|
params = ctx.request.query;
|
|
|
|
|
|
|
|
|
|
if (params.id) {
|
|
|
|
|
_context.next = 4;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组id不能为空'));
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
_context.next = 7;
|
|
|
|
|
return groupInst.getGroupById(params.id);
|
|
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
|
result = _context.sent;
|
|
|
|
|
|
|
|
|
|
result = result.toObject();
|
|
|
|
|
_context.next = 11;
|
|
|
|
|
return this.getProjectRole(params.id, 'group');
|
|
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
|
result.role = _context.sent;
|
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
|
|
|
|
_context.next = 18;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 15:
|
|
|
|
|
_context.prev = 15;
|
|
|
|
|
_context.t0 = _context['catch'](0);
|
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context.t0.message);
|
|
|
|
|
|
|
|
|
|
case 18:
|
|
|
|
|
case 'end':
|
|
|
|
|
return _context.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, _callee, this, [[0, 15]]);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
function get(_x) {
|
|
|
|
|
return _ref.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return get;
|
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加项目分组
|
|
|
|
|
* @interface /group/add
|
|
|
|
|
* @method POST
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
|
|
|
|
* @param {String} group_name 项目分组名称,不能为空
|
2017-08-15 18:38:36 +08:00
|
|
|
|
* @param {String} [group_desc] 项目分组描述
|
2017-08-15 18:36:48 +08:00
|
|
|
|
* @param {String} owner_uid 组长uid
|
2017-08-15 18:38:36 +08:00
|
|
|
|
* @returns {Object}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
* @example ./api/group/add.json
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
key: 'add',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
var params, groupUserdata, groupInst, checkRepeat, data, result;
|
|
|
|
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
|
|
|
|
while (1) {
|
|
|
|
|
switch (_context2.prev = _context2.next) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 0:
|
|
|
|
|
params = ctx.request.body;
|
|
|
|
|
|
2017-07-27 14:58:32 +08:00
|
|
|
|
|
2017-07-26 14:22:59 +08:00
|
|
|
|
params = _yapi2.default.commons.handleParams(params, {
|
|
|
|
|
group_name: 'string',
|
2017-08-08 14:45:19 +08:00
|
|
|
|
group_desc: 'string',
|
|
|
|
|
owner_uid: 'number'
|
2017-07-26 14:22:59 +08:00
|
|
|
|
});
|
|
|
|
|
|
2017-07-19 19:38:48 +08:00
|
|
|
|
if (!(this.getRole() !== 'admin')) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 4;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '没有权限'));
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-07-26 14:22:59 +08:00
|
|
|
|
case 4:
|
2017-07-19 19:38:48 +08:00
|
|
|
|
if (params.group_name) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 6;
|
2017-07-19 19:38:48 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目分组名不能为空'));
|
2017-07-19 19:38:48 +08:00
|
|
|
|
|
2017-07-26 14:22:59 +08:00
|
|
|
|
case 6:
|
2017-08-08 14:45:19 +08:00
|
|
|
|
if (params.owner_uid) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 8;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目分组必须添加一个组长'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 8:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 10;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return this.getUserdata(params.owner_uid, 'owner');
|
|
|
|
|
|
|
|
|
|
case 10:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
groupUserdata = _context2.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
if (!(groupUserdata === null)) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 13;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '组长uid不存在'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 13:
|
2017-07-05 16:52:48 +08:00
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 16;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
return groupInst.checkRepeat(params.group_name);
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 16:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
checkRepeat = _context2.sent;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
if (!(checkRepeat > 0)) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 19;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目分组名已存在'));
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 19:
|
2017-07-05 16:17:58 +08:00
|
|
|
|
data = {
|
|
|
|
|
group_name: params.group_name,
|
|
|
|
|
group_desc: params.group_desc,
|
2017-07-26 14:22:59 +08:00
|
|
|
|
uid: this.getUid(),
|
2017-07-05 16:17:58 +08:00
|
|
|
|
add_time: _yapi2.default.commons.time(),
|
2017-08-08 14:45:19 +08:00
|
|
|
|
up_time: _yapi2.default.commons.time(),
|
|
|
|
|
members: [groupUserdata]
|
2017-07-05 16:17:58 +08:00
|
|
|
|
};
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.prev = 20;
|
|
|
|
|
_context2.next = 23;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
return groupInst.save(data);
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 23:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
result = _context2.sent;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-07-27 14:58:32 +08:00
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
result = _yapi2.default.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid', 'members']);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.next = 31;
|
2017-07-04 16:43:07 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 28:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context2.prev = 28;
|
|
|
|
|
_context2.t0 = _context2['catch'](20);
|
2017-07-04 16:43:07 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t0.message);
|
2017-07-04 16:43:07 +08:00
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 31:
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context2.stop();
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-07-04 16:43:07 +08:00
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee2, this, [[20, 28]]);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function add(_x2) {
|
|
|
|
|
return _ref2.apply(this, arguments);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return add;
|
|
|
|
|
}()
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'getUserdata',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
var userInst, userData;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context3.prev = _context3.next) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 0:
|
|
|
|
|
role = role || 'dev';
|
|
|
|
|
userInst = _yapi2.default.getInst(_user2.default);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context3.next = 4;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return userInst.findById(uid);
|
|
|
|
|
|
|
|
|
|
case 4:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
userData = _context3.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
if (userData) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context3.next = 7;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context3.abrupt('return', null);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 7:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context3.abrupt('return', {
|
2017-08-15 17:38:22 +08:00
|
|
|
|
_role: userData.role,
|
2017-08-08 14:45:19 +08:00
|
|
|
|
role: role,
|
|
|
|
|
uid: userData._id,
|
|
|
|
|
username: userData.username,
|
|
|
|
|
email: userData.email
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
case 8:
|
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context3.stop();
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee3, this);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function getUserdata(_x3, _x4) {
|
|
|
|
|
return _ref3.apply(this, arguments);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getUserdata;
|
|
|
|
|
}()
|
2017-08-15 17:38:22 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加项目分组成员
|
|
|
|
|
* @interface /group/add_member
|
|
|
|
|
* @method POST
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
|
|
|
|
* @param {String} id 项目分组id
|
|
|
|
|
* @param {String} member_uid 项目分组成员uid
|
2017-08-17 11:24:46 +08:00
|
|
|
|
* @param {String} role 成员角色,owner or dev
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
|
|
|
|
* @example
|
2017-08-15 17:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'addMember',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
var params, groupInst, check, groupUserdata, result;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context4.prev = _context4.next) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 0:
|
|
|
|
|
params = ctx.request.body;
|
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
|
|
|
|
|
if (params.member_uid) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context4.next = 4;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组成员uid不能为空'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
if (params.id) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context4.next = 6;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组id不能为空'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 6:
|
2017-08-17 11:24:46 +08:00
|
|
|
|
|
|
|
|
|
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
|
|
|
|
|
|
|
|
|
_context4.next = 9;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return groupInst.checkMemberRepeat(params.id, params.member_uid);
|
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 9:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
check = _context4.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
if (!(check > 0)) {
|
2017-08-17 11:24:46 +08:00
|
|
|
|
_context4.next = 12;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '成员已存在'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 12:
|
|
|
|
|
_context4.next = 14;
|
|
|
|
|
return this.getUserdata(params.member_uid, params.role);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 14:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
groupUserdata = _context4.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
if (!(groupUserdata === null)) {
|
2017-08-17 11:24:46 +08:00
|
|
|
|
_context4.next = 17;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '组长uid不存在'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 17:
|
2017-08-15 17:38:22 +08:00
|
|
|
|
if (!(groupUserdata._role === 'admin')) {
|
2017-08-17 11:24:46 +08:00
|
|
|
|
_context4.next = 19;
|
2017-08-15 17:38:22 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不能邀请管理员'));
|
2017-08-15 17:38:22 +08:00
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 19:
|
2017-08-15 17:38:22 +08:00
|
|
|
|
delete groupUserdata._role;
|
2017-08-17 11:24:46 +08:00
|
|
|
|
_context4.prev = 20;
|
|
|
|
|
_context4.next = 23;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return groupInst.addMember(params.id, groupUserdata);
|
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 23:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
result = _context4.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-17 11:24:46 +08:00
|
|
|
|
_context4.next = 30;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 27:
|
|
|
|
|
_context4.prev = 27;
|
|
|
|
|
_context4.t0 = _context4['catch'](20);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-17 11:24:46 +08:00
|
|
|
|
case 30:
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context4.stop();
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-17 11:24:46 +08:00
|
|
|
|
}, _callee4, this, [[20, 27]]);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function addMember(_x5) {
|
|
|
|
|
return _ref4.apply(this, arguments);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return addMember;
|
|
|
|
|
}()
|
2017-08-15 17:38:22 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改项目分组成员角色
|
|
|
|
|
* @interface /group/change_member_role
|
|
|
|
|
* @method POST
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
|
|
|
|
* @param {String} id 项目分组id
|
|
|
|
|
* @param {String} member_uid 项目分组成员uid
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @param {String} role 权限 ['owner'|'dev']
|
|
|
|
|
* @returns {Object}
|
|
|
|
|
* @example
|
2017-08-15 17:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}, {
|
2017-08-08 19:18:12 +08:00
|
|
|
|
key: 'changeMemberRole',
|
2017-08-08 14:45:19 +08:00
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
2017-08-08 19:18:12 +08:00
|
|
|
|
var params, groupInst, check, result;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context5.prev = _context5.next) {
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 0:
|
|
|
|
|
params = ctx.request.body;
|
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
|
|
|
|
|
if (params.member_uid) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 4;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组成员uid不能为空'));
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
if (params.id) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 6;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组id不能为空'));
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 6:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 8;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
return groupInst.checkMemberRepeat(params.id, params.member_uid);
|
|
|
|
|
|
|
|
|
|
case 8:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
check = _context5.sent;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
if (!(check === 0)) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 11;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组成员不存在'));
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 11:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 13;
|
2017-08-15 17:38:22 +08:00
|
|
|
|
return this.checkAuth(params.id, 'group', 'danger');
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 13:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.t0 = _context5.sent;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
if (!(_context5.t0 !== true)) {
|
|
|
|
|
_context5.next = 16;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 16:
|
|
|
|
|
|
|
|
|
|
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.prev = 17;
|
|
|
|
|
_context5.next = 20;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
return groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
|
|
|
|
|
|
|
|
|
case 20:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
result = _context5.sent;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.next = 27;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 24:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context5.prev = 24;
|
|
|
|
|
_context5.t1 = _context5['catch'](17);
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context5.t1.message);
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 27:
|
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context5.stop();
|
2017-08-08 19:18:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee5, this, [[17, 24]]);
|
2017-08-08 19:18:12 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function changeMemberRole(_x6) {
|
|
|
|
|
return _ref5.apply(this, arguments);
|
2017-08-08 19:18:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return changeMemberRole;
|
|
|
|
|
}()
|
2017-08-15 17:38:22 +08:00
|
|
|
|
/**
|
|
|
|
|
* 获取所有项目成员
|
|
|
|
|
* @interface /group/get_member_list
|
|
|
|
|
* @method GET
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
|
|
|
|
* @param {String} id 项目分组id
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
|
|
|
|
* @example
|
2017-08-15 17:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'getMemberList',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
2017-08-08 19:18:12 +08:00
|
|
|
|
var params, groupInst, group;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
2017-08-08 19:18:12 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context6.prev = _context6.next) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 0:
|
|
|
|
|
params = ctx.request.query;
|
|
|
|
|
|
|
|
|
|
if (params.id) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context6.next = 3;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 3:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context6.prev = 3;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context6.next = 7;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return groupInst.get(params.id);
|
|
|
|
|
|
|
|
|
|
case 7:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
group = _context6.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(group.members);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context6.next = 14;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 11:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context6.prev = 11;
|
|
|
|
|
_context6.t0 = _context6['catch'](3);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context6.stop();
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee6, this, [[3, 11]]);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function getMemberList(_x7) {
|
|
|
|
|
return _ref6.apply(this, arguments);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getMemberList;
|
|
|
|
|
}()
|
2017-08-15 17:38:22 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除项目成员
|
|
|
|
|
* @interface /group/del_member
|
|
|
|
|
* @method POST
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
|
|
|
|
* @param {String} id 项目分组id
|
|
|
|
|
* @param {String} member_uid 项目分组成员uid
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
|
|
|
|
* @example
|
2017-08-15 17:38:22 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'delMember',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
var params, groupInst, check, result;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context7.prev = _context7.next) {
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 0:
|
|
|
|
|
params = ctx.request.body;
|
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
|
|
|
|
|
if (params.member_uid) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 4;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组成员uid不能为空'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
if (params.id) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 6;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组id不能为空'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 6:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 8;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return groupInst.checkMemberRepeat(params.id, params.member_uid);
|
|
|
|
|
|
|
|
|
|
case 8:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
check = _context7.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
if (!(check === 0)) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 11;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '分组成员不存在'));
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
case 11:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 13;
|
2017-08-15 17:38:22 +08:00
|
|
|
|
return this.checkAuth(params.id, 'group', 'danger');
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 13:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.t0 = _context7.sent;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
if (!(_context7.t0 !== true)) {
|
|
|
|
|
_context7.next = 16;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
|
|
|
|
case 16:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.prev = 16;
|
|
|
|
|
_context7.next = 19;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
return groupInst.delMember(params.id, params.member_uid);
|
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 19:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
result = _context7.sent;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.next = 26;
|
2017-08-08 14:45:19 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 23:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context7.prev = 23;
|
|
|
|
|
_context7.t1 = _context7['catch'](16);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t1.message);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 26:
|
2017-08-08 14:45:19 +08:00
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context7.stop();
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee7, this, [[16, 23]]);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function delMember(_x8) {
|
|
|
|
|
return _ref7.apply(this, arguments);
|
2017-08-08 14:45:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return delMember;
|
|
|
|
|
}()
|
2017-07-06 20:53:26 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2017-07-10 11:56:53 +08:00
|
|
|
|
* 获取项目分组列表
|
2017-07-06 20:53:26 +08:00
|
|
|
|
* @interface /group/list
|
|
|
|
|
* @method get
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
2017-07-10 11:56:53 +08:00
|
|
|
|
* @example ./api/group/list.json
|
2017-07-06 20:53:26 +08:00
|
|
|
|
*/
|
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'list',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
var groupInst, result;
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
while (1) {
|
2017-08-15 18:36:48 +08:00
|
|
|
|
switch (_context8.prev = _context8.next) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 0:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context8.prev = 0;
|
2017-07-05 16:52:48 +08:00
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context8.next = 4;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
return groupInst.list();
|
|
|
|
|
|
|
|
|
|
case 4:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
result = _context8.sent;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context8.next = 11;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 8:
|
2017-08-15 18:36:48 +08:00
|
|
|
|
_context8.prev = 8;
|
|
|
|
|
_context8.t0 = _context8['catch'](0);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context8.t0.message);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
|
case 'end':
|
2017-08-15 18:36:48 +08:00
|
|
|
|
return _context8.stop();
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-07-04 16:43:07 +08:00
|
|
|
|
}
|
2017-08-15 18:36:48 +08:00
|
|
|
|
}, _callee8, this, [[0, 8]]);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function list(_x9) {
|
|
|
|
|
return _ref8.apply(this, arguments);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}()
|
2017-07-10 11:56:53 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除项目分组
|
|
|
|
|
* @interface /group/del
|
|
|
|
|
* @method post
|
|
|
|
|
* @param {String} id 项目分组id
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
2017-07-10 11:56:53 +08:00
|
|
|
|
* @example ./api/group/del.json
|
|
|
|
|
*/
|
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'del',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
var _this2 = this;
|
|
|
|
|
|
2017-08-25 16:25:34 +08:00
|
|
|
|
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, id, projectList, result;
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
while (1) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
switch (_context10.prev = _context10.next) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 0:
|
2017-07-19 19:38:48 +08:00
|
|
|
|
if (!(this.getRole() !== 'admin')) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context10.next = 2;
|
2017-07-19 19:38:48 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '没有权限'));
|
2017-07-19 19:38:48 +08:00
|
|
|
|
|
|
|
|
|
case 2:
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context10.prev = 2;
|
2017-07-05 16:52:48 +08:00
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
2017-07-10 20:02:44 +08:00
|
|
|
|
projectInst = _yapi2.default.getInst(_project2.default);
|
2017-08-16 10:56:42 +08:00
|
|
|
|
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
|
|
|
|
interfaceColInst = _yapi2.default.getInst(_interfaceCol2.default);
|
|
|
|
|
interfaceCaseInst = _yapi2.default.getInst(_interfaceCase2.default);
|
2017-08-25 16:25:34 +08:00
|
|
|
|
id = ctx.request.body.id;
|
2017-07-10 20:02:44 +08:00
|
|
|
|
|
2017-08-25 16:25:34 +08:00
|
|
|
|
if (id) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context10.next = 11;
|
2017-07-10 20:02:44 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, 'id不能为空'));
|
2017-07-10 20:02:44 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
case 11:
|
|
|
|
|
_context10.next = 13;
|
2017-08-25 16:25:34 +08:00
|
|
|
|
return projectInst.list(id, true);
|
2017-07-10 20:02:44 +08:00
|
|
|
|
|
2017-07-19 20:01:29 +08:00
|
|
|
|
case 13:
|
2017-08-16 10:56:42 +08:00
|
|
|
|
projectList = _context10.sent;
|
|
|
|
|
|
|
|
|
|
projectList.forEach(function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
|
|
|
|
while (1) {
|
|
|
|
|
switch (_context9.prev = _context9.next) {
|
|
|
|
|
case 0:
|
|
|
|
|
_context9.next = 2;
|
|
|
|
|
return interfaceInst.delByProjectId(p._id);
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
_context9.next = 4;
|
|
|
|
|
return interfaceCaseInst.delByProjectId(p._id);
|
|
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
|
_context9.next = 6;
|
|
|
|
|
return interfaceColInst.delByProjectId(p._id);
|
|
|
|
|
|
|
|
|
|
case 6:
|
|
|
|
|
case 'end':
|
|
|
|
|
return _context9.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, _callee9, _this2);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return function (_x11) {
|
|
|
|
|
return _ref10.apply(this, arguments);
|
|
|
|
|
};
|
|
|
|
|
}());
|
|
|
|
|
_context10.next = 17;
|
2017-08-25 16:25:34 +08:00
|
|
|
|
return projectInst.delByGroupid(id);
|
2017-08-16 10:56:42 +08:00
|
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
|
_context10.next = 19;
|
2017-08-25 16:25:34 +08:00
|
|
|
|
return groupInst.del(id);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
case 19:
|
|
|
|
|
result = _context10.sent;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context10.next = 26;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
case 23:
|
|
|
|
|
_context10.prev = 23;
|
|
|
|
|
_context10.t0 = _context10['catch'](2);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t0.message);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
case 26:
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 'end':
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _context10.stop();
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-07-04 16:43:07 +08:00
|
|
|
|
}
|
2017-08-16 10:56:42 +08:00
|
|
|
|
}, _callee10, this, [[2, 23]]);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-15 18:36:48 +08:00
|
|
|
|
function del(_x10) {
|
|
|
|
|
return _ref9.apply(this, arguments);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return del;
|
|
|
|
|
}()
|
2017-07-10 11:56:53 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新项目分组
|
|
|
|
|
* @interface /group/up
|
|
|
|
|
* @method post
|
|
|
|
|
* @param {String} id 项目分组id
|
|
|
|
|
* @param {String} group_name 项目分组名称
|
|
|
|
|
* @param {String} group_desc 项目分组描述
|
|
|
|
|
* @category group
|
|
|
|
|
* @foldnumber 10
|
2017-08-15 18:23:30 +08:00
|
|
|
|
* @returns {Object}
|
2017-07-10 11:56:53 +08:00
|
|
|
|
* @example ./api/group/up.json
|
|
|
|
|
*/
|
|
|
|
|
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}, {
|
|
|
|
|
key: 'up',
|
|
|
|
|
value: function () {
|
2017-08-29 11:17:54 +08:00
|
|
|
|
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
2017-08-25 16:25:34 +08:00
|
|
|
|
var groupInst, id, data, result;
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
while (1) {
|
2017-08-16 10:56:42 +08:00
|
|
|
|
switch (_context11.prev = _context11.next) {
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 0:
|
2017-08-25 16:25:34 +08:00
|
|
|
|
groupInst = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
id = ctx.request.body.id;
|
|
|
|
|
data = {};
|
|
|
|
|
_context11.next = 5;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
return this.checkAuth(id, 'group', 'danger');
|
|
|
|
|
|
2017-08-25 16:25:34 +08:00
|
|
|
|
case 5:
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context11.t0 = _context11.sent;
|
2017-08-08 19:18:12 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
if (!(_context11.t0 !== true)) {
|
2017-08-25 16:25:34 +08:00
|
|
|
|
_context11.next = 8;
|
2017-07-19 19:38:48 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
2017-07-26 14:22:59 +08:00
|
|
|
|
|
2017-08-25 16:25:34 +08:00
|
|
|
|
case 8:
|
|
|
|
|
_context11.prev = 8;
|
2017-07-26 14:22:59 +08:00
|
|
|
|
|
|
|
|
|
ctx.request.body = _yapi2.default.commons.handleParams(ctx.request.body, {
|
|
|
|
|
id: 'number',
|
|
|
|
|
group_name: 'string',
|
|
|
|
|
group_desc: 'string'
|
|
|
|
|
});
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
ctx.request.body.group_name && (data.group_name = ctx.request.body.group_name);
|
|
|
|
|
ctx.request.body.group_desc && (data.group_desc = ctx.request.body.group_desc);
|
|
|
|
|
if ((0, _keys2.default)(data).length === 0) {
|
2017-07-06 19:21:54 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 404, '分组名和分组描述不能为空');
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context11.next = 15;
|
2017-08-25 16:25:34 +08:00
|
|
|
|
return groupInst.up(id, data);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 15:
|
2017-08-16 10:56:42 +08:00
|
|
|
|
result = _context11.sent;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(result);
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context11.next = 22;
|
2017-07-05 16:17:58 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 19:
|
2017-08-16 10:56:42 +08:00
|
|
|
|
_context11.prev = 19;
|
2017-08-25 16:25:34 +08:00
|
|
|
|
_context11.t1 = _context11['catch'](8);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t1.message);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
2017-08-08 19:18:12 +08:00
|
|
|
|
case 22:
|
2017-07-05 16:17:58 +08:00
|
|
|
|
case 'end':
|
2017-08-16 10:56:42 +08:00
|
|
|
|
return _context11.stop();
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
2017-07-04 16:43:07 +08:00
|
|
|
|
}
|
2017-08-25 16:25:34 +08:00
|
|
|
|
}, _callee11, this, [[8, 19]]);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}));
|
|
|
|
|
|
2017-08-16 10:56:42 +08:00
|
|
|
|
function up(_x12) {
|
|
|
|
|
return _ref11.apply(this, arguments);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return up;
|
|
|
|
|
}()
|
|
|
|
|
}]);
|
|
|
|
|
return groupController;
|
2017-07-05 17:47:51 +08:00
|
|
|
|
}(_base2.default);
|
2017-07-05 16:17:58 +08:00
|
|
|
|
|
|
|
|
|
module.exports = groupController;
|