请求Headers:
diff --git a/client/containers/User/index.scss b/client/containers/User/index.scss
index 0b840353..858b2b4d 100644
--- a/client/containers/User/index.scss
+++ b/client/containers/User/index.scss
@@ -71,7 +71,7 @@
z-index: 3;
}
.user-item-body{
- width: 80%;
+ width: 95%;
margin: 0px auto;
padding: 32px;
position: relative;
@@ -144,6 +144,7 @@
margin-right: 30px;
white-space: nowrap;
text-align: right;
+ width: 130px;
}
.text{
padding-right: 15px;
@@ -181,6 +182,7 @@
height: 100px;
background-color: white;
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.31), 0 1px 3px rgba(0, 0, 0, 0.08);
+ margin-left: 60px;
img{
width: 100%;
}
@@ -196,7 +198,7 @@
.avatar-box{
width: 100px;
position: relative;
- // margin-left: 160px;
+ margin-left: 60px;
}
.avatarCon{
// background: gray;
diff --git a/server/controllers/interface.js b/server/controllers/interface.js
index 00c3fb5b..e3f8ed0f 100644
--- a/server/controllers/interface.js
+++ b/server/controllers/interface.js
@@ -113,16 +113,19 @@ class interfaceController extends baseController {
}
let result = await this.Model.save(data);
- let username = this.getUsername();
+
// let project = await this.projectModel.get(params.project_id);
- let cate = await this.catModel.get(params.catid);
- yapi.commons.saveLog({
- content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.project_id
+ this.catModel.get(params.catid).then((cate)=>{
+ let username = this.getUsername();
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: params.project_id
+ });
});
+
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -340,21 +343,30 @@ class interfaceController extends baseController {
try {
let result = await this.Model.up(id, data);
let username = this.getUsername();
- let cate;
if (params.catid) {
- cate = await this.catModel.get(+params.catid);
+ this.catModel.get(+params.catid).then((cate)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
+ });
} else {
- let inter = await this.Model.get(id);
- cate = interfaceData.catid;
+ let cateid = interfaceData.catid;
+ this.catModel.get(cateid).then((cate)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
+ });
}
- yapi.commons.saveLog({
- content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: cate.project_id
- });
+
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -394,14 +406,16 @@ class interfaceController extends baseController {
let result = await this.Model.del(id);
let username = this.getUsername();
- let cate = await this.catModel.get(inter.catid);
- yapi.commons.saveLog({
- content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: cate.project_id
- });
+ this.catModel.get(inter.catid).then((cate)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
+ })
+
ctx.body = yapi.commons.resReturn(result);
} catch (err) {
@@ -529,22 +543,18 @@ class interfaceController extends baseController {
}
}
- let cate = await this.catModel.get(id);
- let result = await this.catModel.del(id);
- let r = await this.Model.delByCatid(id);
let username = this.getUsername();
-
yapi.commons.saveLog({
- content: `用户 "${username}" 删除了分类 "${cate.name}" 及该分类下的接口`,
+ content: `用户 "${username}" 删除了分类 "${catData.name}" 及该分类下的接口`,
type: 'project',
uid: this.getUid(),
username: username,
- typeid: cate.project_id
+ typeid: catData.project_id
});
+ let result = await this.catModel.del(id);
+ let r = await this.Model.delByCatid(id);
return ctx.body = yapi.commons.resReturn(r);
-
-
} catch (e) {
yapi.commons.resReturn(null, 400, e.message)
}
diff --git a/server/controllers/interfaceCol.js b/server/controllers/interfaceCol.js
index e41a611f..cd0f031a 100644
--- a/server/controllers/interfaceCol.js
+++ b/server/controllers/interfaceCol.js
@@ -76,7 +76,15 @@ class interfaceColController extends baseController{
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
- })
+ });
+ let username = this.getUsername();
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 添加了接口集 "${params.name}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: params.project_id
+ });
ctx.body = yapi.commons.resReturn(result);
}catch(e){
@@ -162,7 +170,19 @@ class interfaceColController extends baseController{
params.add_time = yapi.commons.time();
params.up_time = yapi.commons.time();
let result = await this.caseModel.save(params);
+ let username = this.getUsername();
+ this.colModel.get(params.col_id).then((col)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 在接口集 "${col.name}" 下添加了接口用例 "${params.casename}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: params.project_id
+ });
+ });
+
+
ctx.body = yapi.commons.resReturn(result);
}catch(e){
@@ -171,7 +191,7 @@ class interfaceColController extends baseController{
}
/**
- * 增加一个接口用例
+ * 更新一个接口用例
* @interface /col/up_case
* @method POST
* @category col
@@ -208,8 +228,8 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '用例名称不能为空');
}
- let caseData = await this.caseModel.get(id);
- let auth = await this.checkAuth(caseData.project_id, 'project', 'edit')
+ let caseData = await this.caseModel.get(params.id);
+ let auth = await this.checkAuth(caseData.project_id, 'project', 'edit');
if (!auth) {
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
@@ -217,6 +237,18 @@ class interfaceColController extends baseController{
params.uid = this.getUid();
let result = await this.caseModel.up(params.id, params);
+ let username = this.getUsername();
+ this.colModel.get(caseData.col_id).then((col)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 在接口集 "${col.name}" 更新了接口用例 "${params.casename}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: caseData.project_id
+ });
+ });
+
+
ctx.body = yapi.commons.resReturn(result);
@@ -272,7 +304,15 @@ class interfaceColController extends baseController{
name: params.name,
desc: params.desc,
up_time: yapi.commons.time()
- })
+ });
+ let username = this.getUsername();
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 更新了接口集 "${params.name}" 的信息`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: colData.project_id
+ });
ctx.body = yapi.commons.resReturn(result)
}catch(e){
ctx.body = yapi.commons.resReturn(null, 400, e.message)
@@ -296,6 +336,7 @@ class interfaceColController extends baseController{
if(!params || !Array.isArray(params)){
ctx.body = yapi.commons.resReturn(null, 400, "请求参数必须是数组")
}
+ // let caseName = "";
params.forEach((item) => {
if(item.id && item.index){
this.caseModel.upCaseIndex(item.id, item.index).then((res) => {}, (err) => {
@@ -303,7 +344,16 @@ class interfaceColController extends baseController{
})
}
- })
+ });
+
+ // let username = this.getUsername();
+ // yapi.commons.saveLog({
+ // content: `用户 "${username}" 更新了接口集 "${params.col_name}"`,
+ // type: 'project',
+ // uid: this.getUid(),
+ // username: username,
+ // typeid: params.project_id
+ // });
return ctx.body = yapi.commons.resReturn('success')
}catch(e){
@@ -336,12 +386,17 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
}
}
-
let result = await this.colModel.del(id);
- await this.caseModel.delByCol(id)
+ await this.caseModel.delByCol(id);
+ let username = this.getUsername();
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 删除了接口集 "${colData.name}" 及其下面的接口`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: colData.project_id
+ });
return ctx.body = yapi.commons.resReturn(result);
-
-
}catch(e){
yapi.commons.resReturn(null, 400, e.message)
}
@@ -368,6 +423,19 @@ class interfaceColController extends baseController{
}
let result = await this.caseModel.del(caseid);
+
+ let username = this.getUsername();
+ this.colModel.get(caseData.col_id).then((col)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 删除了接口集 "${col.name}" 下的接口 "${caseData.casename}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: caseData.project_id
+ });
+ });
+
+
return ctx.body = yapi.commons.resReturn(result);
diff --git a/server/controllers/project.js b/server/controllers/project.js
index 2bb003f7..861f82b1 100644
--- a/server/controllers/project.js
+++ b/server/controllers/project.js
@@ -232,14 +232,14 @@ class projectController extends baseController {
try {
let result = await this.Model.delMember(params.id, params.member_uid);
let username = this.getUsername();
- let project = await this.Model.get(params.id);
- let member = await yapi.getInst(userModel).findById(params.member_uid);
- yapi.commons.saveLog({
- content: `用户 "${username}" 删除了项目 "${project.name}" 中的成员 "${member.username}"`,
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.id
+ yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 删除了项目中的成员 "${member.username}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: params.id
+ });
});
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
@@ -441,15 +441,15 @@ class projectController extends baseController {
let result = await projectInst.changeMemberRole(params.id, params.member_uid, params.role);
let username = this.getUsername();
- let project = await this.Model.get(params.id);
- let member = await yapi.getInst(userModel).findById(params.member_uid);
- yapi.commons.saveLog({
- content: `用户 "${username}" 修改了项目 "${project.name}" 中成员 "${member.username}" 的角色为 "${params.role}"`,
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.id
- });
+ yapi.getInst(userModel).findById(params.member_uid).then((member)=>{
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 修改了项目中的成员 "${member.username}" 的角色为 "${params.role}"`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: params.id
+ });
+ })
ctx.body = yapi.commons.resReturn(result);
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -483,7 +483,16 @@ class projectController extends baseController {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try {
- this.followModel.updateById(this.getUid(), id, data).then();
+ this.followModel.updateById(this.getUid(), id, data).then(()=>{
+ let username = this.getUsername();
+ yapi.commons.saveLog({
+ content: `用户 "${username}" 修改了项目图标、颜色`,
+ type: 'project',
+ uid: this.getUid(),
+ username: username,
+ typeid: id
+ });
+ });
} catch (e) {
yapi.commons.log(e, 'error'); // eslint-disable-line
}
@@ -570,43 +579,6 @@ class projectController extends baseController {
}
}
- /**
- * 修改项目头像
- * @interface /project/upset
- * @method POST
- * @category project
- * @foldnumber 10
- * @param {Number} id
- * @param {String} color
- * @param {String} icon
- * @return {Object}
- */
- async upSet(ctx) {
- let id = ctx.request.body.id;
- let data = {};
- data.color = ctx.request.body.color;
- data.icon = ctx.request.body.icon;
- if (!id) {
- return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
- }
-
- let auth = await this.checkAuth(id, 'project', 'danger')
- if (!auth) {
- return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
- }
- try {
- let result = await this.Model.up(id, data);
- ctx.body = yapi.commons.resReturn(result);
- } catch (e) {
- ctx.body = yapi.commons.resReturn(null, 402, e.message);
- }
- try {
- this.followModel.updateById(this.getUid(), id, data).then();
- } catch (e) {
- yapi.commons.log(e, 'error'); // eslint-disable-line
- }
- }
-
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search
diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js
index d52b3d3f..ed9dded3 100644
--- a/server_dist/controllers/interface.js
+++ b/server_dist/controllers/interface.js
@@ -106,7 +106,9 @@ var interfaceController = function (_baseController) {
key: 'add',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
- var params, auth, checkRepeat, data, result, username, cate;
+ var _this2 = this;
+
+ var params, auth, checkRepeat, data, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
@@ -218,38 +220,36 @@ var interfaceController = function (_baseController) {
case 29:
result = _context.sent;
- username = this.getUsername();
+
+
// let project = await this.projectModel.get(params.project_id);
-
- _context.next = 33;
- return this.catModel.get(params.catid);
-
- case 33:
- cate = _context.sent;
-
- _yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u4E3A\u5206\u7C7B "' + cate.name + '" \u6DFB\u52A0\u4E86\u63A5\u53E3 "' + data.title + '"',
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.project_id
+ this.catModel.get(params.catid).then(function (cate) {
+ var username = _this2.getUsername();
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u4E3A\u5206\u7C7B "' + cate.name + '" \u6DFB\u52A0\u4E86\u63A5\u53E3 "' + data.title + '"',
+ type: 'project',
+ uid: _this2.getUid(),
+ username: username,
+ typeid: params.project_id
+ });
});
+
ctx.body = _yapi2.default.commons.resReturn(result);
- _context.next = 41;
+ _context.next = 37;
break;
- case 38:
- _context.prev = 38;
+ case 34:
+ _context.prev = 34;
_context.t0 = _context['catch'](21);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
- case 41:
+ case 37:
case 'end':
return _context.stop();
}
}
- }, _callee, this, [[21, 38]]);
+ }, _callee, this, [[21, 34]]);
}));
function add(_x) {
@@ -541,7 +541,9 @@ var interfaceController = function (_baseController) {
key: 'up',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
- var params, id, interfaceData, auth, checkRepeat, data, result, username, cate, inter;
+ var _this3 = this;
+
+ var params, id, interfaceData, auth, checkRepeat, data, result, username, cateid;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
@@ -681,55 +683,47 @@ var interfaceController = function (_baseController) {
case 41:
result = _context6.sent;
username = this.getUsername();
- cate = void 0;
- if (!params.catid) {
- _context6.next = 50;
- break;
+ if (params.catid) {
+ this.catModel.get(+params.catid).then(function (cate) {
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
+ type: 'project',
+ uid: _this3.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
+ });
+ } else {
+ cateid = interfaceData.catid;
+
+ this.catModel.get(cateid).then(function (cate) {
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
+ type: 'project',
+ uid: _this3.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
+ });
}
- _context6.next = 47;
- return this.catModel.get(+params.catid);
+ ctx.body = _yapi2.default.commons.resReturn(result);
+ _context6.next = 50;
+ break;
case 47:
- cate = _context6.sent;
- _context6.next = 54;
- break;
-
- case 50:
- _context6.next = 52;
- return this.Model.get(id);
-
- case 52:
- inter = _context6.sent;
-
- cate = interfaceData.catid;
-
- case 54:
-
- _yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: cate.project_id
- });
- ctx.body = _yapi2.default.commons.resReturn(result);
- _context6.next = 61;
- break;
-
- case 58:
- _context6.prev = 58;
+ _context6.prev = 47;
_context6.t0 = _context6['catch'](38);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
- case 61:
+ case 50:
case 'end':
return _context6.stop();
}
}
- }, _callee6, this, [[38, 58]]);
+ }, _callee6, this, [[38, 47]]);
}));
function up(_x6) {
@@ -754,7 +748,9 @@ var interfaceController = function (_baseController) {
key: 'del',
value: function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
- var id, data, auth, inter, result, username, cate;
+ var _this4 = this;
+
+ var id, data, auth, inter, result, username;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
@@ -806,36 +802,33 @@ var interfaceController = function (_baseController) {
case 18:
result = _context7.sent;
username = this.getUsername();
- _context7.next = 22;
- return this.catModel.get(inter.catid);
- case 22:
- cate = _context7.sent;
-
- _yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + inter.title + '"',
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: cate.project_id
+ this.catModel.get(inter.catid).then(function (cate) {
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + inter.title + '"',
+ type: 'project',
+ uid: _this4.getUid(),
+ username: username,
+ typeid: cate.project_id
+ });
});
ctx.body = _yapi2.default.commons.resReturn(result);
- _context7.next = 30;
+ _context7.next = 27;
break;
- case 27:
- _context7.prev = 27;
+ case 24:
+ _context7.prev = 24;
_context7.t0 = _context7['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t0.message);
- case 30:
+ case 27:
case 'end':
return _context7.stop();
}
}
- }, _callee7, this, [[0, 27]]);
+ }, _callee7, this, [[0, 24]]);
}));
function del(_x7) {
@@ -848,7 +841,7 @@ var interfaceController = function (_baseController) {
key: 'solveConflict',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
- var _this2 = this;
+ var _this5 = this;
var id, result, userInst, userinfo, data;
return _regenerator2.default.wrap(function _callee8$(_context8) {
@@ -902,7 +895,7 @@ var interfaceController = function (_baseController) {
case 18:
ctx.websocket.send((0, _stringify2.default)(data));
ctx.websocket.on('close', function () {
- _this2.Model.upEditUid(id, 0).then();
+ _this5.Model.upEditUid(id, 0).then();
});
_context8.next = 25;
break;
@@ -1098,7 +1091,7 @@ var interfaceController = function (_baseController) {
key: 'delCat',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
- var id, catData, auth, cate, result, r, username;
+ var id, catData, auth, username, result, r;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
@@ -1134,46 +1127,40 @@ var interfaceController = function (_baseController) {
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
case 12:
- _context11.next = 14;
- return this.catModel.get(id);
-
- case 14:
- cate = _context11.sent;
- _context11.next = 17;
- return this.catModel.del(id);
-
- case 17:
- result = _context11.sent;
- _context11.next = 20;
- return this.Model.delByCatid(id);
-
- case 20:
- r = _context11.sent;
username = this.getUsername();
-
_yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + cate.name + '" \u53CA\u8BE5\u5206\u7C7B\u4E0B\u7684\u63A5\u53E3',
+ content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + catData.name + '" \u53CA\u8BE5\u5206\u7C7B\u4E0B\u7684\u63A5\u53E3',
type: 'project',
uid: this.getUid(),
username: username,
- typeid: cate.project_id
+ typeid: catData.project_id
});
+ _context11.next = 16;
+ return this.catModel.del(id);
+
+ case 16:
+ result = _context11.sent;
+ _context11.next = 19;
+ return this.Model.delByCatid(id);
+
+ case 19:
+ r = _context11.sent;
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(r));
- case 26:
- _context11.prev = 26;
+ case 23:
+ _context11.prev = 23;
_context11.t0 = _context11['catch'](0);
_yapi2.default.commons.resReturn(null, 400, _context11.t0.message);
- case 29:
+ case 26:
case 'end':
return _context11.stop();
}
}
- }, _callee11, this, [[0, 26]]);
+ }, _callee11, this, [[0, 23]]);
}));
function delCat(_x11) {
diff --git a/server_dist/controllers/interfaceCol.js b/server_dist/controllers/interfaceCol.js
index c50294b6..cc4dcfb9 100644
--- a/server_dist/controllers/interfaceCol.js
+++ b/server_dist/controllers/interfaceCol.js
@@ -75,16 +75,15 @@ var interfaceColController = function (_baseController) {
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
- var _id, result, i;
-
+ 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;
+ id = ctx.query.project_id;
_context.next = 4;
- return this.colModel.list(_id);
+ return this.colModel.list(id);
case 4:
result = _context.sent;
@@ -151,7 +150,7 @@ var interfaceColController = function (_baseController) {
key: 'addCol',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
- var params, auth, result;
+ var params, auth, result, username;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
@@ -207,24 +206,32 @@ var interfaceColController = function (_baseController) {
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 = 21;
+ _context2.next = 23;
break;
- case 18:
- _context2.prev = 18;
+ case 20:
+ _context2.prev = 20;
_context2.t0 = _context2['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t0.message);
- case 21:
+ case 23:
case 'end':
return _context2.stop();
}
}
- }, _callee2, this, [[0, 18]]);
+ }, _callee2, this, [[0, 20]]);
}));
function addCol(_x2) {
@@ -249,17 +256,16 @@ var interfaceColController = function (_baseController) {
key: 'getCaseList',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
- var _id2, inst, result;
-
+ var id, inst, result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
- _id2 = ctx.query.col_id;
+ id = ctx.query.col_id;
inst = _yapi2.default.getInst(_interfaceCase2.default);
_context3.next = 5;
- return inst.list(_id2, 'all');
+ return inst.list(id, 'all');
case 5:
result = _context3.sent;
@@ -314,7 +320,9 @@ var interfaceColController = function (_baseController) {
key: 'addCase',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
- var params, auth, result;
+ var _this2 = this;
+
+ var params, auth, result, username;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
@@ -378,25 +386,36 @@ var interfaceColController = function (_baseController) {
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 = 27;
+ _context4.next = 29;
break;
- case 24:
- _context4.prev = 24;
+ case 26:
+ _context4.prev = 26;
_context4.t0 = _context4['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
- case 27:
+ case 29:
case 'end':
return _context4.stop();
}
}
- }, _callee4, this, [[0, 24]]);
+ }, _callee4, this, [[0, 26]]);
}));
function addCase(_x4) {
@@ -407,7 +426,7 @@ var interfaceColController = function (_baseController) {
}()
/**
- * 增加一个接口用例
+ * 更新一个接口用例
* @interface /col/up_case
* @method POST
* @category col
@@ -430,7 +449,9 @@ var interfaceColController = function (_baseController) {
key: 'upCase',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
- var params, caseData, auth, result;
+ var _this3 = this;
+
+ var params, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
@@ -462,7 +483,7 @@ var interfaceColController = function (_baseController) {
case 7:
_context5.next = 9;
- return this.caseModel.get(id);
+ return this.caseModel.get(params.id);
case 9:
caseData = _context5.sent;
@@ -488,25 +509,35 @@ var interfaceColController = function (_baseController) {
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 = 25;
+ _context5.next = 27;
break;
- case 22:
- _context5.prev = 22;
+ case 24:
+ _context5.prev = 24;
_context5.t0 = _context5['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context5.t0.message);
- case 25:
+ case 27:
case 'end':
return _context5.stop();
}
}
- }, _callee5, this, [[0, 22]]);
+ }, _callee5, this, [[0, 24]]);
}));
function upCase(_x5) {
@@ -531,16 +562,15 @@ var interfaceColController = function (_baseController) {
key: 'getCase',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
- var _id3, result;
-
+ var id, result;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.prev = 0;
- _id3 = ctx.query.caseid;
+ id = ctx.query.caseid;
_context6.next = 4;
- return this.caseModel.get(_id3);
+ return this.caseModel.get(id);
case 4:
result = _context6.sent;
@@ -586,17 +616,16 @@ var interfaceColController = function (_baseController) {
key: 'upCol',
value: function () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
- var params, _id4, colData, auth, result;
-
+ 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;
- _id4 = params.col_id;
+ id = params.col_id;
_context7.next = 5;
- return this.colModel.get(_id4);
+ return this.colModel.get(id);
case 5:
colData = _context7.sent;
@@ -623,23 +652,31 @@ var interfaceColController = function (_baseController) {
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 = 20;
+ _context7.next = 22;
break;
- case 17:
- _context7.prev = 17;
+ case 19:
+ _context7.prev = 19;
_context7.t0 = _context7['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context7.t0.message);
- case 20:
+ case 22:
case 'end':
return _context7.stop();
}
}
- }, _callee7, this, [[0, 17]]);
+ }, _callee7, this, [[0, 19]]);
}));
function upCol(_x7) {
@@ -664,7 +701,7 @@ var interfaceColController = function (_baseController) {
key: 'upCaseIndex',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
- var _this2 = this;
+ var _this4 = this;
var params;
return _regenerator2.default.wrap(function _callee8$(_context8) {
@@ -677,14 +714,24 @@ var interfaceColController = function (_baseController) {
if (!params || !Array.isArray(params)) {
ctx.body = _yapi2.default.commons.resReturn(null, 400, "请求参数必须是数组");
}
+ // let caseName = "";
params.forEach(function (item) {
if (item.id && item.index) {
- _this2.caseModel.upCaseIndex(item.id, item.index).then(function (res) {}, function (err) {
+ _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:
@@ -723,16 +770,15 @@ var interfaceColController = function (_baseController) {
key: 'delCol',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
- var _id5, colData, auth, result;
-
+ 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;
- _id5 = ctx.query.col_id;
+ id = ctx.query.col_id;
_context9.next = 4;
- return this.colModel.get(_id5);
+ return this.colModel.get(id);
case 4:
colData = _context9.sent;
@@ -761,28 +807,37 @@ var interfaceColController = function (_baseController) {
case 12:
_context9.next = 14;
- return this.colModel.del(_id5);
+ return this.colModel.del(id);
case 14:
result = _context9.sent;
_context9.next = 17;
- return this.caseModel.delByCol(_id5);
+ 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 20:
- _context9.prev = 20;
+ case 22:
+ _context9.prev = 22;
_context9.t0 = _context9['catch'](0);
_yapi2.default.commons.resReturn(null, 400, _context9.t0.message);
- case 23:
+ case 25:
case 'end':
return _context9.stop();
}
}
- }, _callee9, this, [[0, 20]]);
+ }, _callee9, this, [[0, 22]]);
}));
function delCol(_x9) {
@@ -801,7 +856,9 @@ var interfaceColController = function (_baseController) {
key: 'delCase',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
- var caseid, caseData, auth, result;
+ var _this5 = this;
+
+ var caseid, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
@@ -842,20 +899,32 @@ var interfaceColController = function (_baseController) {
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 18:
- _context10.prev = 18;
+ case 20:
+ _context10.prev = 20;
_context10.t0 = _context10['catch'](0);
_yapi2.default.commons.resReturn(null, 400, _context10.t0.message);
- case 21:
+ case 23:
case 'end':
return _context10.stop();
}
}
- }, _callee10, this, [[0, 18]]);
+ }, _callee10, this, [[0, 20]]);
}));
function delCase(_x10) {
diff --git a/server_dist/controllers/project.js b/server_dist/controllers/project.js
index bf0d2123..21e64eac 100644
--- a/server_dist/controllers/project.js
+++ b/server_dist/controllers/project.js
@@ -445,7 +445,9 @@ var projectController = function (_baseController) {
key: 'delMember',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
- var params, check, result, username, project, member;
+ var _this2 = this;
+
+ var params, check, result, username;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
@@ -503,40 +505,32 @@ var projectController = function (_baseController) {
case 18:
result = _context3.sent;
username = this.getUsername();
- _context3.next = 22;
- return this.Model.get(params.id);
- case 22:
- project = _context3.sent;
- _context3.next = 25;
- return _yapi2.default.getInst(_user2.default).findById(params.member_uid);
-
- case 25:
- member = _context3.sent;
-
- _yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u9879\u76EE "' + project.name + '" \u4E2D\u7684\u6210\u5458 "' + member.username + '"',
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.id
+ _yapi2.default.getInst(_user2.default).findById(params.member_uid).then(function (member) {
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u9879\u76EE\u4E2D\u7684\u6210\u5458 "' + member.username + '"',
+ type: 'project',
+ uid: _this2.getUid(),
+ username: username,
+ typeid: params.id
+ });
});
ctx.body = _yapi2.default.commons.resReturn(result);
- _context3.next = 33;
+ _context3.next = 27;
break;
- case 30:
- _context3.prev = 30;
+ case 24:
+ _context3.prev = 24;
_context3.t1 = _context3['catch'](15);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t1.message);
- case 33:
+ case 27:
case 'end':
return _context3.stop();
}
}
- }, _callee3, this, [[15, 30]]);
+ }, _callee3, this, [[15, 24]]);
}));
function delMember(_x3) {
@@ -947,7 +941,9 @@ var projectController = function (_baseController) {
key: 'changeMemberRole',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
- var params, projectInst, check, result, username, project, member;
+ var _this3 = this;
+
+ var params, projectInst, check, result, username;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
@@ -1009,40 +1005,32 @@ var projectController = function (_baseController) {
case 20:
result = _context9.sent;
username = this.getUsername();
- _context9.next = 24;
- return this.Model.get(params.id);
- case 24:
- project = _context9.sent;
- _context9.next = 27;
- return _yapi2.default.getInst(_user2.default).findById(params.member_uid);
-
- case 27:
- member = _context9.sent;
-
- _yapi2.default.commons.saveLog({
- content: '\u7528\u6237 "' + username + '" \u4FEE\u6539\u4E86\u9879\u76EE "' + project.name + '" \u4E2D\u6210\u5458 "' + member.username + '" \u7684\u89D2\u8272\u4E3A "' + params.role + '"',
- type: 'project',
- uid: this.getUid(),
- username: username,
- typeid: params.id
+ _yapi2.default.getInst(_user2.default).findById(params.member_uid).then(function (member) {
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u4FEE\u6539\u4E86\u9879\u76EE\u4E2D\u7684\u6210\u5458 "' + member.username + '" \u7684\u89D2\u8272\u4E3A "' + params.role + '"',
+ type: 'project',
+ uid: _this3.getUid(),
+ username: username,
+ typeid: params.id
+ });
});
ctx.body = _yapi2.default.commons.resReturn(result);
- _context9.next = 35;
+ _context9.next = 29;
break;
- case 32:
- _context9.prev = 32;
+ case 26:
+ _context9.prev = 26;
_context9.t1 = _context9['catch'](17);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t1.message);
- case 35:
+ case 29:
case 'end':
return _context9.stop();
}
}
- }, _callee9, this, [[17, 32]]);
+ }, _callee9, this, [[17, 26]]);
}));
function changeMemberRole(_x10) {
@@ -1069,6 +1057,8 @@ var projectController = function (_baseController) {
key: 'upSet',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
+ var _this4 = this;
+
var id, data, result;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
@@ -1107,7 +1097,16 @@ var projectController = function (_baseController) {
case 16:
try {
- this.followModel.updateById(this.getUid(), id, data).then();
+ this.followModel.updateById(this.getUid(), id, data).then(function () {
+ var username = _this4.getUsername();
+ _yapi2.default.commons.saveLog({
+ content: '\u7528\u6237 "' + username + '" \u4FEE\u6539\u4E86\u9879\u76EE\u56FE\u6807\u3001\u989C\u8272',
+ type: 'project',
+ uid: _this4.getUid(),
+ username: username,
+ typeid: id
+ });
+ });
} catch (e) {
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
}
@@ -1279,94 +1278,6 @@ var projectController = function (_baseController) {
return up;
}()
- /**
- * 修改项目头像
- * @interface /project/upset
- * @method POST
- * @category project
- * @foldnumber 10
- * @param {Number} id
- * @param {String} color
- * @param {String} icon
- * @return {Object}
- */
-
- }, {
- key: 'upSet',
- value: function () {
- var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
- var id, data, auth, result;
- return _regenerator2.default.wrap(function _callee12$(_context12) {
- while (1) {
- switch (_context12.prev = _context12.next) {
- case 0:
- id = ctx.request.body.id;
- data = {};
-
- data.color = ctx.request.body.color;
- data.icon = ctx.request.body.icon;
-
- if (id) {
- _context12.next = 6;
- break;
- }
-
- return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
-
- case 6:
- _context12.next = 8;
- return this.checkAuth(id, 'project', 'danger');
-
- case 8:
- auth = _context12.sent;
-
- if (auth) {
- _context12.next = 11;
- break;
- }
-
- return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
-
- case 11:
- _context12.prev = 11;
- _context12.next = 14;
- return this.Model.up(id, data);
-
- case 14:
- result = _context12.sent;
-
- ctx.body = _yapi2.default.commons.resReturn(result);
- _context12.next = 21;
- break;
-
- case 18:
- _context12.prev = 18;
- _context12.t0 = _context12['catch'](11);
-
- ctx.body = _yapi2.default.commons.resReturn(null, 402, _context12.t0.message);
-
- case 21:
- try {
- this.followModel.updateById(this.getUid(), id, data).then();
- } catch (e) {
- _yapi2.default.commons.log(e, 'error'); // eslint-disable-line
- }
-
- case 22:
- case 'end':
- return _context12.stop();
- }
- }
- }, _callee12, this, [[11, 18]]);
- }));
-
- function upSet(_x13) {
- return _ref12.apply(this, arguments);
- }
-
- return upSet;
- }()
-
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search
@@ -1381,40 +1292,40 @@ var projectController = function (_baseController) {
}, {
key: 'search',
value: function () {
- var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
+ var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
var q, projectList, groupList, projectRules, groupRules, queryList;
- return _regenerator2.default.wrap(function _callee13$(_context13) {
+ return _regenerator2.default.wrap(function _callee12$(_context12) {
while (1) {
- switch (_context13.prev = _context13.next) {
+ switch (_context12.prev = _context12.next) {
case 0:
q = ctx.request.query.q;
if (q) {
- _context13.next = 3;
+ _context12.next = 3;
break;
}
- return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'No keyword.'));
+ return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'No keyword.'));
case 3:
if (_yapi2.default.commons.validateSearchKeyword(q)) {
- _context13.next = 5;
+ _context12.next = 5;
break;
}
- return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'Bad query.'));
+ return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'Bad query.'));
case 5:
- _context13.next = 7;
+ _context12.next = 7;
return this.Model.search(q);
case 7:
- projectList = _context13.sent;
- _context13.next = 10;
+ projectList = _context12.sent;
+ _context12.next = 10;
return this.groupModel.search(q);
case 10:
- groupList = _context13.sent;
+ groupList = _context12.sent;
projectRules = ['_id', 'name', 'basepath', 'uid', 'env', 'members', { key: 'group_id', alias: 'groupId' }, { key: 'up_time', alias: 'upTime' }, { key: 'add_time', alias: 'addTime' }];
groupRules = ['_id', 'uid', { key: 'group_name', alias: 'groupName' }, { key: 'group_desc', alias: 'groupDesc' }, { key: 'add_time', alias: 'addTime' }, { key: 'up_time', alias: 'upTime' }];
@@ -1426,18 +1337,18 @@ var projectController = function (_baseController) {
project: projectList,
group: groupList
};
- return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(queryList, 0, 'ok'));
+ return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(queryList, 0, 'ok'));
case 17:
case 'end':
- return _context13.stop();
+ return _context12.stop();
}
}
- }, _callee13, this);
+ }, _callee12, this);
}));
- function search(_x14) {
- return _ref13.apply(this, arguments);
+ function search(_x13) {
+ return _ref12.apply(this, arguments);
}
return search;
@@ -1456,36 +1367,36 @@ var projectController = function (_baseController) {
}, {
key: 'download',
value: function () {
- var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(ctx) {
+ var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
var project_id, interfaceInst, count, arr, fileName, res;
- return _regenerator2.default.wrap(function _callee14$(_context14) {
+ return _regenerator2.default.wrap(function _callee13$(_context13) {
while (1) {
- switch (_context14.prev = _context14.next) {
+ switch (_context13.prev = _context13.next) {
case 0:
project_id = ctx.request.query.project_id;
interfaceInst = _yapi2.default.getInst(_interface2.default);
// 根据 project_id 获取接口数据
- _context14.next = 4;
+ _context13.next = 4;
return interfaceInst.list(project_id);
case 4:
- count = _context14.sent;
+ count = _context13.sent;
if (project_id) {
- _context14.next = 9;
+ _context13.next = 9;
break;
}
- return _context14.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
+ return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
case 9:
if (count) {
- _context14.next = 11;
+ _context13.next = 11;
break;
}
- return _context14.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目id不存在'));
+ return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目id不存在'));
case 11:
arr = (0, _stringify2.default)(count.map(function (item) {
@@ -1499,23 +1410,23 @@ var projectController = function (_baseController) {
fileName = 'mock.js';
ctx.attachment(fileName);
- _context14.next = 16;
+ _context13.next = 16;
return send(ctx, fileName, { root: __dirname + '/public' });
case 16:
res = ('\n var Mock = require(\'mockjs\');\n var xhook = require(\'xhook\');\n var data = ' + arr + ';\n function run() {\n xhook.before(function(request, callback) {\n setTimeout(function() {\n var res;\n data.forEach((item) => {\n // \u8BF7\u6C42\u7684\u63A5\u53E3\u5728 data \u4E2D\u5B58\u5728\n if(request.url === item.path) {\n res = {\n status: 200,\n text: Mock.mock(item.mock)\n }\n }\n });\n if (res) {\n callback(res);\n }else {\n callback({ status: 405, text: \'\u63A5\u53E3\u4E0D\u5B58\u5728\' });\n }\n }, 500);\n });\n }\n module.exports = run;').trim();
- return _context14.abrupt('return', ctx.body = res);
+ return _context13.abrupt('return', ctx.body = res);
case 18:
case 'end':
- return _context14.stop();
+ return _context13.stop();
}
}
- }, _callee14, this);
+ }, _callee13, this);
}));
- function download(_x15) {
- return _ref14.apply(this, arguments);
+ function download(_x14) {
+ return _ref13.apply(this, arguments);
}
return download;
diff --git a/static/attachment/cross-request.crx b/static/attachment/cross-request.crx
new file mode 100644
index 00000000..8463afeb
Binary files /dev/null and b/static/attachment/cross-request.crx differ