mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-12 15:10:23 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
9d5dd1a43d
@ -11,12 +11,19 @@
|
||||
.m-card, .card-btns {
|
||||
transform: translateY(-4px);
|
||||
}
|
||||
.m-card .ant-card-body {
|
||||
box-shadow: 0 4px 8px rgba(50, 50, 93, 0.11), 0 4px 6px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
}
|
||||
&:active {
|
||||
.m-card, .card-btns {
|
||||
transform: translateY(4px);
|
||||
}
|
||||
}
|
||||
// 覆盖 card 组件 hover 状态的默认阴影样式
|
||||
.ant-card:not(.ant-card-no-hovering):hover {
|
||||
box-shadow: none;
|
||||
}
|
||||
// 卡片右上角按钮
|
||||
.card-btns {
|
||||
position: absolute;
|
||||
@ -47,6 +54,7 @@
|
||||
border-radius: 4px;
|
||||
padding-top: .24rem + .16rem + 1rem;
|
||||
box-shadow: 0 4px 6px rgba(50,50,93,.11), 0 1px 3px rgba(0,0,0,.08);
|
||||
transition: all .2s;
|
||||
}
|
||||
.ui-logo {
|
||||
width: 1rem;
|
||||
|
@ -244,7 +244,7 @@ export default class GroupList extends Component {
|
||||
</div>
|
||||
<div className="group-operate">
|
||||
<div className="search">
|
||||
<Search onChange={this.searchGroup} onSearch={(v) => this.searchGroup(null, v)}/>
|
||||
<Search placeholder="Filter by name" onChange={this.searchGroup} onSearch={(v) => this.searchGroup(null, v)}/>
|
||||
</div>
|
||||
{
|
||||
this.props.curUserRole === "admin"?(<Button type="primary" onClick={this.showModal}>添加分组</Button>):''
|
||||
|
@ -8,11 +8,8 @@ import { logoSVG } from '../../common.js';
|
||||
|
||||
// import Intro from '../../components/Intro/Intro'
|
||||
import { changeMenuItem } from '../../reducer/modules/menu'
|
||||
import { OverPack } from 'rc-scroll-anim'
|
||||
import TweenOne from 'rc-tween-one'
|
||||
import QueueAnim from 'rc-queue-anim';
|
||||
|
||||
const oneAnim = { y: '+=30', opacity: 0, type: 'from', ease: 'easeOutQuad' };
|
||||
// const oneAnim = { y: '+=30', opacity: 0, type: 'from', ease: 'easeOutQuad' };
|
||||
|
||||
const HomeGuest = () => (
|
||||
<div className="g-body">
|
||||
@ -56,43 +53,25 @@ const HomeGuest = () => (
|
||||
</div>
|
||||
<div className="feat-part section-feature">
|
||||
<div className="container home-section">
|
||||
<OverPack
|
||||
playScale={[0.2,0.1]}
|
||||
>
|
||||
<TweenOne
|
||||
key="feat-motion-one"
|
||||
animation={oneAnim}
|
||||
>
|
||||
<h3 className="title">为API开发者设计的管理平台</h3>
|
||||
<span className="desc">YApi让接口开发更简单高效,让接口的管理更具可读性、可维护性,让团队协作更合理。</span>
|
||||
</TweenOne>
|
||||
<Row key="feat-motion-row">
|
||||
<QueueAnim
|
||||
delay = {200}
|
||||
interval ={200}
|
||||
leaveReverse={true}
|
||||
ease = 'easeOutQuad'
|
||||
animConfig ={{ opacity:[1,0],y: '+=30' }}
|
||||
key="feat-motion-queue"
|
||||
>
|
||||
<Col span={8} className="section-item" key="feat-wrapper-1">
|
||||
<Icon type="api" className="img" />
|
||||
<h4 className="title">项目接口管理</h4>
|
||||
<span className="desc">提供基本的项目分组,项目管理,接口管理功能</span>
|
||||
</Col>
|
||||
<Col span={8} className="section-item" key="feat-wrapper-2">
|
||||
<Icon type="code-o" className="img" />
|
||||
<h4 className="title">可部署</h4>
|
||||
<span className="desc">用户只需配置接口的基本路径,通过将线上域名指到我们的YApi平台服务器,就可使用mockServer服务</span>
|
||||
</Col>
|
||||
<Col span={8} className="section-item" key="feat-wrapper-3">
|
||||
<Icon type="team" className="img" />
|
||||
<h4 className="title">用户管理</h4>
|
||||
<span className="desc">提供基本的用户注册登录管理等功能,集成了去哪儿QSSO登录</span>
|
||||
</Col>
|
||||
</QueueAnim>
|
||||
</Row>
|
||||
</OverPack>
|
||||
<h3 className="title">为API开发者设计的管理平台</h3>
|
||||
<span className="desc">YApi让接口开发更简单高效,让接口的管理更具可读性、可维护性,让团队协作更合理。</span>
|
||||
<Row key="feat-motion-row">
|
||||
<Col span={8} className="section-item" key="feat-wrapper-1">
|
||||
<Icon type="api" className="img" />
|
||||
<h4 className="title">项目接口管理</h4>
|
||||
<span className="desc">提供基本的项目分组,项目管理,接口管理功能</span>
|
||||
</Col>
|
||||
<Col span={8} className="section-item" key="feat-wrapper-2">
|
||||
<Icon type="code-o" className="img" />
|
||||
<h4 className="title">可部署</h4>
|
||||
<span className="desc">用户只需配置接口的基本路径,通过将线上域名指到我们的YApi平台服务器,就可使用mockServer服务</span>
|
||||
</Col>
|
||||
<Col span={8} className="section-item" key="feat-wrapper-3">
|
||||
<Icon type="team" className="img" />
|
||||
<h4 className="title">用户管理</h4>
|
||||
<span className="desc">提供基本的用户注册登录管理等功能,集成了去哪儿QSSO登录</span>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
<div className="feat-part m-mock m-skew home-section">
|
||||
@ -110,15 +89,15 @@ const HomeGuest = () => (
|
||||
<p className="mock-desc">通过学习一些简单的 Mock 模板规则即可轻松编写接口,这将大大提高定义接口的效率,并且无需为编写 Mock 数据烦恼: 所有的数据都可以实时随机生成。</p>
|
||||
<div className="code">
|
||||
<ol start="1">
|
||||
<li className="alt"><span className="orderNum orderNum-first">1</span><span><span>{  </span></span></li>
|
||||
<li className=""><span className="orderNum">2</span><span>    <span className="string">"errcode|200-500"</span><span>: <span className="number">200</span>,  </span></span></li>
|
||||
<li className="alt"><span className="orderNum">3</span><span>    <span className="string">"errmsg|4-8"</span><span>: </span><span className="string">"@string"</span><span>,  </span></span></li>
|
||||
<li className=""><span className="orderNum">4</span><span>    <span className="string">"data"</span><span>: {  </span></span></li>
|
||||
<li className="alt"><span className="orderNum">5</span><span>        <span className="string">"boolean|1"</span><span>: </span><span className="keyword">true</span><span>,  </span></span></li>
|
||||
<li className=""><span className="orderNum">6</span><span>        <span className="string">"array|4"</span><span>: <span className="number">1</span>,  </span></span></li>
|
||||
<li className="alt"><span className="orderNum">7</span><span>        <span className="string">"combine"</span><span>: </span><span className="string">"@boolean & @array"</span><span>  </span></span></li>
|
||||
<li className=""><span className="orderNum">8</span><span>    }  </span></li>
|
||||
<li className="alt"><span className="orderNum orderNum-last">9</span><span>}  </span></li>
|
||||
<li className="item"><span className="orderNum orderNum-first">1</span><span><span>{  </span></span></li>
|
||||
<li className="item"><span className="orderNum">2</span><span>    <span className="string">"errcode|200-500"</span><span>: <span className="number">200</span>,  </span></span></li>
|
||||
<li className="item"><span className="orderNum">3</span><span>    <span className="string">"errmsg|4-8"</span><span>: </span><span className="string">"@string"</span><span>,  </span></span></li>
|
||||
<li className="item"><span className="orderNum">4</span><span>    <span className="string">"data"</span><span>: {  </span></span></li>
|
||||
<li className="item"><span className="orderNum">5</span><span>        <span className="string">"boolean|1"</span><span>: </span><span className="keyword">true</span><span>,  </span></span></li>
|
||||
<li className="item"><span className="orderNum">6</span><span>        <span className="string">"array|4"</span><span>: <span className="number">1</span>,  </span></span></li>
|
||||
<li className="item"><span className="orderNum">7</span><span>        <span className="string">"combine"</span><span>: </span><span className="string">"@boolean & @array"</span><span>  </span></span></li>
|
||||
<li className="item"><span className="orderNum">8</span><span>    }  </span></li>
|
||||
<li className="item"><span className="orderNum orderNum-last">9</span><span>}  </span></li>
|
||||
</ol>
|
||||
</div>
|
||||
</Card>
|
||||
@ -146,7 +125,7 @@ const HomeGuest = () => (
|
||||
</div>
|
||||
<div className="home-section section-manage">
|
||||
<div className="container">
|
||||
<Row className="row-card">
|
||||
<Row className="row-card" style={{marginBottom: '.48rem'}}>
|
||||
<Col span={7} className="section-card">
|
||||
<Card>
|
||||
<div className="section-block block-first">
|
||||
|
@ -351,6 +351,9 @@ $color-bg-lightblue: #c6e2ff;
|
||||
box-shadow: 0 15px 35px rgba(50,50,93,.1), 0 5px 15px rgba(0,0,0,.07);
|
||||
border: none;
|
||||
}
|
||||
.ant-card:not(.ant-card-no-hovering):hover {
|
||||
box-shadow: 0 15px 35px rgba(50,50,93,.1), 0 5px 15px rgba(0,0,0,.07);
|
||||
}
|
||||
.ant-card-head {
|
||||
background-color: $color-blue-grey-lighter;
|
||||
border-top-left-radius: .04rem;
|
||||
@ -399,6 +402,11 @@ $color-bg-lightblue: #c6e2ff;
|
||||
.keyword {
|
||||
color: #2359f1;
|
||||
}
|
||||
.item {
|
||||
overflow: hidden;
|
||||
text-overflow:ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.mock-after {
|
||||
.ant-card-head {
|
||||
|
@ -89,13 +89,13 @@ class InterfaceMenu extends Component {
|
||||
|
||||
|
||||
onSelect = (selectedKeys) => {
|
||||
const {history, match} = this.props;
|
||||
const { history, match } = this.props;
|
||||
let curkey = selectedKeys[0];
|
||||
if(!curkey || !selectedKeys) return false;
|
||||
if (!curkey || !selectedKeys) return false;
|
||||
let basepath = "/project/" + match.params.id + "/interface/api";
|
||||
if(curkey === 'root'){
|
||||
if (curkey === 'root') {
|
||||
history.push(basepath)
|
||||
}else{
|
||||
} else {
|
||||
history.push(basepath + '/' + curkey)
|
||||
}
|
||||
}
|
||||
@ -162,7 +162,7 @@ class InterfaceMenu extends Component {
|
||||
that.props.history.push('/project/' + that.props.match.params.id + '/interface/api')
|
||||
ref.destroy()
|
||||
},
|
||||
async onCancel() {
|
||||
async onCancel() {
|
||||
ref.destroy()
|
||||
}
|
||||
});
|
||||
@ -201,12 +201,37 @@ class InterfaceMenu extends Component {
|
||||
|
||||
render() {
|
||||
const matchParams = this.props.match.params;
|
||||
let menuList = this.props.list;
|
||||
|
||||
|
||||
const defaultExpandedKeys = () => {
|
||||
const { router, inter, list } = this.props, rNull = { expands: [], selects: [] };
|
||||
if (list.length === 0) return rNull;
|
||||
if (router) {
|
||||
if (!isNaN(router.params.actionId)) {
|
||||
let _actionId = parseInt(router.params.actionId, 10)
|
||||
if (!inter._id || inter._id !== _actionId) return rNull;
|
||||
return {
|
||||
expands: ['cat_' + inter.catid],
|
||||
selects: [inter._id + ""]
|
||||
}
|
||||
} else {
|
||||
let catid = router.params.actionId.substr(4);
|
||||
return {
|
||||
expands: ['cat_' + catid],
|
||||
selects: ['cat_' + catid]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
expands: ['cat_' + list[0]._id],
|
||||
selects: ['root']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const item_interface_create = (item) => {
|
||||
let color, filter = this.state.filter;
|
||||
if (filter && item.title.indexOf(filter) === -1 && item.path.indexOf(filter) === -1) {
|
||||
return null;
|
||||
}
|
||||
let color;
|
||||
switch (item.method) {
|
||||
case 'GET': color = "green"; break;
|
||||
case 'POST': color = "blue"; break;
|
||||
@ -249,38 +274,26 @@ class InterfaceMenu extends Component {
|
||||
</Menu>
|
||||
};
|
||||
|
||||
const defaultExpandedKeys = ()=>{
|
||||
const {router, inter, list} = this.props, rNull = {expands: [], selects: []};
|
||||
if(list.length === 0) return rNull;
|
||||
if(router){
|
||||
if(!isNaN(router.params.actionId)){
|
||||
let _actionId = parseInt(router.params.actionId, 10)
|
||||
if(!inter._id || inter._id !== _actionId)return rNull;
|
||||
return {
|
||||
expands: ['cat_' + inter.catid],
|
||||
selects: [inter._id+""]
|
||||
}
|
||||
}else{
|
||||
let catid = router.params.actionId.substr(4);
|
||||
return {
|
||||
expands: ['cat_' + catid],
|
||||
selects: ['cat_' + catid]
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return {
|
||||
expands: ['cat_' + list[0]._id],
|
||||
selects: ['root']
|
||||
|
||||
|
||||
let currentKes = defaultExpandedKeys();
|
||||
if (this.state.filter) {
|
||||
let arr = [];
|
||||
menuList = this.props.list.filter(item => {
|
||||
if (item.name.indexOf(this.state.filter) === -1) {
|
||||
return false;
|
||||
}
|
||||
arr.push('cat_' + item._id)
|
||||
return true;
|
||||
})
|
||||
if(arr.length > 0){
|
||||
currentKes.expands = arr;
|
||||
}
|
||||
}
|
||||
|
||||
const currentKes = defaultExpandedKeys();
|
||||
|
||||
return <div>
|
||||
<div className="interface-filter">
|
||||
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
|
||||
<Tag color="#108ee9" style={{ marginLeft: "15px" }} ><Icon type="plus" onClick={() => this.changeModal('add_cat_modal_visible', true)} /></Tag>
|
||||
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
|
||||
<Modal
|
||||
title="添加接口"
|
||||
visible={this.state.visible}
|
||||
@ -305,15 +318,15 @@ class InterfaceMenu extends Component {
|
||||
<AddInterfaceCatForm catdata={this.state.curCatdata} onCancel={() => this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} />
|
||||
</Modal>
|
||||
</div>
|
||||
{this.props.list.length > 0 ?
|
||||
{menuList.length > 0 ?
|
||||
<Tree
|
||||
className="interface-list"
|
||||
defaultExpandedKeys={currentKes.expands}
|
||||
defaultSelectedKeys={currentKes.selects}
|
||||
expandedKeys={currentKes.expands}
|
||||
selectedKeys={currentKes.selects}
|
||||
onSelect={this.onSelect}
|
||||
>
|
||||
<TreeNode title={<Link style={{ fontSize: '14px' }} to={"/project/" + matchParams.id + "/interface/api"}><Icon type="folder-open" style={{ marginRight: 5 }} />全部接口</Link>} key="root" />
|
||||
{this.props.list.map((item) => {
|
||||
{menuList.map((item) => {
|
||||
return <TreeNode title={<div>
|
||||
<Link className="interface-item" to={"/project/" + matchParams.id + "/interface/api/cat_" + item._id} ><Icon type="folder-open" style={{ marginRight: 5 }} />{item.name}</Link>
|
||||
<Dropdown overlay={menu(item)}>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col, Input, Button, Select, message, Upload} from 'antd'
|
||||
import { Row, Col, Input, Button, Select, message, Upload, Tooltip} from 'antd'
|
||||
import axios from 'axios';
|
||||
import {formatTime} from '../../common.js'
|
||||
import PropTypes from 'prop-types'
|
||||
@ -365,17 +365,21 @@ class AvatarUpload extends Component {
|
||||
// console.log(this.props.uid);
|
||||
|
||||
return <div className="avatar-box">
|
||||
<Upload
|
||||
className="avatar-uploader"
|
||||
name="basecode"
|
||||
showUploadList={false}
|
||||
action="/api/user/upload_avatar"
|
||||
beforeUpload={beforeUpload}
|
||||
onChange={this.handleChange.bind(this)} >
|
||||
{/*<Avatar size="large" src={imageUrl} />*/}
|
||||
<img className = "avatar" src = {imageUrl} />
|
||||
</Upload>
|
||||
<span className="avatarChange">点击头像更换<br></br>只支持jpg、png格式且大小不超过200kb的图片</span>
|
||||
<Tooltip placement="left" title={<div>点击头像更换 (只支持jpg、png格式且大小不超过200kb的图片)</div>}>
|
||||
<div>
|
||||
<Upload
|
||||
className="avatar-uploader"
|
||||
name="basecode"
|
||||
showUploadList={false}
|
||||
action="/api/user/upload_avatar"
|
||||
beforeUpload={beforeUpload}
|
||||
onChange={this.handleChange.bind(this)} >
|
||||
{/*<Avatar size="large" src={imageUrl} />*/}
|
||||
<img className = "avatar" src = {imageUrl} />
|
||||
</Upload>
|
||||
</div>
|
||||
</Tooltip>
|
||||
<span className="avatarChange"></span>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
}
|
||||
.user-name{
|
||||
padding: .24rem;
|
||||
// text-align: center;
|
||||
background-color: #34495e;
|
||||
color: white;
|
||||
font-size: 18px;
|
||||
@ -60,7 +59,6 @@
|
||||
|
||||
.user-profile {
|
||||
-webkit-box-flex: 1;
|
||||
padding: 32px;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
background: #FFF;
|
||||
border-radius: .04rem;
|
||||
@ -68,14 +66,16 @@
|
||||
position: relative;
|
||||
.bacToPer{
|
||||
position: absolute;
|
||||
right: 40px;
|
||||
top: 40px;
|
||||
right: 8px;
|
||||
top: 8px;
|
||||
z-index: 3;
|
||||
}
|
||||
.user-item-body{
|
||||
width: 80%;
|
||||
margin: 0px auto;
|
||||
padding: 32px;
|
||||
background-color: #ececec;
|
||||
position: relative;
|
||||
// box-shadow: 0 4px 6px rgba(50, 50, 93, 0.3), 0 1px 3px rgba(0, 0, 0, 0.01);
|
||||
.user-item-mask-top{
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
@ -100,9 +100,9 @@
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
padding: 8px 0px;
|
||||
|
||||
.maoboli{
|
||||
background-color: rgba(225,225,225,0.60);
|
||||
// filter: blur(3px);
|
||||
background-color: rgba(225,225,225,0.16);
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@ -119,7 +119,6 @@
|
||||
margin: 5px;
|
||||
margin-left: 0px;
|
||||
margin-bottom: 16px;
|
||||
// border-bottom: 1px solid #f1f3f6;
|
||||
padding-bottom: 16px;
|
||||
font-size: 14px;
|
||||
#old_password,#password,#verify_pass{
|
||||
@ -135,11 +134,9 @@
|
||||
}
|
||||
}
|
||||
.ant-col-4{
|
||||
color: rgba(0,0,0,0.85);
|
||||
color: rgba(0,0,0,0.66);
|
||||
padding: 0px 16px;
|
||||
text-indent: .7em;
|
||||
// background-color: #f1f3f6;
|
||||
border-left: 4px solid #f1f3f6;
|
||||
margin-right: 30px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@ -147,7 +144,6 @@
|
||||
padding-right: 15px;
|
||||
}
|
||||
.text-button{
|
||||
// font-size: 12px;
|
||||
color: #657289;
|
||||
cursor: pointer
|
||||
}
|
||||
@ -160,6 +156,7 @@
|
||||
}
|
||||
.avatar-uploader{
|
||||
border: none;
|
||||
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.31), 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
.avatar-uploader,
|
||||
.avatar-uploader-trigger{
|
||||
@ -171,7 +168,6 @@
|
||||
.avatar{
|
||||
width: 100px;
|
||||
min-height: 100px;
|
||||
// border-radius: 50px;
|
||||
}
|
||||
.avatarImg{
|
||||
width: 100px;
|
||||
@ -180,6 +176,7 @@
|
||||
height: 100px;
|
||||
background-color: white;
|
||||
margin: 0px auto;
|
||||
box-shadow: 0 4px 6px rgba(50, 50, 93, 0.31), 0 1px 3px rgba(0, 0, 0, 0.08);
|
||||
img{
|
||||
width: 100%;
|
||||
}
|
||||
@ -195,6 +192,7 @@
|
||||
.avatar-box{
|
||||
width: 100px;
|
||||
margin: 0px auto;
|
||||
position: relative;
|
||||
}
|
||||
.avatarCon{
|
||||
background: gray;
|
||||
@ -257,6 +255,8 @@
|
||||
padding: 8px;
|
||||
margin-left: -100px;
|
||||
color: #ececec;
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
|
||||
|
9081
npm-shrinkwrap.json
generated
9081
npm-shrinkwrap.json
generated
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,6 @@ class interfaceController extends baseController {
|
||||
*/
|
||||
async add(ctx) {
|
||||
let params = ctx.request.body;
|
||||
|
||||
params = yapi.commons.handleParams(params, {
|
||||
project_id: 'number',
|
||||
title: 'string',
|
||||
@ -52,6 +51,11 @@ class interfaceController extends baseController {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
params.res_body_type = params.res_body_type ? params.res_body_type.toLowerCase() : 'json';
|
||||
@ -196,14 +200,14 @@ class interfaceController extends baseController {
|
||||
}
|
||||
try {
|
||||
let result = await this.catModel.list(project_id), newResult = [];
|
||||
for(let i=0, item, list;i< result.length; i++){
|
||||
for (let i = 0, item, list; i < result.length; i++) {
|
||||
item = result[i].toObject()
|
||||
list = await this.Model.listByCatid(item._id, '_id title method')
|
||||
for(let j=0; j< list.length; j++){
|
||||
list = await this.Model.listByCatid(item._id, '_id title method path')
|
||||
for (let j = 0; j < list.length; j++) {
|
||||
list[j] = list[j].toObject()
|
||||
}
|
||||
}
|
||||
item.list = list;
|
||||
newResult[i] = item
|
||||
newResult[i] = item
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(newResult);
|
||||
} catch (err) {
|
||||
@ -249,6 +253,7 @@ class interfaceController extends baseController {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
|
||||
@ -257,7 +262,12 @@ class interfaceController extends baseController {
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
|
||||
}
|
||||
|
||||
let interfaceData = await this.Model.get(id);
|
||||
let auth = await this.checkAuth(interfaceData.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
if (params.path && !yapi.commons.verifyPath(params.path)) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/');
|
||||
@ -287,7 +297,7 @@ class interfaceController extends baseController {
|
||||
data.method = params.method;
|
||||
}
|
||||
|
||||
if(params.catid){
|
||||
if (params.catid) {
|
||||
data.catid = params.catid;
|
||||
}
|
||||
|
||||
@ -323,7 +333,7 @@ class interfaceController extends baseController {
|
||||
data.res_body = params.res_body;
|
||||
}
|
||||
|
||||
if(params.status){
|
||||
if (params.status) {
|
||||
data.status = params.status;
|
||||
}
|
||||
|
||||
@ -331,13 +341,13 @@ class interfaceController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
let username = this.getUsername();
|
||||
let cate;
|
||||
if(params.catid){
|
||||
if (params.catid) {
|
||||
cate = await this.catModel.get(+params.catid);
|
||||
}else{
|
||||
} else {
|
||||
let inter = await this.Model.get(id);
|
||||
cate = await this.catModel.get(inter.catid);
|
||||
cate = interfaceData.catid;
|
||||
}
|
||||
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
|
||||
type: 'project',
|
||||
@ -374,8 +384,9 @@ class interfaceController extends baseController {
|
||||
let data = await this.Model.get(ctx.request.body.id);
|
||||
|
||||
if (data.uid != this.getUid()) {
|
||||
if (await this.jungeProjectAuth(data.project_id) !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
let auth = await this.checkAuth(data.project_id, 'project', 'danger')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,10 +449,16 @@ class interfaceController extends baseController {
|
||||
if (!params.project_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
if (!params.name) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '名称不能为空');
|
||||
}
|
||||
|
||||
|
||||
let result = await this.catModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -474,10 +491,15 @@ class interfaceController extends baseController {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
up_time: yapi.commons.time()
|
||||
});
|
||||
});
|
||||
|
||||
let username = this.getUsername();
|
||||
let cate = await this.catModel.get(params.catid);
|
||||
|
||||
let auth = await this.checkAuth(cate.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}"`,
|
||||
type: 'project',
|
||||
@ -511,7 +533,7 @@ class interfaceController extends baseController {
|
||||
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}" 及该分类下的接口`,
|
||||
type: 'project',
|
||||
|
@ -21,7 +21,7 @@ class interfaceColController extends baseController{
|
||||
* @example
|
||||
*/
|
||||
async list(ctx){
|
||||
try {
|
||||
try {
|
||||
let id = ctx.query.project_id;
|
||||
let result = await this.colModel.list(id);
|
||||
|
||||
@ -64,6 +64,11 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '名称不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
let result = await this.colModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -133,9 +138,16 @@ class interfaceColController extends baseController{
|
||||
method: 'string'
|
||||
});
|
||||
|
||||
|
||||
if (!params.project_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
if (!params.col_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口集id不能为空');
|
||||
}
|
||||
@ -192,11 +204,16 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '用例id不能为空');
|
||||
}
|
||||
|
||||
|
||||
if(!params.casename){
|
||||
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')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
params.uid = this.getUid();
|
||||
|
||||
let result = await this.caseModel.up(params.id, params);
|
||||
@ -244,6 +261,13 @@ class interfaceColController extends baseController{
|
||||
async upCol(ctx){
|
||||
try{
|
||||
let params = ctx.request.body;
|
||||
let id = params.col_id;
|
||||
let colData = await this.colModel.get(id);
|
||||
let auth = await this.checkAuth(colData.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
let result = await this.colModel.up(params.col_id, {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
|
@ -589,6 +589,11 @@ class projectController extends baseController {
|
||||
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);
|
||||
|
@ -118,7 +118,7 @@ class userController extends baseController {
|
||||
|
||||
if (login === true) {
|
||||
yapi.commons.log('login success');
|
||||
ctx.redirect('/');
|
||||
ctx.redirect('/group');
|
||||
}
|
||||
} catch (e) {
|
||||
yapi.commons.log(e.message, 'error');
|
||||
|
@ -106,14 +106,13 @@ var interfaceController = function (_baseController) {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, username, cate;
|
||||
var params, auth, checkRepeat, data, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
params = ctx.request.body;
|
||||
|
||||
|
||||
params = _yapi2.default.commons.handleParams(params, {
|
||||
project_id: 'number',
|
||||
title: 'string',
|
||||
@ -122,49 +121,64 @@ var interfaceController = function (_baseController) {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
_context.next = 4;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 4:
|
||||
auth = _context.sent;
|
||||
|
||||
if (auth) {
|
||||
_context.next = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 7:
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
params.res_body_type = params.res_body_type ? params.res_body_type.toLowerCase() : 'json';
|
||||
|
||||
if (params.project_id) {
|
||||
_context.next = 7;
|
||||
_context.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 7:
|
||||
case 12:
|
||||
if (params.path) {
|
||||
_context.next = 9;
|
||||
_context.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口请求路径不能为空'));
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
if (_yapi2.default.commons.verifyPath(params.path)) {
|
||||
_context.next = 11;
|
||||
_context.next = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 11:
|
||||
_context.next = 13;
|
||||
case 16:
|
||||
_context.next = 18;
|
||||
return this.Model.checkRepeat(params.project_id, params.path, params.method);
|
||||
|
||||
case 13:
|
||||
case 18:
|
||||
checkRepeat = _context.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context.next = 16;
|
||||
_context.next = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 16:
|
||||
_context.prev = 16;
|
||||
case 21:
|
||||
_context.prev = 21;
|
||||
data = {
|
||||
project_id: params.project_id,
|
||||
catid: params.catid,
|
||||
@ -199,18 +213,18 @@ var interfaceController = function (_baseController) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
_context.next = 24;
|
||||
_context.next = 29;
|
||||
return this.Model.save(data);
|
||||
|
||||
case 24:
|
||||
case 29:
|
||||
result = _context.sent;
|
||||
username = this.getUsername();
|
||||
// let project = await this.projectModel.get(params.project_id);
|
||||
|
||||
_context.next = 28;
|
||||
_context.next = 33;
|
||||
return this.catModel.get(params.catid);
|
||||
|
||||
case 28:
|
||||
case 33:
|
||||
cate = _context.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
@ -221,21 +235,21 @@ var interfaceController = function (_baseController) {
|
||||
typeid: params.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 36;
|
||||
_context.next = 41;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
_context.prev = 33;
|
||||
_context.t0 = _context['catch'](16);
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.t0 = _context['catch'](21);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 36:
|
||||
case 41:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[16, 33]]);
|
||||
}, _callee, this, [[21, 38]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -454,7 +468,7 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
item = result[i].toObject();
|
||||
_context5.next = 13;
|
||||
return this.Model.listByCatid(item._id, '_id title method');
|
||||
return this.Model.listByCatid(item._id, '_id title method path');
|
||||
|
||||
case 13:
|
||||
list = _context5.sent;
|
||||
@ -527,7 +541,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, id, interfaceData, checkRepeat, data, result, username, cate, inter;
|
||||
var params, id, interfaceData, auth, checkRepeat, data, result, username, cate, inter;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
@ -542,6 +556,7 @@ var interfaceController = function (_baseController) {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
|
||||
@ -560,34 +575,47 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 9:
|
||||
interfaceData = _context6.sent;
|
||||
_context6.next = 12;
|
||||
return this.checkAuth(interfaceData.project_id, 'project', 'edit');
|
||||
|
||||
case 12:
|
||||
auth = _context6.sent;
|
||||
|
||||
if (auth) {
|
||||
_context6.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 15:
|
||||
if (!(params.path && !_yapi2.default.commons.verifyPath(params.path))) {
|
||||
_context6.next = 12;
|
||||
_context6.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 12:
|
||||
case 17:
|
||||
if (!(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method)) {
|
||||
_context6.next = 18;
|
||||
_context6.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
_context6.next = 15;
|
||||
_context6.next = 20;
|
||||
return this.Model.checkRepeat(interfaceData.project_id, params.path, params.method);
|
||||
|
||||
case 15:
|
||||
case 20:
|
||||
checkRepeat = _context6.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context6.next = 18;
|
||||
_context6.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 18:
|
||||
case 23:
|
||||
data = {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
@ -646,41 +674,38 @@ var interfaceController = function (_baseController) {
|
||||
data.status = params.status;
|
||||
}
|
||||
|
||||
_context6.prev = 33;
|
||||
_context6.next = 36;
|
||||
_context6.prev = 38;
|
||||
_context6.next = 41;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 36:
|
||||
case 41:
|
||||
result = _context6.sent;
|
||||
username = this.getUsername();
|
||||
cate = void 0;
|
||||
|
||||
if (!params.catid) {
|
||||
_context6.next = 45;
|
||||
_context6.next = 50;
|
||||
break;
|
||||
}
|
||||
|
||||
_context6.next = 42;
|
||||
_context6.next = 47;
|
||||
return this.catModel.get(+params.catid);
|
||||
|
||||
case 42:
|
||||
case 47:
|
||||
cate = _context6.sent;
|
||||
_context6.next = 51;
|
||||
_context6.next = 54;
|
||||
break;
|
||||
|
||||
case 45:
|
||||
_context6.next = 47;
|
||||
case 50:
|
||||
_context6.next = 52;
|
||||
return this.Model.get(id);
|
||||
|
||||
case 47:
|
||||
case 52:
|
||||
inter = _context6.sent;
|
||||
_context6.next = 50;
|
||||
return this.catModel.get(inter.catid);
|
||||
|
||||
case 50:
|
||||
cate = _context6.sent;
|
||||
cate = interfaceData.catid;
|
||||
|
||||
case 51:
|
||||
case 54:
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
|
||||
@ -690,21 +715,21 @@ var interfaceController = function (_baseController) {
|
||||
typeid: cate.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 58;
|
||||
_context6.next = 61;
|
||||
break;
|
||||
|
||||
case 55:
|
||||
_context6.prev = 55;
|
||||
_context6.t0 = _context6['catch'](33);
|
||||
case 58:
|
||||
_context6.prev = 58;
|
||||
_context6.t0 = _context6['catch'](38);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
||||
|
||||
case 58:
|
||||
case 61:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[33, 55]]);
|
||||
}, _callee6, this, [[38, 58]]);
|
||||
}));
|
||||
|
||||
function up(_x6) {
|
||||
@ -729,7 +754,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var id, data, inter, result, username, cate;
|
||||
var id, data, auth, inter, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
switch (_context7.prev = _context7.next) {
|
||||
@ -757,17 +782,17 @@ var interfaceController = function (_baseController) {
|
||||
}
|
||||
|
||||
_context7.next = 10;
|
||||
return this.jungeProjectAuth(data.project_id);
|
||||
return this.checkAuth(data.project_id, 'project', 'danger');
|
||||
|
||||
case 10:
|
||||
_context7.t0 = _context7.sent;
|
||||
auth = _context7.sent;
|
||||
|
||||
if (!(_context7.t0 !== true)) {
|
||||
if (auth) {
|
||||
_context7.next = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 13:
|
||||
_context7.next = 15;
|
||||
@ -801,9 +826,9 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 27:
|
||||
_context7.prev = 27;
|
||||
_context7.t1 = _context7['catch'](0);
|
||||
_context7.t0 = _context7['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t1.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t0.message);
|
||||
|
||||
case 30:
|
||||
case 'end':
|
||||
@ -906,7 +931,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'addCat',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, result, username;
|
||||
var params, auth, result, username;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -928,15 +953,29 @@ var interfaceController = function (_baseController) {
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 5:
|
||||
_context9.next = 7;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 7:
|
||||
auth = _context9.sent;
|
||||
|
||||
if (auth) {
|
||||
_context9.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 10:
|
||||
if (params.name) {
|
||||
_context9.next = 7;
|
||||
_context9.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '名称不能为空'));
|
||||
|
||||
case 7:
|
||||
_context9.next = 9;
|
||||
case 12:
|
||||
_context9.next = 14;
|
||||
return this.catModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -946,7 +985,7 @@ var interfaceController = function (_baseController) {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context9.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
@ -960,21 +999,21 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context9.next = 18;
|
||||
_context9.next = 23;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
_context9.prev = 15;
|
||||
case 20:
|
||||
_context9.prev = 20;
|
||||
_context9.t0 = _context9['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t0.message);
|
||||
|
||||
case 18:
|
||||
case 23:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[0, 15]]);
|
||||
}, _callee9, this, [[0, 20]]);
|
||||
}));
|
||||
|
||||
function addCat(_x9) {
|
||||
@ -987,7 +1026,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'upCat',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, result, username, cate;
|
||||
var params, result, username, cate, auth;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
switch (_context10.prev = _context10.next) {
|
||||
@ -1009,7 +1048,20 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 8:
|
||||
cate = _context10.sent;
|
||||
_context10.next = 11;
|
||||
return this.checkAuth(cate.project_id, 'project', 'edit');
|
||||
|
||||
case 11:
|
||||
auth = _context10.sent;
|
||||
|
||||
if (auth) {
|
||||
_context10.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 14:
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '"',
|
||||
type: 'project',
|
||||
@ -1019,21 +1071,21 @@ var interfaceController = function (_baseController) {
|
||||
});
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 16;
|
||||
_context10.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context10.prev = 13;
|
||||
case 18:
|
||||
_context10.prev = 18;
|
||||
_context10.t0 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context10.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 13]]);
|
||||
}, _callee10, this, [[0, 18]]);
|
||||
}));
|
||||
|
||||
function upCat(_x10) {
|
||||
|
@ -74,16 +74,17 @@ 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;
|
||||
@ -149,8 +150,8 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCol',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, result;
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -181,6 +182,20 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 7:
|
||||
_context2.next = 9;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 9:
|
||||
auth = _context2.sent;
|
||||
|
||||
if (auth) {
|
||||
_context2.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 12:
|
||||
_context2.next = 14;
|
||||
return this.colModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -190,26 +205,26 @@ var interfaceColController = function (_baseController) {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context2.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context2.next = 16;
|
||||
_context2.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context2.prev = 13;
|
||||
case 18:
|
||||
_context2.prev = 18;
|
||||
_context2.t0 = _context2['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[0, 13]]);
|
||||
}, _callee2, this, [[0, 18]]);
|
||||
}));
|
||||
|
||||
function addCol(_x2) {
|
||||
@ -233,17 +248,18 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getCaseList',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var id, inst, result;
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _id2, inst, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
_context3.prev = 0;
|
||||
id = ctx.query.col_id;
|
||||
_id2 = ctx.query.col_id;
|
||||
inst = _yapi2.default.getInst(_interfaceCase2.default);
|
||||
_context3.next = 5;
|
||||
return inst.list(id, 'all');
|
||||
return inst.list(_id2, 'all');
|
||||
|
||||
case 5:
|
||||
result = _context3.sent;
|
||||
@ -297,8 +313,8 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCase',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, result;
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
switch (_context4.prev = _context4.next) {
|
||||
@ -322,51 +338,65 @@ var interfaceColController = function (_baseController) {
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 5:
|
||||
_context4.next = 7;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 7:
|
||||
auth = _context4.sent;
|
||||
|
||||
if (auth) {
|
||||
_context4.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 10:
|
||||
if (params.col_id) {
|
||||
_context4.next = 7;
|
||||
_context4.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口集id不能为空'));
|
||||
|
||||
case 7:
|
||||
case 12:
|
||||
if (params.casename) {
|
||||
_context4.next = 9;
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
|
||||
params.uid = this.getUid();
|
||||
params.index = 0;
|
||||
params.add_time = _yapi2.default.commons.time();
|
||||
params.up_time = _yapi2.default.commons.time();
|
||||
_context4.next = 15;
|
||||
_context4.next = 20;
|
||||
return this.caseModel.save(params);
|
||||
|
||||
case 15:
|
||||
case 20:
|
||||
result = _context4.sent;
|
||||
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context4.next = 22;
|
||||
_context4.next = 27;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
_context4.prev = 19;
|
||||
case 24:
|
||||
_context4.prev = 24;
|
||||
_context4.t0 = _context4['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
||||
|
||||
case 22:
|
||||
case 27:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[0, 19]]);
|
||||
}, _callee4, this, [[0, 24]]);
|
||||
}));
|
||||
|
||||
function addCase(_x4) {
|
||||
@ -399,8 +429,8 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCase',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, result;
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, caseData, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
switch (_context5.prev = _context5.next) {
|
||||
@ -431,33 +461,52 @@ var interfaceColController = function (_baseController) {
|
||||
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
|
||||
|
||||
case 7:
|
||||
_context5.next = 9;
|
||||
return this.caseModel.get(id);
|
||||
|
||||
case 9:
|
||||
caseData = _context5.sent;
|
||||
_context5.next = 12;
|
||||
return this.checkAuth(caseData.project_id, 'project', 'edit');
|
||||
|
||||
case 12:
|
||||
auth = _context5.sent;
|
||||
|
||||
if (auth) {
|
||||
_context5.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 15:
|
||||
|
||||
params.uid = this.getUid();
|
||||
|
||||
_context5.next = 10;
|
||||
_context5.next = 18;
|
||||
return this.caseModel.up(params.id, params);
|
||||
|
||||
case 10:
|
||||
case 18:
|
||||
result = _context5.sent;
|
||||
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context5.next = 17;
|
||||
_context5.next = 25;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
_context5.prev = 14;
|
||||
case 22:
|
||||
_context5.prev = 22;
|
||||
_context5.t0 = _context5['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context5.t0.message);
|
||||
|
||||
case 17:
|
||||
case 25:
|
||||
case 'end':
|
||||
return _context5.stop();
|
||||
}
|
||||
}
|
||||
}, _callee5, this, [[0, 14]]);
|
||||
}, _callee5, this, [[0, 22]]);
|
||||
}));
|
||||
|
||||
function upCase(_x5) {
|
||||
@ -481,16 +530,17 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getCase',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var id, result;
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _id3, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
case 0:
|
||||
_context6.prev = 0;
|
||||
id = ctx.query.caseid;
|
||||
_id3 = ctx.query.caseid;
|
||||
_context6.next = 4;
|
||||
return this.caseModel.get(id);
|
||||
return this.caseModel.get(_id3);
|
||||
|
||||
case 4:
|
||||
result = _context6.sent;
|
||||
@ -535,40 +585,61 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCol',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var params, result;
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var params, _id4, colData, auth, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
switch (_context7.prev = _context7.next) {
|
||||
case 0:
|
||||
_context7.prev = 0;
|
||||
params = ctx.request.body;
|
||||
_context7.next = 4;
|
||||
_id4 = params.col_id;
|
||||
_context7.next = 5;
|
||||
return this.colModel.get(_id4);
|
||||
|
||||
case 5:
|
||||
colData = _context7.sent;
|
||||
_context7.next = 8;
|
||||
return this.checkAuth(colData.project_id, 'project', 'edit');
|
||||
|
||||
case 8:
|
||||
auth = _context7.sent;
|
||||
|
||||
if (auth) {
|
||||
_context7.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 11:
|
||||
_context7.next = 13;
|
||||
return this.colModel.up(params.col_id, {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 4:
|
||||
case 13:
|
||||
result = _context7.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context7.next = 11;
|
||||
_context7.next = 20;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_context7.prev = 8;
|
||||
case 17:
|
||||
_context7.prev = 17;
|
||||
_context7.t0 = _context7['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context7.t0.message);
|
||||
|
||||
case 11:
|
||||
case 20:
|
||||
case 'end':
|
||||
return _context7.stop();
|
||||
}
|
||||
}
|
||||
}, _callee7, this, [[0, 8]]);
|
||||
}, _callee7, this, [[0, 17]]);
|
||||
}));
|
||||
|
||||
function upCol(_x7) {
|
||||
@ -592,7 +663,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCaseIndex',
|
||||
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 _this2 = this;
|
||||
|
||||
var params;
|
||||
@ -651,16 +722,17 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCol',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var id, colData, auth, result;
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _id5, colData, auth, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
case 0:
|
||||
_context9.prev = 0;
|
||||
id = ctx.query.col_id;
|
||||
_id5 = ctx.query.col_id;
|
||||
_context9.next = 4;
|
||||
return this.colModel.get(id);
|
||||
return this.colModel.get(_id5);
|
||||
|
||||
case 4:
|
||||
colData = _context9.sent;
|
||||
@ -689,12 +761,12 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 12:
|
||||
_context9.next = 14;
|
||||
return this.colModel.del(id);
|
||||
return this.colModel.del(_id5);
|
||||
|
||||
case 14:
|
||||
result = _context9.sent;
|
||||
_context9.next = 17;
|
||||
return this.caseModel.delByCol(id);
|
||||
return this.caseModel.delByCol(_id5);
|
||||
|
||||
case 17:
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
|
||||
@ -728,7 +800,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCase',
|
||||
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 caseid, caseData, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
|
@ -1295,7 +1295,7 @@ var projectController = function (_baseController) {
|
||||
key: 'upSet',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var id, data, result;
|
||||
var id, data, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
while (1) {
|
||||
switch (_context12.prev = _context12.next) {
|
||||
@ -1314,36 +1314,50 @@ var projectController = function (_baseController) {
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 6:
|
||||
_context12.prev = 6;
|
||||
_context12.next = 9;
|
||||
_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 9:
|
||||
case 14:
|
||||
result = _context12.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context12.next = 16;
|
||||
_context12.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context12.prev = 13;
|
||||
_context12.t0 = _context12['catch'](6);
|
||||
case 18:
|
||||
_context12.prev = 18;
|
||||
_context12.t0 = _context12['catch'](11);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context12.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then();
|
||||
} catch (e) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
|
||||
case 17:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context12.stop();
|
||||
}
|
||||
}
|
||||
}, _callee12, this, [[6, 13]]);
|
||||
}, _callee12, this, [[11, 18]]);
|
||||
}));
|
||||
|
||||
function upSet(_x13) {
|
||||
|
@ -271,7 +271,7 @@ var userController = function (_baseController) {
|
||||
|
||||
if (login === true) {
|
||||
_yapi2.default.commons.log('login success');
|
||||
ctx.redirect('/');
|
||||
ctx.redirect('/group');
|
||||
}
|
||||
_context3.next = 16;
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user