Merg branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
wenbo.dong 2017-08-25 17:16:51 +08:00
commit 6a417b68b1
5 changed files with 58 additions and 59 deletions

View File

@ -124,7 +124,7 @@ export default class GroupList extends Component {
async editGroup() {
const { currGroupName: group_name, currGroupDesc: group_desc } = this.state;
const id = this.props.currGroup._id;
const res = axios.post('/api/group/up', { group_name, group_desc, id });
const res = await axios.post('/api/group/up', { group_name, group_desc, id });
if (res.data.errcode) {
message.error(res.data.errmsg);
} else {

View File

@ -61,27 +61,27 @@ class InterfaceEdit extends Component {
}
componentWillMount() {
let domain = location.hostname + (location.port !== "" ? ":" + location.port : "");
let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
s.onopen = () => {
this.WebSocket = s;
}
// let domain = location.hostname + (location.port !== "" ? ":" + location.port : "");
// let s = new WebSocket('ws://' + domain + '/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
// s.onopen = () => {
// this.WebSocket = s;
// }
s.onmessage = (e) => {
let result = JSON.parse(e.data);
if (result.errno === 0) {
this.setState({
curdata: result.data,
status: 1
})
} else {
this.setState({
curdata: result.data,
status: 2
})
}
// s.onmessage = (e) => {
// let result = JSON.parse(e.data);
// if (result.errno === 0) {
// this.setState({
// curdata: result.data,
// status: 1
// })
// } else {
// this.setState({
// curdata: result.data,
// status: 2
// })
// }
}
// }
}

View File

@ -47,7 +47,6 @@ class InterfaceEditForm extends Component {
return item
})
}
this.state = Object.assign({
title: '',
path: '',
@ -87,7 +86,6 @@ class InterfaceEditForm extends Component {
e.preventDefault();
this.props.form.validateFields((err, values) => {
if (!err) {
console.log(values)
if (values.res_body_type === 'json') values.res_body = this.state.res_body;
values.req_params = this.state.req_params;
values.req_body_other = this.state.req_body_other;
@ -373,7 +371,7 @@ class InterfaceEditForm extends Component {
label="选择分类"
>
{getFieldDecorator('catid', {
initialValue: _.find(this.props.cat, item => item._id === this.state.catid).name,
initialValue: this.state.catid + "",
rules: [
{ required: true, message: '请选择一个分类' }
]

View File

@ -134,7 +134,7 @@ class groupController extends baseController {
async addMember(ctx){
async addMember(ctx) {
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@ -314,7 +314,7 @@ class groupController extends baseController {
if (!id) {
return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
}
let projectList =await projectInst.list(id, true);
let projectList = await projectInst.list(id, true);
projectList.forEach(async (p) => {
await interfaceInst.delByProjectId(p._id)
await interfaceCaseInst.delByProjectId(p._id)
@ -341,6 +341,11 @@ class groupController extends baseController {
* @example ./api/group/up.json
*/
async up(ctx) {
let groupInst = yapi.getInst(groupModel);
let id = ctx.request.body.id;
let data = {};
if (await this.checkAuth(id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@ -350,9 +355,7 @@ class groupController extends baseController {
group_name: 'string',
group_desc: 'string'
});
let groupInst = yapi.getInst(groupModel);
let id = ctx.request.body.id;
let data = {};
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 (Object.keys(data).length === 0) {

View File

@ -88,7 +88,7 @@ var groupController = function (_baseController) {
(0, _createClass3.default)(groupController, [{
key: 'get',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
var params, groupInst, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
@ -160,7 +160,7 @@ var groupController = function (_baseController) {
}, {
key: 'add',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
var params, groupUserdata, groupInst, checkRepeat, data, result;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
@ -272,7 +272,7 @@ var groupController = function (_baseController) {
}, {
key: 'getUserdata',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(uid, role) {
var userInst, userData;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
@ -333,7 +333,7 @@ var groupController = function (_baseController) {
}, {
key: 'addMember',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
var params, groupInst, check, groupUserdata, result;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
@ -446,7 +446,7 @@ var groupController = function (_baseController) {
}, {
key: 'changeMemberRole',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
@ -547,7 +547,7 @@ var groupController = function (_baseController) {
}, {
key: 'getMemberList',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
var params, groupInst, group;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
@ -611,7 +611,7 @@ var groupController = function (_baseController) {
}, {
key: 'delMember',
value: function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
@ -709,7 +709,7 @@ var groupController = function (_baseController) {
}, {
key: 'list',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
var groupInst, result;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
@ -762,11 +762,10 @@ var groupController = function (_baseController) {
}, {
key: 'del',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
var _this2 = this;
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, _id, projectList, result;
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, id, projectList, result;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
@ -785,9 +784,9 @@ var groupController = function (_baseController) {
interfaceInst = _yapi2.default.getInst(_interface2.default);
interfaceColInst = _yapi2.default.getInst(_interfaceCol2.default);
interfaceCaseInst = _yapi2.default.getInst(_interfaceCase2.default);
_id = ctx.request.body.id;
id = ctx.request.body.id;
if (_id) {
if (id) {
_context10.next = 11;
break;
}
@ -796,13 +795,13 @@ var groupController = function (_baseController) {
case 11:
_context10.next = 13;
return projectInst.list(_id, true);
return projectInst.list(id, true);
case 13:
projectList = _context10.sent;
projectList.forEach(function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(p) {
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
@ -831,11 +830,11 @@ var groupController = function (_baseController) {
};
}());
_context10.next = 17;
return projectInst.delByGroupid(_id);
return projectInst.delByGroupid(id);
case 17:
_context10.next = 19;
return groupInst.del(_id);
return groupInst.del(id);
case 19:
result = _context10.sent;
@ -881,37 +880,36 @@ var groupController = function (_baseController) {
}, {
key: 'up',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var groupInst, _id2, data, result;
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
var groupInst, id, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
_context11.next = 2;
groupInst = _yapi2.default.getInst(_group2.default);
id = ctx.request.body.id;
data = {};
_context11.next = 5;
return this.checkAuth(id, 'group', 'danger');
case 2:
case 5:
_context11.t0 = _context11.sent;
if (!(_context11.t0 !== true)) {
_context11.next = 5;
_context11.next = 8;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
case 5:
_context11.prev = 5;
case 8:
_context11.prev = 8;
ctx.request.body = _yapi2.default.commons.handleParams(ctx.request.body, {
id: 'number',
group_name: 'string',
group_desc: 'string'
});
groupInst = _yapi2.default.getInst(_group2.default);
_id2 = ctx.request.body.id;
data = {};
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);
@ -919,7 +917,7 @@ var groupController = function (_baseController) {
ctx.body = _yapi2.default.commons.resReturn(null, 404, '分组名和分组描述不能为空');
}
_context11.next = 15;
return groupInst.up(_id2, data);
return groupInst.up(id, data);
case 15:
result = _context11.sent;
@ -930,7 +928,7 @@ var groupController = function (_baseController) {
case 19:
_context11.prev = 19;
_context11.t1 = _context11['catch'](5);
_context11.t1 = _context11['catch'](8);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t1.message);
@ -939,7 +937,7 @@ var groupController = function (_baseController) {
return _context11.stop();
}
}
}, _callee11, this, [[5, 19]]);
}, _callee11, this, [[8, 19]]);
}));
function up(_x12) {