From ab08cae0b376c9fbb4b136d90a64bf02eee95217 Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Fri, 25 Aug 2017 16:25:34 +0800 Subject: [PATCH 1/2] fix: group/up bug --- .../containers/Group/GroupList/GroupList.js | 2 +- .../Project/Interface/InterfaceList/Edit.js | 38 ++++++------ server/controllers/group.js | 13 ++-- server_dist/controllers/group.js | 60 +++++++++---------- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/client/containers/Group/GroupList/GroupList.js b/client/containers/Group/GroupList/GroupList.js index 159ad96f..48580fff 100644 --- a/client/containers/Group/GroupList/GroupList.js +++ b/client/containers/Group/GroupList/GroupList.js @@ -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 { diff --git a/client/containers/Project/Interface/InterfaceList/Edit.js b/client/containers/Project/Interface/InterfaceList/Edit.js index 64d76ce3..4264de97 100644 --- a/client/containers/Project/Interface/InterfaceList/Edit.js +++ b/client/containers/Project/Interface/InterfaceList/Edit.js @@ -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 + // }) + // } - } + // } } diff --git a/server/controllers/group.js b/server/controllers/group.js index a7158792..c73ad6cf 100644 --- a/server/controllers/group.js +++ b/server/controllers/group.js @@ -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) { diff --git a/server_dist/controllers/group.js b/server_dist/controllers/group.js index d6d2cc01..dd9591d8 100644 --- a/server_dist/controllers/group.js +++ b/server_dist/controllers/group.js @@ -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) { From 22b59964b2eec446ec7b08dd5ff8927085044bf2 Mon Sep 17 00:00:00 2001 From: suxiaoxin Date: Fri, 25 Aug 2017 16:31:53 +0800 Subject: [PATCH 2/2] fix: interface edit catid bug --- .../Project/Interface/InterfaceList/InterfaceEditForm.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js index 1cc101e8..37f2d83c 100644 --- a/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js +++ b/client/containers/Project/Interface/InterfaceList/InterfaceEditForm.js @@ -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: '请选择一个分类' } ]