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

This commit is contained in:
suxiaoxin 2017-08-24 20:58:35 +08:00
commit 90645685e1
28 changed files with 577 additions and 527 deletions

View File

@ -89,45 +89,34 @@
}
// .card-panel-s {
// .m-card {
// .ant-card-body {
// padding-top: .6rem;
// }
// .ui-logo {
// width: .6rem;
// height: .6rem;
// line-height: .6rem;
// transform: translate(-50%, -20%);
// font-size: .24rem;
// background-color: #2395f1;
// }
// }
// }
@media (max-width: 768px) {
.m-card {
.ant-card-body {
padding-top: .24rem + .16rem + .6rem;
}
.ui-logo {
width: .6rem;
height: .6rem;
line-height: .6rem;
font-size: .3rem;
transform: translate(-50%, 0.08rem);
}
.ant-card-body {
padding-top: .08rem + .08rem + .6rem;
padding-bottom: .08rem;
}
}
}
@media (min-width: 768px) and (max-width: 992px) {
.m-card {
.ant-card-body {
padding-top: .24rem + .16rem + .8rem;
}
.ui-logo {
width: .8rem;
height: .8rem;
line-height: .8rem;
font-size: .4rem;
transform: translate(-50%, 0.16rem);
}
.ant-card-body {
padding-top: .16rem + .16rem + .8rem;
padding-bottom: .16rem;
}
}
}

View File

@ -147,7 +147,7 @@ class ProjectList extends Component {
>
{getFieldDecorator('desc', {
rules: [{
required: false, message: '请输入描述!'
required: false, message: '描述不超过50字!', max: 50
}]
})(
<TextArea rows={4} />

View File

@ -1,7 +1,13 @@
@import '../../styles/common.scss';
@import '../../styles/mixin.scss';
.follow-box{
padding: 24px;
background-color: #fff;
}
.card-panel {
border-radius: 4px;
box-shadow: $box-shadow-panel;
}

View File

@ -1,9 +1,17 @@
@import '../../../styles/mixin.scss';
.m-panel{
background-color: #fff;
padding: 24px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
border-radius: 4px;
min-height: 4.68rem;
margin-top: 0;
box-shadow: $box-shadow-panel;
}
.m-tab {
overflow: inherit !important;
}
.btn-container {

View File

@ -8,6 +8,7 @@
padding: 24px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
border-radius: 4px;
min-height: 4.68rem;
margin-top: 0;
}

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react'
import { Timeline, Spin, Avatar,Icon } from 'antd'
import { Timeline, Spin, Avatar } from 'antd'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { formatTime } from '../../../../common.js';
@ -122,10 +122,10 @@ class TimeTree extends Component {
if (data && data.length) {
data = data.map(function (item, i) {
return (<Timeline.Item dot={<Avatar src={`/api/user/avatar?uid=${item.uid}`} />} key={i}>
return (<Timeline.Item dot={<Link to={`/user/profile/${item.uid}`}><Avatar src={`/api/user/avatar?uid=${item.uid}`} /></Link>} key={i}>
<div className="logMesHeade">
<span className="logoTimeago">{timeago(item.add_time)}</span>
<span className="logusername"><Link to={`/user/profile/${item.uid}`}><Icon type="user" />{item.username}</Link></span>
{/*<span className="logusername"><Link to={`/user/profile/${item.uid}`}><Icon type="user" />{item.username}</Link></span>*/}
<span className="logtype">{logType[item.type]}动态</span>
<span className="logtime">{formatTime(item.add_time)}</span>
</div>

View File

@ -178,6 +178,25 @@ class View extends Component {
})
})
}
const req_dataSource = [];
if(this.props.curData.req_params&&this.props.curData.req_params.length){
this.props.curData.req_params.map((item,i)=>{
req_dataSource.push({
key: i,
name: item.name,
value: item.desc
})
})
}
const req_params_columns = [{
title: '参数名称',
dataIndex: 'name',
key: 'name'
},{
title: '备注',
dataIndex: 'value',
key: 'value'
}];
const columns = [{
title: '参数名称',
@ -260,6 +279,10 @@ class View extends Component {
<span className="colKey">接口描述</span>
<span className="colValue">{this.props.curData.desc}</span>
</div>:""}
{req_dataSource.length?<div className="colHeader">
<span className="colKey">路径参数</span>
<Table bordered size="small" pagination = {false} columns= {req_params_columns} dataSource = {req_dataSource} />
</div>:""}
{dataSource.length?<div className="colHeader">
<span className="colKey">请求Headers</span>
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />

View File

@ -16,12 +16,12 @@ import '../Setting.scss';
// layout
const formItemLayout = {
labelCol: {
lg: { span: 3 },
lg: { offset: 1, span: 3 },
xs: { span: 24 },
sm: { span: 6 }
},
wrapperCol: {
lg: { span: 21 },
lg: { span: 19 },
xs: { span: 24 },
sm: { span: 14 }
},
@ -323,12 +323,12 @@ class ProjectMessage extends Component {
return (
<div className="m-panel">
<Row className="project-setting">
<Col sm={6} lg={3} className="setting-logo">
<Col xs={6} lg={{offset: 1, span: 3}} className="setting-logo">
<Popover placement="bottom" title={colorSelector} content={iconSelector} trigger="click" overlayClassName="change-project-container">
<Icon type={projectMsg.icon || 'star-o'} className="ui-logo" style={{ backgroundColor: constants.PROJECT_COLOR[projectMsg.color] || constants.PROJECT_COLOR.blue }} />
</Popover>
</Col>
<Col sm={18} lg={21} className="setting-intro">
<Col xs={18} sm={15} lg={19} className="setting-intro">
<h2 className="ui-title">{projectMsg.group_name + ' / ' + projectMsg.name}</h2>
<p className="ui-desc">{projectMsg.desc}</p>
</Col>
@ -407,7 +407,7 @@ class ProjectMessage extends Component {
{getFieldDecorator('desc', {
initialValue: initFormValues.desc,
rules: [{
required: false, message: '请输入描述!'
required: false, message: '描述不超过50字!', max: 50
}]
})(
<TextArea rows={4} />

View File

@ -35,14 +35,14 @@
border-radius: 2px;
.ant-card-head {
background-color: #eee;
padding: 0 .08rem !important;
padding: 0 .08rem !important;
}
.ant-card-head-title {
font-size: .12rem;
float: inherit;
}
.ant-card-body {
padding: 0;
padding: 0 !important;
}
.card-item {
padding: .1rem .15rem;

View File

@ -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;

View File

@ -13,6 +13,9 @@ html, body {
height: 100%;
background: #ececec;
}
::selection {
background-color: #2395f1;
}
div, article, p, table, tr, td, th, ul, ol, li, h1, h2, h3, form, dl, dt, dd {
margin: 0;

View File

@ -4,7 +4,8 @@ $color-blue : #108ee9;
$color-blue-deeper: #34495E;
$color-grey-deep : #929aac;
$color-black-light : #404040;
$color-bg-dark: #202d3a; // 背景色 - 深蓝
$color-bg-dark: #202d3a; // 背景色 - header 用的深蓝色
$box-shadow-panel: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
@mixin row-width-limit {
max-width: 12.2rem;

View File

@ -98,9 +98,9 @@
@background-color-active: #eee;
// Disabled states
@disabled-color : fade(#0d1b3e, 25%);
@disabled-color : fade(#0d1b3e, 45%);
@disabled-bg : @background-color-base;
@disabled-color-dark : fade(#fff, 35%);
@disabled-color-dark : fade(#fff, 55%);
// Shadow
@shadow-color : rgba(0, 0, 0, .2);

View File

@ -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)
}

View File

@ -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,7 +228,7 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '用例名称不能为空');
}
let caseData = await this.caseModel.get(id);
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);

View File

@ -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

View File

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

View File

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

View File

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

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,7 +762,7 @@ 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;
@ -802,7 +802,7 @@ var groupController = function (_baseController) {
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) {
@ -881,7 +881,7 @@ var groupController = function (_baseController) {
}, {
key: 'up',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
var groupInst, _id2, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) {

View File

@ -105,8 +105,10 @@ var interfaceController = function (_baseController) {
(0, _createClass3.default)(interfaceController, [{
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 _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
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) {
@ -273,7 +273,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'get',
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, result;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
@ -335,7 +335,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'list',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
var project_id, result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
@ -385,7 +385,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'listByCat',
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 catid, result;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
@ -435,7 +435,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'listByMenu',
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 project_id, result, newResult, i, item, list, j;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
@ -540,8 +540,10 @@ 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 _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
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) {
@ -753,8 +747,10 @@ 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 _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
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) {
@ -847,8 +840,8 @@ var interfaceController = function (_baseController) {
}, {
key: 'solveConflict',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var _this2 = this;
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
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;
@ -930,7 +923,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'addCat',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
var params, auth, result, username;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
@ -1025,7 +1018,7 @@ var interfaceController = function (_baseController) {
}, {
key: 'upCat',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
var params, result, username, cate, auth;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
@ -1097,8 +1090,8 @@ 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 _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
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) {

View File

@ -74,17 +74,16 @@ var interfaceColController = function (_baseController) {
(0, _createClass3.default)(interfaceColController, [{
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var _id, result, i;
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
var id, result, i;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
_id = ctx.query.project_id;
id = ctx.query.project_id;
_context.next = 4;
return this.colModel.list(_id);
return this.colModel.list(id);
case 4:
result = _context.sent;
@ -150,8 +149,8 @@ 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 _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
var params, auth, result, username;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
@ -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) {
@ -248,18 +255,17 @@ 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 _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
var id, inst, result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.prev = 0;
_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;
@ -313,8 +319,10 @@ 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 _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
var _this2 = this;
var params, auth, result, username;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
@ -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
@ -429,8 +448,10 @@ 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 _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
var _this3 = this;
var params, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
@ -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) {
@ -530,17 +561,16 @@ var interfaceColController = function (_baseController) {
}, {
key: 'getCase',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var _id3, result;
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
var id, result;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.prev = 0;
_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;
@ -585,18 +615,17 @@ 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 _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
var params, id, colData, auth, result, username;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_context7.prev = 0;
params = ctx.request.body;
_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) {
@ -663,8 +700,8 @@ var interfaceColController = function (_baseController) {
}, {
key: 'upCaseIndex',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var _this2 = this;
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
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:
@ -722,17 +769,16 @@ 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 _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
var id, colData, auth, result, username;
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.prev = 0;
_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) {
@ -800,8 +855,10 @@ 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 _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
var _this5 = this;
var caseid, caseData, auth, result, username;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
@ -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) {

View File

@ -75,7 +75,7 @@ var logController = function (_baseController) {
(0, _createClass3.default)(logController, [{
key: 'list',
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 typeid, page, limit, type, result, count;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {

View File

@ -148,7 +148,7 @@ var projectController = function (_baseController) {
}, {
key: 'add',
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, checkRepeat, data, result, colInst, catInst, username;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
@ -321,7 +321,7 @@ var projectController = function (_baseController) {
}, {
key: 'addMember',
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, check, userdata, result, username;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
@ -444,8 +444,10 @@ 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 _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
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) {
@ -548,7 +542,7 @@ var projectController = function (_baseController) {
}, {
key: 'getUserdata',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(uid, role) {
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(uid, role) {
var userInst, userData;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
@ -606,7 +600,7 @@ var projectController = function (_baseController) {
}, {
key: 'getMemberList',
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, project;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
@ -668,7 +662,7 @@ var projectController = function (_baseController) {
}, {
key: 'get',
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, result, catInst, cat;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
@ -753,7 +747,7 @@ var projectController = function (_baseController) {
}, {
key: 'list',
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 group_id, auth, result, follow, uids, _users, users;
return _regenerator2.default.wrap(function _callee7$(_context7) {
@ -853,7 +847,7 @@ var projectController = function (_baseController) {
}, {
key: 'del',
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 id, interfaceInst, interfaceColInst, interfaceCaseInst, result;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
@ -946,8 +940,10 @@ 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 _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
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) {
@ -1068,7 +1056,9 @@ var projectController = function (_baseController) {
}, {
key: 'upSet',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _ref10 = (0, _asyncToGenerator3.default)(_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
}
@ -1147,7 +1146,7 @@ var projectController = function (_baseController) {
}, {
key: 'up',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
var id, params, projectData, checkRepeat, data, result, username;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
@ -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)(_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)(_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;

View File

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

View File

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

View File

@ -355,7 +355,7 @@ function createAction(controller, action, path, method) {
var _this = this;
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, 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 inst;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {

View File

@ -26,7 +26,7 @@ function websocket(app) {
return next(ctx);
});
router.get('/api/interface/solve_conflict', 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 inst;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {