mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
Merge branch 'dev' into run
This commit is contained in:
commit
7237bb7f98
@ -96,6 +96,9 @@ $color-black-light : #404040;
|
||||
.ant-avatar-image{
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
.ant-avatar > img{
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
&:hover{
|
||||
.dropdown-link {
|
||||
|
@ -7,9 +7,6 @@ import PropTypes from 'prop-types';
|
||||
class ProjectCard extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
@ -18,13 +15,12 @@ class ProjectCard extends Component {
|
||||
|
||||
render() {
|
||||
const { projectData } = this.props;
|
||||
console.log(projectData);
|
||||
return (
|
||||
<Link to={`/project/${projectData._id}`}>
|
||||
<Card bordered={false} bodyStyle={{padding: 16}} className="m-card">
|
||||
<div className="m-card-logo">
|
||||
<Icon type="area-chart" className="icon" />
|
||||
<p className="name">{projectData.name}</p>
|
||||
<p className="name">{projectData.name || projectData.projectname}</p>
|
||||
</div>
|
||||
<div className="m-card-btns" style={{display: 'none'}}>btns</div>
|
||||
</Card>
|
||||
|
@ -1,10 +1,48 @@
|
||||
import React, { Component } from 'react';
|
||||
import './Follows.scss';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Row, Col } from 'antd';
|
||||
import { getFollowList } from '../../reducer/modules/follow';
|
||||
import Subnav from '../../components/Subnav/Subnav.js';
|
||||
import ProjectCard from '../../components/ProjectCard/ProjectCard.js';
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
data: state.follow.data
|
||||
}
|
||||
},
|
||||
{
|
||||
getFollowList
|
||||
}
|
||||
)
|
||||
class Follows extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
data: []
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
getFollowList: PropTypes.func
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.props.getFollowList(107).then((res) => {
|
||||
console.log(res);
|
||||
if (res.payload.data.errcode === 0) {
|
||||
this.setState({
|
||||
data: res.payload.data.data.list
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render () {
|
||||
const data = this.state.data;
|
||||
console.log(data);
|
||||
return (
|
||||
<div>
|
||||
<Subnav
|
||||
@ -17,14 +55,15 @@ class Follows extends Component {
|
||||
path: '/follow'
|
||||
}]}/>
|
||||
<div className="g-row">
|
||||
<div className="follow-box">
|
||||
<div className="follow-container">
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
<ProjectCard />
|
||||
</div>
|
||||
</div>
|
||||
<Row gutter={16} className="follow-box">
|
||||
{data.map((item, index) => {
|
||||
console.log(item);
|
||||
return (
|
||||
<Col span={6} key={index}>
|
||||
<ProjectCard projectData={item} />
|
||||
</Col>);
|
||||
})}
|
||||
</Row>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
@ -3,10 +3,5 @@
|
||||
|
||||
.follow-box{
|
||||
padding: 24px;
|
||||
background-color: #FFF;
|
||||
.follow-container{
|
||||
display: flex;
|
||||
display: -webkit-flex;
|
||||
}
|
||||
|
||||
}
|
||||
background-color: #fff;
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ class MemberList extends Component {
|
||||
render() {
|
||||
return (
|
||||
<div className="m-panel">
|
||||
chengyuan 列表 成员
|
||||
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -133,17 +133,17 @@ class ProjectList extends Component {
|
||||
})
|
||||
}
|
||||
|
||||
// 分页逻辑
|
||||
@autobind
|
||||
paginationChange(pageNum) {
|
||||
this.props.fetchProjectList(this.props.currGroup._id, pageNum).then((res) => {
|
||||
if (res.payload.data.errcode) {
|
||||
message.error(res.payload.data.errmsg);
|
||||
} else {
|
||||
this.props.changeTableLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
// // 分页逻辑 取消分页
|
||||
// @autobind
|
||||
// paginationChange(pageNum) {
|
||||
// this.props.fetchProjectList(this.props.currGroup._id, pageNum).then((res) => {
|
||||
// if (res.payload.data.errcode) {
|
||||
// message.error(res.payload.data.errmsg);
|
||||
// } else {
|
||||
// this.props.changeTableLoading(false);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// 切换分组
|
||||
|
@ -54,7 +54,7 @@ class Login extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
window.QSSO.attach('qsso-login','/api/user/login_by_token')
|
||||
if(window.QSSO) window.QSSO.attach('qsso-login','/api/user/login_by_token')
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,96 @@
|
||||
import React,{Component} from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Form, Input, Select, Button } from 'antd';
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
function hasErrors(fieldsError) {
|
||||
return Object.keys(fieldsError).some(field => fieldsError[field]);
|
||||
}
|
||||
class AddInterfaceForm extends Component {
|
||||
static propTypes = {
|
||||
form: PropTypes.object,
|
||||
onSubmit: PropTypes.func,
|
||||
onCancel: PropTypes.func
|
||||
}
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.props.onSubmit(values)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator, getFieldsError } = this.props.form;
|
||||
const prefixSelector = getFieldDecorator('method', {
|
||||
initialValue: 'GET'
|
||||
})(
|
||||
<Select style={{ width: 75 }}>
|
||||
<Option value="GET">GET</Option>
|
||||
<Option value="POST">POST</Option>
|
||||
<Option value="PUT">PUT</Option>
|
||||
<Option value="DELETE">DELETE</Option>
|
||||
</Select>
|
||||
);
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 14 }
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="接口名称"
|
||||
>
|
||||
{getFieldDecorator('title', {
|
||||
rules: [{
|
||||
required: true, message: '清输入接口名称!'
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="接口名称" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="接口路径"
|
||||
>
|
||||
{getFieldDecorator('path', {
|
||||
rules: [{
|
||||
required: true, message: '清输入接口路径!'
|
||||
}]
|
||||
})(
|
||||
<Input addonBefore={prefixSelector} placeholder="/path" />
|
||||
)}
|
||||
</FormItem>
|
||||
<br />
|
||||
<FormItem wrapperCol={{ span: 24, offset: 8 }} >
|
||||
<Button onClick={this.props.onCancel} style={{marginRight: "10px"}} >取消</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
disabled={hasErrors(getFieldsError())}
|
||||
>
|
||||
提交
|
||||
</Button>
|
||||
</FormItem>
|
||||
|
||||
</Form>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(AddInterfaceForm);
|
@ -1,5 +1,29 @@
|
||||
import React from 'react'
|
||||
import React,{Component} from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux';
|
||||
import InterfaceEditForm from './InterfaceEditForm.js'
|
||||
|
||||
export default () => {
|
||||
return <h1>接口Edit</h1>
|
||||
}
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
curdata: state.inter.curdata
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class InterfaceEdit extends Component{
|
||||
static propTypes = {
|
||||
curdata: PropTypes.object
|
||||
}
|
||||
|
||||
render(){
|
||||
|
||||
return <div>
|
||||
<h3>Edit</h3>
|
||||
<InterfaceEditForm />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceEdit;
|
@ -0,0 +1,334 @@
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
import {
|
||||
Form, Select, Input,
|
||||
Button, Row, Col, Radio, Icon
|
||||
} from 'antd';
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
const RadioGroup = Radio.Group;
|
||||
const dataTpl = {
|
||||
query: { name: "", required: "1", desc: "" },
|
||||
req_headers: { name: "", required: "1", desc: "" }
|
||||
}
|
||||
|
||||
const mockEditor = require('./mockEditor.js');
|
||||
|
||||
|
||||
class InterfaceEditForm extends Component {
|
||||
static propTypes = {
|
||||
form: PropTypes.object
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
title: 'title',
|
||||
path: 'path',
|
||||
method: 'get',
|
||||
query: [{
|
||||
name: 'name',
|
||||
desc: 'desc',
|
||||
required: "1"
|
||||
}],
|
||||
req_body_type: 'form',
|
||||
req_headers: [{
|
||||
name: 'Content-Type',
|
||||
value: 'application/urlencode', required: "1"
|
||||
}],
|
||||
req_body_form: [{
|
||||
name: 'id',
|
||||
type: 'text',
|
||||
required: '1'
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log('Received values of form: ', values);
|
||||
console.log(this.props.form.getFieldValue('keys'))
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
mockEditor({
|
||||
container: 'req_body_json',
|
||||
data: {
|
||||
name: "@name"
|
||||
},
|
||||
onChange: function (d) {
|
||||
console.log(this)
|
||||
console.log(d)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
addParams = (name) => {
|
||||
let newValue = {}
|
||||
newValue[name] = [].concat(this.state[name], dataTpl[name])
|
||||
this.setState(newValue)
|
||||
}
|
||||
|
||||
delParams = (key, name) => {
|
||||
|
||||
let curValue = this.props.form.getFieldValue(name);
|
||||
let newValue = {}
|
||||
newValue[name] = curValue.filter((val, index) => {
|
||||
return index !== key;
|
||||
})
|
||||
this.props.form.setFieldsValue(newValue)
|
||||
this.setState(newValue)
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const formItemLayout = {
|
||||
labelCol: { span: 6 },
|
||||
wrapperCol: { span: 14 }
|
||||
};
|
||||
const prefixSelector = getFieldDecorator('method', {
|
||||
initialValue: 'GET'
|
||||
})(
|
||||
<Select style={{ width: 75 }}>
|
||||
<Option value="GET">GET</Option>
|
||||
<Option value="POST">POST</Option>
|
||||
<Option value="PUT">PUT</Option>
|
||||
<Option value="DELETE">DELETE</Option>
|
||||
</Select>
|
||||
);
|
||||
|
||||
const queryTpl = (data, index) => {
|
||||
return <Row key={index}>
|
||||
<Col span="4">
|
||||
{getFieldDecorator('query[' + index + '].name', {
|
||||
initialValue: data.name
|
||||
})(
|
||||
<Input placeholder="参数名称" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="4" >
|
||||
{getFieldDecorator('query[' + index + '].required', {
|
||||
initialValue: data.required
|
||||
})(
|
||||
<Select>
|
||||
<Option value="1">必需</Option>
|
||||
<Option value="0">非必需</Option>
|
||||
</Select>
|
||||
)}
|
||||
</Col>
|
||||
<Col span="8" >
|
||||
{getFieldDecorator('query[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="2" >
|
||||
<Icon type="delete" onClick={() => this.delParams(index, 'query')} />
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
}
|
||||
|
||||
const headerTpl = (data, index) => {
|
||||
return <Row key={index}>
|
||||
<Col span="4">
|
||||
{getFieldDecorator('req_headers[' + index + '].name', {
|
||||
initialValue: data.name
|
||||
})(
|
||||
<Input placeholder="参数名称" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="6" >
|
||||
{getFieldDecorator('req_headers[' + index + '].value', {
|
||||
initialValue: data.value
|
||||
})(
|
||||
<Input placeholder="参数值" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="8" >
|
||||
{getFieldDecorator('req_headers[' + index + '].desc', {
|
||||
initialValue: data.desc
|
||||
})(
|
||||
<Input placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="2" >
|
||||
<Icon type="delete" onClick={() => this.delParams(index, 'req_headers')} />
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
}
|
||||
|
||||
const requestBodyTpl = (data, index) => {
|
||||
return <Row key={index}>
|
||||
<Col span="8">
|
||||
{getFieldDecorator('req_body_form[' + index + '].name')(
|
||||
<Input placeholder="name" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="4" >
|
||||
{getFieldDecorator('req_body_form[' + index + '].type', {
|
||||
initialValue: 'text'
|
||||
})(
|
||||
<Select>
|
||||
<Option value="text">文本</Option>
|
||||
<Option value="file">文件</Option>
|
||||
</Select>
|
||||
)}
|
||||
</Col>
|
||||
<Col span="8">
|
||||
{getFieldDecorator('req_body_form[' + index + '].desc')(
|
||||
<Input placeholder="备注" />
|
||||
)}
|
||||
</Col>
|
||||
<Col span="2" >
|
||||
<Icon type="delete" onClick={() => this.delParams(index, 'req_body_form')} />
|
||||
</Col>
|
||||
</Row>
|
||||
}
|
||||
|
||||
const QueryList = this.state.query.map((item, index) => {
|
||||
return queryTpl(item, index)
|
||||
})
|
||||
|
||||
const headerList = this.state.req_headers.map((item, index) => {
|
||||
return headerTpl(item, index)
|
||||
})
|
||||
|
||||
const requestBodyList = this.state.req_body_form.map((item, index) => {
|
||||
return requestBodyTpl(item, index)
|
||||
})
|
||||
|
||||
return (
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="接口名称"
|
||||
>
|
||||
{getFieldDecorator('title', {
|
||||
rules: [{
|
||||
required: true, message: '清输入接口名称!'
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="接口名称" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="接口路径"
|
||||
>
|
||||
{getFieldDecorator('path', {
|
||||
rules: [{
|
||||
required: true, message: '清输入接口路径!'
|
||||
}]
|
||||
})(
|
||||
<Input addonBefore={prefixSelector} placeholder="/path" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="状态"
|
||||
>
|
||||
{getFieldDecorator('status', { initialValue: 'undone' })(
|
||||
<Select>
|
||||
<Option value="done">已完成</Option>
|
||||
<Option value="undone">未完成</Option>
|
||||
</Select>
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="接口描述"
|
||||
>
|
||||
{getFieldDecorator('desc')(
|
||||
<Input.TextArea placeholder="接口描述" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="Query"
|
||||
>
|
||||
<Button onClick={() => this.addParams('query')}>添加Query参数</Button>
|
||||
</FormItem>
|
||||
|
||||
<Row>
|
||||
<Col span={18} offset={6}>
|
||||
{QueryList}
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="请求Headers"
|
||||
>
|
||||
<Button onClick={() => this.addParams('req_headers')}>添加Header</Button>
|
||||
</FormItem>
|
||||
|
||||
<Row>
|
||||
<Col span={18} offset={6}>
|
||||
{headerList}
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
|
||||
<FormItem style={{ marginBottom: "5px" }}
|
||||
{...formItemLayout}
|
||||
label="请求Body"
|
||||
>
|
||||
{getFieldDecorator('req_body_type', {
|
||||
initialValue: this.state.req_body_type
|
||||
})(
|
||||
<RadioGroup>
|
||||
<Radio value="form">form</Radio>
|
||||
<Radio value="json">json</Radio>
|
||||
<Radio value="file">file</Radio>
|
||||
</RadioGroup>
|
||||
)}
|
||||
|
||||
</FormItem>
|
||||
|
||||
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'form' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} style={{ minHeight: "300px", padding: "15px" }}>
|
||||
<Row>
|
||||
<Col span="24">
|
||||
|
||||
<Button onClick={() => this.addParams('req_body_form')}>添加form参数</Button>
|
||||
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
{requestBodyList}
|
||||
</Col>
|
||||
|
||||
</Row>
|
||||
|
||||
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'json' ? 'block' : 'none' }}>
|
||||
<Col span={14} offset={6} id="req_body_json" style={{ minHeight: "300px", padding: "15px" }}>
|
||||
|
||||
</Col>
|
||||
|
||||
|
||||
</Row>
|
||||
<FormItem
|
||||
wrapperCol={{ span: 12, offset: 6 }}
|
||||
>
|
||||
<Button type="primary" htmlType="submit">Submit</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(InterfaceEditForm);
|
@ -1,54 +1,174 @@
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux';
|
||||
import PropTypes from 'prop-types'
|
||||
import { fetchInterfaceList } from '../../../../reducer/modules/interface.js';
|
||||
import { Menu, Button, Input, Icon, Tag } from 'antd';
|
||||
import { fetchInterfaceList, fetchInterfaceData, changeInterfaceId, addInterfaceData, deleteInterfaceData } from '../../../../reducer/modules/interface.js';
|
||||
import { Menu, Input, Icon, Tag, Modal, message } from 'antd';
|
||||
import AddInterfaceForm from './AddInterfaceForm';
|
||||
import axios from 'axios'
|
||||
|
||||
const confirm = Modal.confirm;
|
||||
|
||||
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
list: state.inter.list,
|
||||
curProject: state.project.curProject
|
||||
curProject: state.project.curProject,
|
||||
interfaceId: state.inter.interfaceId
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchInterfaceList
|
||||
fetchInterfaceList,
|
||||
fetchInterfaceData,
|
||||
changeInterfaceId,
|
||||
addInterfaceData,
|
||||
deleteInterfaceData
|
||||
}
|
||||
)
|
||||
class InterfaceMenu extends Component {
|
||||
static propTypes = {
|
||||
projectId: PropTypes.string,
|
||||
interfaceId: PropTypes.number,
|
||||
list: PropTypes.array,
|
||||
fetchInterfaceList: PropTypes.func,
|
||||
curProject: PropTypes.object
|
||||
}
|
||||
curProject: PropTypes.object,
|
||||
fetchInterfaceData: PropTypes.func,
|
||||
changeInterfaceId: PropTypes.func,
|
||||
addInterfaceData: PropTypes.func,
|
||||
deleteInterfaceData: PropTypes.func
|
||||
}
|
||||
|
||||
showModal = () => {
|
||||
this.setState({
|
||||
visible: true
|
||||
});
|
||||
}
|
||||
|
||||
handleCancel = () => {
|
||||
this.setState({
|
||||
visible: false
|
||||
});
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
curKey: null,
|
||||
visible: false,
|
||||
delIcon: null,
|
||||
filter: ''
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount(){
|
||||
this.props.fetchInterfaceList(this.props.projectId)
|
||||
async handleRequest() {
|
||||
let result = await this.props.fetchInterfaceList(this.props.projectId);
|
||||
let interfaces = result.payload.data;
|
||||
if (interfaces.length > 0) {
|
||||
this.props.changeInterfaceId(interfaces[0]._id)
|
||||
await this.props.fetchInterfaceData(interfaces[0]._id)
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.handleRequest()
|
||||
}
|
||||
|
||||
onSelect = (item) => {
|
||||
this.props.changeInterfaceId(parseInt(item.key, 10))
|
||||
this.props.fetchInterfaceData(parseInt(item.key, 10))
|
||||
}
|
||||
|
||||
handleAddInterface = (data) => {
|
||||
data.project_id = this.props.projectId;
|
||||
axios.post('/api/interface/add', data).then((res) => {
|
||||
if (res.data.errcode !== 0) {
|
||||
return message.error(res.data.errmsg);
|
||||
}
|
||||
message.success('接口添加成功')
|
||||
this.props.addInterfaceData(res.data.data)
|
||||
this.setState({
|
||||
visible: false
|
||||
});
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
showConfirm = (id)=> {
|
||||
let that = this;
|
||||
confirm({
|
||||
title: '您确认删除此接口',
|
||||
content: '温馨提示:接口删除后,无法恢复',
|
||||
onOk() {
|
||||
that.props.deleteInterfaceData(id)
|
||||
},
|
||||
onCancel() { }
|
||||
});
|
||||
}
|
||||
|
||||
delInterface = (id) => {
|
||||
|
||||
this.props.deleteInterfaceData(id)
|
||||
}
|
||||
|
||||
enterItem = (e) => {
|
||||
this.setState({ delIcon: e.key })
|
||||
}
|
||||
|
||||
leaveItem = () => {
|
||||
this.setState({ delIcon: null })
|
||||
}
|
||||
|
||||
onFilter = (e) => {
|
||||
this.setState({
|
||||
filter: e.target.value
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
const items = [];
|
||||
this.props.list.forEach((item, index)=> {
|
||||
this.props.list.forEach((item) => {
|
||||
let color, filter = this.state.filter;
|
||||
if(filter && item.title.indexOf(filter) === -1 && item.path.indexOf(filter) === -1){
|
||||
return null;
|
||||
}
|
||||
switch (item.method) {
|
||||
case 'GET': color = "green"; break;
|
||||
case 'POST': color = "blue"; break;
|
||||
case 'PUT': color = "yellow"; break;
|
||||
case 'DELETE': color = 'red'; break;
|
||||
default: color = "green";
|
||||
}
|
||||
|
||||
items.push(
|
||||
<Menu.Item key={index}><Button className="btn-http" type="primary">{item.method} </Button>{item.title}</Menu.Item>
|
||||
<Menu.Item onMouseEnter={this.enterItem} onMouseLeave={this.leaveItem} key={"" + item._id}>
|
||||
<Tag className="btn-http" color={color}>{item.method} </Tag>
|
||||
{item.title}
|
||||
<Icon type="delete" onClick={()=> {this.showConfirm(item._id)}} style={{ display: this.state.delIcon == item._id ? 'block' : 'none' }} className="interface-delete-icon" />
|
||||
</Menu.Item>
|
||||
)
|
||||
} )
|
||||
})
|
||||
|
||||
return <div>
|
||||
<div className="interface-filter">
|
||||
<Input placeholder="Filter by name" style={{ width: "70%" }} />
|
||||
<Tag color="#108ee9" style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
|
||||
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
|
||||
<Tag onClick={this.showModal} color="#108ee9" style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
|
||||
<Modal
|
||||
title="添加接口"
|
||||
visible={this.state.visible}
|
||||
onOk={this.handleOk}
|
||||
onCancel={this.handleCancel}
|
||||
footer={null}
|
||||
>
|
||||
<AddInterfaceForm onCancel={this.handleCancel} onSubmit={this.handleAddInterface} />
|
||||
</Modal>
|
||||
</div>
|
||||
<Menu className="interface-list">
|
||||
<Menu selectedKeys={[this.props.interfaceId + ""]} className="interface-list" onSelect={this.onSelect}>
|
||||
{items}
|
||||
</Menu>
|
||||
</div>
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceMenu
|
@ -1,6 +1,27 @@
|
||||
import React from 'react'
|
||||
import React,{Component} from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
export default () => {
|
||||
return <h1>接口预览</h1>
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
curdata: state.inter.curdata
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
class InterfaceView extends Component{
|
||||
static propTypes = {
|
||||
curdata: PropTypes.object
|
||||
}
|
||||
|
||||
render(){
|
||||
console.log(this.props.curdata)
|
||||
let view = JSON.stringify(this.props.curdata, null, " ");
|
||||
return <pre>
|
||||
{view}
|
||||
</pre>
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceView;
|
138
client/containers/Project/Interface/InterfaceList/mockEditor.js
Normal file
138
client/containers/Project/Interface/InterfaceList/mockEditor.js
Normal file
@ -0,0 +1,138 @@
|
||||
var ace = require('brace'),
|
||||
Mock = require('mockjs')
|
||||
require('brace/mode/javascript');
|
||||
require('brace/theme/xcode');
|
||||
require("brace/ext/language_tools.js");
|
||||
require("brace/snippets/javascript.js");
|
||||
|
||||
var json5 = require('json5');
|
||||
|
||||
var langTools = ace.acequire("ace/ext/language_tools"),
|
||||
editor,
|
||||
mockEditor,
|
||||
rhymeCompleter,
|
||||
wordList = [
|
||||
{ name: '字符串', mock: '@string' },
|
||||
{ name: '自然数', mock: '@natural' },
|
||||
{ name: '浮点数', mock: '@float' },
|
||||
{ name: '字符', mock: '@character' },
|
||||
{ name: '布尔', mock: '@boolean' },
|
||||
{ name: 'url', mock: '@url' },
|
||||
{ name: '域名', mock: '@domain' },
|
||||
{ name: 'ip地址', mock: '@ip' },
|
||||
{ name: 'id', mock: '@id' },
|
||||
{ name: 'guid', mock: '@guid' },
|
||||
{ name: '当前时间', mock: '@now' },
|
||||
{ name: '日期', mock: '@date' },
|
||||
{ name: '时间', mock: '@time' },
|
||||
{ name: '日期时间', mock: '@datetime' },
|
||||
{ name: '图片连接', mock: '@image' },
|
||||
{ name: '图片data', mock: "@imageData" },
|
||||
{ name: '颜色', mock: '@color' },
|
||||
{ name: '颜色hex', mock: '@hex' },
|
||||
{ name: '颜色rgba', mock: '@rgba' },
|
||||
{ name: '颜色rgb', mock: '@rgb' },
|
||||
{ name: '颜色hsl', mock: '@hsl' },
|
||||
{ name: '整数', mock: '@integer' },
|
||||
{ name: '浮点数', mock: '@float' },
|
||||
{ name: 'email', mock: '@email' },
|
||||
{ name: '大段文本', mock: '@paragraph' },
|
||||
{ name: '句子', mock: '@sentence' },
|
||||
{ name: '单词', mock: '@word' },
|
||||
{ name: '大段中文文本', mock: '@cparagraph' },
|
||||
{ name: '中文标题', mock: '@ctitle' },
|
||||
{ name: '标题', mock: '@title' },
|
||||
{ name: '姓名', mock: '@name' },
|
||||
{ name: '中文姓名', mock: '@cname' },
|
||||
{ name: '中文姓', mock: '@cfirst' },
|
||||
{ name: '中文名', mock: '@clast' },
|
||||
{ name: '英文姓', mock: '@first' },
|
||||
{ name: '英文名', mock: '@last' },
|
||||
{ name: '中文句子', mock: '@csentence' },
|
||||
{ name: '中文词组', mock: '@cword' },
|
||||
{ name: '地址', mock: '@region' },
|
||||
{ name: '省份', mock: '@province' },
|
||||
{ name: '城市', mock: '@city' },
|
||||
{ name: '地区', mock: '@county' },
|
||||
{ name: '转换为大写', mock: '@upper' },
|
||||
{ name: '转换为小写', mock: '@lower' },
|
||||
{ name: '挑选(枚举)', mock: '@pick' },
|
||||
{ name: '打乱数组', mock: '@shuffle' },
|
||||
{ name: '协议', mock: '@protocol' }
|
||||
];
|
||||
|
||||
function run(options) {
|
||||
options = options || {};
|
||||
var container, data;
|
||||
container = options.container || 'mock-editor';
|
||||
if (options.wordList && typeof options.wordList === 'object' && options.wordList.name && options.wordList.mock) {
|
||||
wordList.push(options.wordList);
|
||||
}
|
||||
data = options.data || '';
|
||||
|
||||
editor = ace.edit(container)
|
||||
editor.$blockScrolling = Infinity;
|
||||
editor.getSession().setMode('ace/mode/javascript');
|
||||
editor.setTheme('ace/theme/xcode');
|
||||
editor.setOptions({
|
||||
enableBasicAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
enableLiveAutocompletion: true
|
||||
});
|
||||
mockEditor = {
|
||||
curData: {},
|
||||
getValue: editor.getValue,
|
||||
setValue: function (data) {
|
||||
data = data || '';
|
||||
if (typeof data === 'string') {
|
||||
editor.setValue(data);
|
||||
} else if (typeof data === 'object') {
|
||||
editor.setValue(json5.stringify(data, null, " "))
|
||||
}
|
||||
},
|
||||
editor: editor
|
||||
}
|
||||
rhymeCompleter = {
|
||||
identifierRegexps: [/[@]/],
|
||||
getCompletions: function (editor, session, pos, prefix, callback) {
|
||||
if (prefix.length === 0) { callback(null, []); return }
|
||||
callback(null, wordList.map(function (ea) {
|
||||
return { name: ea.mock, value: ea.mock, score: ea.mock, meta: ea.name }
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
langTools.addCompleter(rhymeCompleter);
|
||||
mockEditor.setValue(data);
|
||||
handleJson(editor.getValue())
|
||||
|
||||
editor.clearSelection();
|
||||
|
||||
editor.getSession().on('change', () => {
|
||||
handleJson(editor.getValue())
|
||||
if (typeof options.onChange === 'function') {
|
||||
options.onChange.call(mockEditor, mockEditor.curData);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return mockEditor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function handleJson(json) {
|
||||
var curData = mockEditor.curData;
|
||||
try {
|
||||
var obj = json5.parse(json);
|
||||
curData.text = json;
|
||||
curData.format = true;
|
||||
curData.jsonData = obj;
|
||||
curData.mockData = Mock.mock(obj);
|
||||
} catch (e) {
|
||||
curData.format = e.message;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = run;
|
@ -3,7 +3,7 @@
|
||||
min-height: 5rem;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
background: #FFF;
|
||||
border-radius:4px;
|
||||
border-radius:5px;
|
||||
margin: 3px;
|
||||
.ant-tabs-bar{
|
||||
border-bottom: none;
|
||||
@ -41,9 +41,10 @@
|
||||
width: 40px;
|
||||
}
|
||||
|
||||
.btn-http-get{
|
||||
background-color: #00a854;
|
||||
border-color: #00a854
|
||||
.interface-delete-icon{
|
||||
position: absolute;
|
||||
right: 5px;
|
||||
top: 14px;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -53,7 +54,7 @@
|
||||
min-height: 5rem;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
background: #FFF;
|
||||
border-radius:4px;
|
||||
border-radius:5px;
|
||||
.interface-content{
|
||||
.ant-tabs-nav{
|
||||
width:100%
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col, Input, Button, Select, message, Upload, Icon ,Avatar} from 'antd'
|
||||
import { Row, Col, Input, Button, Select, message, Upload} from 'antd'
|
||||
import axios from 'axios';
|
||||
import {formatTime} from '../../common.js'
|
||||
import PropTypes from 'prop-types'
|
||||
@ -273,7 +273,6 @@ class AvatarUpload extends Component {
|
||||
uploadAvatar(basecode){
|
||||
axios.post("/api/user/upload_avatar",{basecode: basecode}).then(()=>{
|
||||
this.setState({ imageUrl: basecode });
|
||||
|
||||
}).catch((e)=>{
|
||||
console.log(e);
|
||||
})
|
||||
@ -284,22 +283,20 @@ class AvatarUpload extends Component {
|
||||
getBase64(info.file.originFileObj, basecode=>{this.uploadAvatar(basecode)});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
let imageUrl = this.state.imageUrl?this.state.imageUrl:`/api/user/avatar?uid=${this.props.uid}`;
|
||||
// console.log(this.props.uid);
|
||||
|
||||
return <div className="avatar-box">
|
||||
<Upload
|
||||
<Upload
|
||||
className="avatar-uploader"
|
||||
name="basecode"
|
||||
showUploadList={true}
|
||||
showUploadList={false}
|
||||
action="/api/user/upload_avatar"
|
||||
beforeUpload={beforeUpload}
|
||||
onChange={this.handleChange.bind(this)} >
|
||||
{
|
||||
imageUrl ?
|
||||
<Avatar size="large" src={imageUrl} />:
|
||||
<Icon type="plus" className="avatar-uploader-trigger" />
|
||||
}
|
||||
{/*<Avatar size="large" src={imageUrl} />*/}
|
||||
<img className = "avatar" src = {imageUrl} />
|
||||
</Upload>
|
||||
<span className="avatarChange">点击头像更换</span>
|
||||
</div>
|
||||
|
@ -113,22 +113,19 @@
|
||||
border: none;
|
||||
}
|
||||
.avatar-uploader,
|
||||
.avatar-uploader-trigger,
|
||||
.avatar {
|
||||
// width: 100px;
|
||||
// height: 100px;
|
||||
.avatar-uploader-trigger{
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
overflow: hidden;
|
||||
// border-radius: 50px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.avatar{
|
||||
width: 100px;
|
||||
}
|
||||
.avatar-uploader {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ant-avatar-lg{
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.ant-upload-list{
|
||||
display: none;
|
||||
}
|
||||
|
34
client/reducer/modules/follow.js
Normal file
34
client/reducer/modules/follow.js
Normal file
@ -0,0 +1,34 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// Actions
|
||||
const GET_FOLLOW_LIST = 'yapi/follow/GET_FOLLOW_LIST';
|
||||
|
||||
// Reducer
|
||||
const initialState = {
|
||||
data: []
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case GET_FOLLOW_LIST: {
|
||||
console.log(action);
|
||||
return {
|
||||
...state,
|
||||
data: action.payload.data.data
|
||||
};
|
||||
}
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
// Action Creators
|
||||
export function getFollowList(uid) {
|
||||
return {
|
||||
type: GET_FOLLOW_LIST,
|
||||
payload: axios.get('/api/follow/list', {
|
||||
params: { uid }
|
||||
})
|
||||
}
|
||||
}
|
@ -2,19 +2,54 @@ import axios from 'axios'
|
||||
// Actions
|
||||
const FETCH_INTERFACE_DATA = 'yapi/interface/FETCH_INTERFACE_DATA';
|
||||
const FETCH_INTERFACE_LIST = 'yapi/interface/FETCH_INTERFACE_LIST';
|
||||
|
||||
// const DELETE_INTERFACE_DATA = 'yapi/interface/DELETE_INTERFACE_DATA';
|
||||
const CHANGE_INTERFACE_ID = 'yapi/interface/CHANGE_INTERFACE_ID';
|
||||
const ADD_INTERFACE_DATA = 'yapi/interface/ADD_INTERFACE_DATA';
|
||||
const DELETE_INTERFACE_DATA = 'yapi/interface/DELETE_INTERFACE_DATA';
|
||||
// const SAVE_INTERFACE_PROJECT_ID = 'yapi/interface/SAVE_INTERFACE_PROJECT_ID';
|
||||
// const GET_INTERFACE_GROUP_LIST = 'yapi/interface/GET_INTERFACE_GROUP_LIST';
|
||||
|
||||
// Reducer
|
||||
const initialState = {
|
||||
interfaceId: 0,
|
||||
curdata: {},
|
||||
list: []
|
||||
}
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case DELETE_INTERFACE_DATA:
|
||||
return (() => {
|
||||
|
||||
let newlist = state.list.filter(data=> data._id !== action.payload), newid, curdata;
|
||||
|
||||
if (state.interfaceId === action.payload && state.list.length > 0) {
|
||||
newid = state.list[0]._id
|
||||
curdata = state.list[0]
|
||||
} else if (state.list.length == 0) {
|
||||
newid = 0;
|
||||
curdata = {}
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
curdata: curdata,
|
||||
interfaceId: newid,
|
||||
list: newlist
|
||||
}
|
||||
})()
|
||||
|
||||
case ADD_INTERFACE_DATA:
|
||||
return {
|
||||
...state,
|
||||
curdata: action.payload,
|
||||
list: [].concat(state.list, action.payload),
|
||||
interfaceId: action.payload._id
|
||||
}
|
||||
case CHANGE_INTERFACE_ID:
|
||||
return {
|
||||
...state,
|
||||
interfaceId: action.payload
|
||||
}
|
||||
case FETCH_INTERFACE_DATA:
|
||||
return {
|
||||
...state,
|
||||
@ -24,31 +59,47 @@ export default (state = initialState, action) => {
|
||||
return {
|
||||
...state,
|
||||
list: action.payload.data
|
||||
}
|
||||
}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
export function changeInterfaceId(id) {
|
||||
return {
|
||||
type: CHANGE_INTERFACE_ID,
|
||||
payload: id
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteInterfaceData(id) {
|
||||
await axios.post('/api/interface/del', { id: id })
|
||||
return {
|
||||
type: DELETE_INTERFACE_DATA,
|
||||
payload: id
|
||||
}
|
||||
}
|
||||
|
||||
// Action Creators
|
||||
export function fetchInterfaceData (interfaceId) {
|
||||
return async (dispatch) => {
|
||||
let result = await axios.get('/api/interface/get?id=' + interfaceId);
|
||||
dispatch({
|
||||
type: FETCH_INTERFACE_DATA,
|
||||
payload: result.data
|
||||
})
|
||||
export async function fetchInterfaceData(interfaceId) {
|
||||
let result = await axios.get('/api/interface/get?id=' + interfaceId);
|
||||
return {
|
||||
type: FETCH_INTERFACE_DATA,
|
||||
payload: result.data
|
||||
}
|
||||
}
|
||||
|
||||
export function fetchInterfaceList(projectId){
|
||||
return async (dispatch) => {
|
||||
let result = await axios.get('/api/interface/list?project_id=' + projectId);
|
||||
dispatch({
|
||||
type: FETCH_INTERFACE_LIST,
|
||||
payload: result.data
|
||||
})
|
||||
export async function fetchInterfaceList(projectId) {
|
||||
let result = await axios.get('/api/interface/list?project_id=' + projectId);
|
||||
return {
|
||||
type: FETCH_INTERFACE_LIST,
|
||||
payload: result.data
|
||||
}
|
||||
}
|
||||
|
||||
export async function addInterfaceData(data) {
|
||||
return {
|
||||
type: ADD_INTERFACE_DATA,
|
||||
payload: data
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import interfaceCol from './interfaceCol.js'
|
||||
import news from './news.js'
|
||||
import addInterface from './addInterface.js'
|
||||
import menu from './menu.js'
|
||||
import follow from './follow.js'
|
||||
|
||||
export default combineReducers({
|
||||
group,
|
||||
@ -16,5 +17,6 @@ export default combineReducers({
|
||||
project,
|
||||
news,
|
||||
addInterface,
|
||||
menu
|
||||
menu,
|
||||
follow
|
||||
})
|
||||
|
@ -52,6 +52,7 @@
|
||||
"gulp-babel": "^6.1.2",
|
||||
"gulp-watch": "^4.3.11",
|
||||
"json2html": "0.0.8",
|
||||
"json5": "^0.5.1",
|
||||
"jsoneditor": "^5.9.3",
|
||||
"jsonwebtoken": "^7.4.1",
|
||||
"koa": "^2.0.0",
|
||||
|
@ -23,12 +23,12 @@ class interfaceController extends baseController {
|
||||
* @param {String} [req_headers[].value] 请求的header信息值
|
||||
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
|
||||
* @param {String} [req_headers[].desc] header描述
|
||||
* @param {String} [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_params_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_params_form[].name] 请求参数名
|
||||
* @param {String} [req_params_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_params_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_params_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_body_form[].name] 请求参数名
|
||||
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_body_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
|
||||
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
|
||||
* @param {String} [desc] 接口描述
|
||||
@ -75,7 +75,7 @@ class interfaceController extends baseController {
|
||||
desc: params.desc,
|
||||
method: params.method,
|
||||
req_headers: params.req_headers,
|
||||
req_params_type: params.req_params_type,
|
||||
req_body_type: params.req_body_type,
|
||||
res_body: params.res_body,
|
||||
res_body_type: params.res_body_type,
|
||||
uid: this.getUid(),
|
||||
@ -83,11 +83,11 @@ class interfaceController extends baseController {
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
|
||||
if (params.req_params_form) {
|
||||
data.req_params_form = params.req_params_form;
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params_other) {
|
||||
data.req_params_other = params.req_params_other;
|
||||
if (params.req_body_other) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
let result = await this.Model.save(data);
|
||||
@ -161,12 +161,12 @@ class interfaceController extends baseController {
|
||||
* @param {String} [req_headers[].value] 请求的header信息值
|
||||
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
|
||||
* @param {String} [req_headers[].desc] header描述
|
||||
* @param {String} [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_params_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_params_form[].name] 请求参数名
|
||||
* @param {String} [req_params_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_params_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_params_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_body_form[].name] 请求参数名
|
||||
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_body_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
|
||||
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
|
||||
* @param {String} [desc] 接口描述
|
||||
@ -225,11 +225,11 @@ class interfaceController extends baseController {
|
||||
data.req_headers = params.req_headers;
|
||||
}
|
||||
|
||||
if (params.req_params_form) {
|
||||
data.req_params_form = params.req_params_form;
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params_other) {
|
||||
data.req_params_other = params.req_params_other;
|
||||
if (params.req_body_other) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
if (params.res_body_type) {
|
||||
|
@ -23,8 +23,7 @@ class interfaceColController extends baseController{
|
||||
async list(ctx){
|
||||
try {
|
||||
let id = ctx.query.project_id;
|
||||
let inst = yapi.getInst(interfaceColModel);
|
||||
let result = await inst.list(id);
|
||||
let result = await this.colModel.list(id);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
@ -579,6 +579,7 @@ class projectController extends baseController {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
async download(ctx) {
|
||||
|
@ -13,28 +13,55 @@ class interfaceModel extends baseModel {
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
project_id: { type: Number, required: true },
|
||||
status: {type: String, enum: ['undone', 'done'], default: 'undone'},
|
||||
desc: String,
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
req_query:[{
|
||||
name: String, value: String, desc: String, required: Boolean
|
||||
name: String, value: String, desc: String, required: {
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_headers: [{
|
||||
name: String, value: String, desc: String, required: Boolean
|
||||
name: String, value: String, desc: String, required: {
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_params_type: {
|
||||
req_body_type: {
|
||||
type: String,
|
||||
enum: ['form', 'json', 'text', 'xml']
|
||||
enum: ['form', 'json', 'text', 'file']
|
||||
},
|
||||
req_params_form: [{
|
||||
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: Boolean
|
||||
req_body_form: [{
|
||||
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: {
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_params_other: String,
|
||||
req_body_json_doc: [{
|
||||
json_path: String, desc: String,required:{
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_other: String,
|
||||
res_body_type: {
|
||||
type: String,
|
||||
enum: ['json', 'text', 'xml']
|
||||
},
|
||||
res_body: String
|
||||
res_body: String,
|
||||
res_body_json_doc: [{
|
||||
json_path: String, desc: String,required:{
|
||||
type:String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ class projectModel extends baseModel {
|
||||
group_id: { type: Number, required: true },
|
||||
project_type: {type:String, required: true, enum: ['public', 'private']},
|
||||
members: [
|
||||
{uid: Number, role: {type: String, enum:['owner', 'dev'], username: String, email: String}}
|
||||
{uid: Number, role: {type: String, enum:['owner', 'dev']},username: String, email: String}
|
||||
],
|
||||
protocol: { type: String, required: true },
|
||||
prd_host: { type: String, required: true },
|
||||
@ -60,7 +60,7 @@ class projectModel extends baseModel {
|
||||
list(group_id, auth) {
|
||||
let params = {group_id: group_id}
|
||||
if(!auth) params.project_type = 'public';
|
||||
return this.model.find(params).sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type protocol prd_host env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
|
||||
listWithPaging(group_id, page, limit) {
|
||||
@ -111,7 +111,7 @@ class projectModel extends baseModel {
|
||||
{
|
||||
_id: id
|
||||
}, {
|
||||
$pull: { members: uid }
|
||||
$pull: { members: {uid: uid} }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -69,12 +69,12 @@ var interfaceController = function (_baseController) {
|
||||
* @param {String} [req_headers[].value] 请求的header信息值
|
||||
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
|
||||
* @param {String} [req_headers[].desc] header描述
|
||||
* @param {String} [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_params_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_params_form[].name] 请求参数名
|
||||
* @param {String} [req_params_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_params_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_params_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_body_form[].name] 请求参数名
|
||||
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_body_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
|
||||
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
|
||||
* @param {String} [desc] 接口描述
|
||||
@ -152,7 +152,7 @@ var interfaceController = function (_baseController) {
|
||||
desc: params.desc,
|
||||
method: params.method,
|
||||
req_headers: params.req_headers,
|
||||
req_params_type: params.req_params_type,
|
||||
req_body_type: params.req_body_type,
|
||||
res_body: params.res_body,
|
||||
res_body_type: params.res_body_type,
|
||||
uid: this.getUid(),
|
||||
@ -161,11 +161,11 @@ var interfaceController = function (_baseController) {
|
||||
};
|
||||
|
||||
|
||||
if (params.req_params_form) {
|
||||
data.req_params_form = params.req_params_form;
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params_other) {
|
||||
data.req_params_other = params.req_params_other;
|
||||
if (params.req_body_other) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
_context.next = 22;
|
||||
@ -337,12 +337,12 @@ var interfaceController = function (_baseController) {
|
||||
* @param {String} [req_headers[].value] 请求的header信息值
|
||||
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
|
||||
* @param {String} [req_headers[].desc] header描述
|
||||
* @param {String} [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_params_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_params_form[].name] 请求参数名
|
||||
* @param {String} [req_params_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_params_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_params_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
|
||||
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
|
||||
* @param {String} [req_body_form[].name] 请求参数名
|
||||
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
|
||||
* @param {String} [req_body_form[].type] 请求参数类型,有["text", "file"]两种
|
||||
* @param {String} [req_body_other] 非form类型的请求参数可保存到此字段
|
||||
* @param {String} [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
|
||||
* @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
|
||||
* @param {String} [desc] 接口描述
|
||||
@ -436,11 +436,11 @@ var interfaceController = function (_baseController) {
|
||||
data.req_headers = params.req_headers;
|
||||
}
|
||||
|
||||
if (params.req_params_form) {
|
||||
data.req_params_form = params.req_params_form;
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params_other) {
|
||||
data.req_params_other = params.req_params_other;
|
||||
if (params.req_body_other) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
if (params.res_body_type) {
|
||||
|
@ -75,36 +75,35 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var id, inst, result;
|
||||
var id, result;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_context.prev = 0;
|
||||
id = ctx.query.project_id;
|
||||
inst = _yapi2.default.getInst(_interfaceCol2.default);
|
||||
_context.next = 5;
|
||||
return inst.list(id);
|
||||
_context.next = 4;
|
||||
return this.colModel.list(id);
|
||||
|
||||
case 5:
|
||||
case 4:
|
||||
result = _context.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 12;
|
||||
_context.next = 11;
|
||||
break;
|
||||
|
||||
case 9:
|
||||
_context.prev = 9;
|
||||
case 8:
|
||||
_context.prev = 8;
|
||||
_context.t0 = _context['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 12:
|
||||
case 11:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[0, 9]]);
|
||||
}, _callee, this, [[0, 8]]);
|
||||
}));
|
||||
|
||||
function list(_x) {
|
||||
|
@ -1284,6 +1284,7 @@ var projectController = function (_baseController) {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
|
||||
|
@ -52,28 +52,55 @@ var interfaceModel = function (_baseModel) {
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
project_id: { type: Number, required: true },
|
||||
status: { type: String, enum: ['undone', 'done'], default: 'undone' },
|
||||
desc: String,
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
req_query: [{
|
||||
name: String, value: String, desc: String, required: Boolean
|
||||
name: String, value: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_headers: [{
|
||||
name: String, value: String, desc: String, required: Boolean
|
||||
name: String, value: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_params_type: {
|
||||
req_body_type: {
|
||||
type: String,
|
||||
enum: ['form', 'json', 'text', 'xml']
|
||||
enum: ['form', 'json', 'text', 'file']
|
||||
},
|
||||
req_params_form: [{
|
||||
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: Boolean
|
||||
req_body_form: [{
|
||||
name: String, value: String, value_type: { type: String, enum: ['text', 'file'] }, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_params_other: String,
|
||||
req_body_json_doc: [{
|
||||
json_path: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}],
|
||||
req_body_other: String,
|
||||
res_body_type: {
|
||||
type: String,
|
||||
enum: ['json', 'text', 'xml']
|
||||
},
|
||||
res_body: String
|
||||
res_body: String,
|
||||
res_body_json_doc: [{
|
||||
json_path: String, desc: String, required: {
|
||||
type: String,
|
||||
enum: ["1", "0"],
|
||||
default: "1"
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
}, {
|
||||
|
@ -53,7 +53,7 @@ var projectModel = function (_baseModel) {
|
||||
desc: String,
|
||||
group_id: { type: Number, required: true },
|
||||
project_type: { type: String, required: true, enum: ['public', 'private'] },
|
||||
members: [{ uid: Number, role: { type: String, enum: ['owner', 'dev'], username: String, email: String } }],
|
||||
members: [{ uid: Number, role: { type: String, enum: ['owner', 'dev'] }, username: String, email: String }],
|
||||
protocol: { type: String, required: true },
|
||||
prd_host: { type: String, required: true },
|
||||
env: [{ name: String, domain: String }],
|
||||
@ -101,7 +101,7 @@ var projectModel = function (_baseModel) {
|
||||
value: function list(group_id, auth) {
|
||||
var params = { group_id: group_id };
|
||||
if (!auth) params.project_type = 'public';
|
||||
return this.model.find(params).sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type protocol prd_host env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
@ -156,7 +156,7 @@ var projectModel = function (_baseModel) {
|
||||
return this.model.update({
|
||||
_id: id
|
||||
}, {
|
||||
$pull: { members: uid }
|
||||
$pull: { members: { uid: uid } }
|
||||
});
|
||||
}
|
||||
}, {
|
||||
|
@ -9,8 +9,6 @@
|
||||
<body>
|
||||
<div id="yapi" style="height: 100%;"></div>
|
||||
|
||||
|
||||
|
||||
<script src="http://127.0.0.1:4000/prd/manifest@dev.js"></script>
|
||||
<script src="http://127.0.0.1:4000/prd/lib2@dev.js"></script>
|
||||
<script src="http://127.0.0.1:4000/prd/lib@dev.js"></script>
|
||||
@ -20,7 +18,7 @@
|
||||
<script src="/lib/snippets-json.js"></script>
|
||||
<script src="/lib/ext-language.tools.js"></script>
|
||||
<script src="/lib/mode-json-1.2.8.js"></script>
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
|
||||
|
||||
|
||||
|
@ -406,7 +406,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -443,7 +443,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -541,7 +541,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -637,7 +637,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -725,7 +725,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -764,7 +764,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span>
|
||||
@ -855,7 +855,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" ><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" ><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -951,7 +951,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"logout success..."</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1436,7 +1436,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -1549,7 +1549,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#37" target="_blank">./server/controllers/project.js:37</a>
|
||||
<a href="./static/server/controllers/project.js.html#39" target="_blank">./server/controllers/project.js:39</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1661,7 +1661,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1702,7 +1702,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#127" target="_blank">./server/controllers/project.js:127</a>
|
||||
<a href="./static/server/controllers/project.js.html#137" target="_blank">./server/controllers/project.js:137</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1756,7 +1756,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1786,7 +1786,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#170" target="_blank">./server/controllers/project.js:170</a>
|
||||
<a href="./static/server/controllers/project.js.html#188" target="_blank">./server/controllers/project.js:188</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1840,7 +1840,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -1870,7 +1870,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#223" target="_blank">./server/controllers/project.js:223</a>
|
||||
<a href="./static/server/controllers/project.js.html#254" target="_blank">./server/controllers/project.js:254</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1912,7 +1912,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
@ -1948,7 +1948,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#248" target="_blank">./server/controllers/project.js:248</a>
|
||||
<a href="./static/server/controllers/project.js.html#279" target="_blank">./server/controllers/project.js:279</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1990,7 +1990,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2031,7 +2031,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#272" target="_blank">./server/controllers/project.js:272</a>
|
||||
<a href="./static/server/controllers/project.js.html#303" target="_blank">./server/controllers/project.js:303</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2073,7 +2073,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2258,7 +2258,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#313" target="_blank">./server/controllers/project.js:313</a>
|
||||
<a href="./static/server/controllers/project.js.html#344" target="_blank">./server/controllers/project.js:344</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2300,7 +2300,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2330,7 +2330,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#373" target="_blank">./server/controllers/project.js:373</a>
|
||||
<a href="./static/server/controllers/project.js.html#419" target="_blank">./server/controllers/project.js:419</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2448,7 +2448,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
|
||||
<span class="token comment" spellcheck="true">//请求示例</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"id"</span><span class="token punctuation">:</span> <span class="token number">8</span><span class="token punctuation">,</span>
|
||||
@ -2490,7 +2490,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#464" target="_blank">./server/controllers/project.js:464</a>
|
||||
<a href="./static/server/controllers/project.js.html#520" target="_blank">./server/controllers/project.js:520</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2532,7 +2532,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"ok"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -2585,7 +2585,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#519" target="_blank">./server/controllers/project.js:519</a>
|
||||
<a href="./static/server/controllers/project.js.html#575" target="_blank">./server/controllers/project.js:575</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2868,7 +2868,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code">
|
||||
<span class="token comment" spellcheck="true">//请求 /interface/add</span>
|
||||
<span class="token comment" spellcheck="true">//header Content-Type:application/json</span>
|
||||
|
||||
@ -3003,7 +3003,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span><span class="token keyword">get</span><span class="token punctuation">.</span>json</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3068,7 +3068,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">.</span><span class="token operator">/</span>api<span class="token operator">/</span><span class="token keyword">interface</span><span class="token operator">/</span>list<span class="token punctuation">.</span>json</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3293,7 +3293,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -3366,7 +3366,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token punctuation">{</span>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token punctuation">{</span>
|
||||
<span class="token string">"errcode"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"errmsg"</span><span class="token punctuation">:</span> <span class="token string">"success"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"data"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
@ -3461,7 +3461,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>list</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3526,7 +3526,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>del</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -3536,7 +3536,7 @@
|
||||
<h3 id="-follow-add" class="page-header subject">
|
||||
/follow/add
|
||||
|
||||
<span class="ui-badge">POST</span>
|
||||
<span class="ui-badge">GET</span>
|
||||
|
||||
|
||||
<a class="hashlink" href="#-follow-add">#</a>
|
||||
@ -3627,7 +3627,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>follow<span class="token operator">/</span>add</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -4344,9 +4344,9 @@
|
||||
</thead>
|
||||
|
||||
<tr>
|
||||
<td>uid</td>
|
||||
<td>typeid</td>
|
||||
<td>Number</td>
|
||||
<td>用户id, 不能为空</td>
|
||||
<td>动态类型id, 不能为空</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
@ -4380,7 +4380,7 @@
|
||||
|
||||
|
||||
<div>示例:</div>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
|
||||
<pre class="ydoc-example" data-foldnumber=10><code class="js-code"><span class="token operator">/</span>log<span class="token operator">/</span>list</code></pre>
|
||||
|
||||
|
||||
</div>
|
||||
@ -4435,8 +4435,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -4444,7 +4444,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -175,8 +175,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -184,7 +184,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -68,23 +68,23 @@
|
||||
<div class="ydoc-container-content " id="readme">
|
||||
|
||||
<article class="markdown-body">
|
||||
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1 接口管理架构">1 接口管理架构 <a class="hashlink" href="#1 接口管理架构">#</a></h3><p>平台以<strong>项目分组</strong> -> <strong>项目</strong> -> <strong>接口</strong>的划分进行接口组织管理。</p>
|
||||
<h2 class="subject" id="快速开始">快速开始 <a class="hashlink" href="#快速开始">#</a></h2><h3 class="subject" id="1_接口管理架构">1 接口管理架构 <a class="hashlink" href="#1_接口管理架构">#</a></h3><p>平台以<strong>项目分组</strong> -> <strong>项目</strong> -> <strong>接口</strong>的划分进行接口组织管理。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-305ba49a60ee1ff5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<h4 class="subject" id="1.1 项目分组">1.1 项目分组 <a class="hashlink" href="#1.1 项目分组">#</a></h4><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
|
||||
<h4 class="subject" id="1.1_项目分组">1.1 项目分组 <a class="hashlink" href="#1.1_项目分组">#</a></h4><p>登录之后进到项目首页,左边侧边栏显示的即分组列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-d90ca4b3242fa760.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "200" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>管理员有权限添加或删除分组。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-a0d4d9a98003896a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "500" style="margin-left:170px;display:block;" alt="图片名称" align=center /></p>
|
||||
<blockquote>
|
||||
<p>分组名称具有唯一性</p>
|
||||
</blockquote>
|
||||
<h4 class="subject" id="1.2 项目">1.2 项目 <a class="hashlink" href="#1.2 项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
|
||||
<h4 class="subject" id="1.2_项目">1.2 项目 <a class="hashlink" href="#1.2_项目">#</a></h4><p>选中不同的分组,右边会显示该分组下的项目列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-137bcae58b84715e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>创建项目需要填写项目名称,项目线上域名(添加完成后可配置项目其他环境域名),项目接口基本路径(接口路径前面相同的部分)以及项目描述。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-360a50ddb746f73d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<blockquote>
|
||||
<p>项目『线上域名 + 基本路径』具有唯一性</p>
|
||||
</blockquote>
|
||||
<h4 class="subject" id="1.3 接口">1.3 接口 <a class="hashlink" href="#1.3 接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
|
||||
<h4 class="subject" id="1.3_接口">1.3 接口 <a class="hashlink" href="#1.3_接口">#</a></h4><p>点击项目名称,进入该项目接口列表。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-e858005f714f4889.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p>点击编辑,进入接口详情页(之后接口详情页和编辑也会分开),可以编辑接口或者请求测试真实接口。</p>
|
||||
<p><img src="http://upload-images.jianshu.io/upload_images/842107-78c0ea839619d068.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
@ -134,8 +134,8 @@
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -143,7 +143,7 @@
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -70,7 +70,7 @@
|
||||
<article class="markdown-body">
|
||||
<h2 class="subject" id="Mock功能">Mock功能 <a class="hashlink" href="#Mock功能">#</a></h2> <p style='text-indent:2em;line-height:1.8em'>yapi的Mock功能可以根据用户的输入接口信息如协议、URL、接口名、请求头、请求参数、mock规则(<a href="#mock">点击到Mock规则</a>)生成Mock接口,这些接口会自动生成模拟数据,支持复杂的生成逻辑,创建者可以自由构造需要的数据。而且与常见的Mock方式如将Mock写在代码里和JS拦截等相比yapi的Mock在使用场景和效率和复杂度上是相差甚远的,正是由于yapi的Mock是一个第三方平台那么在 团队开发时任何人都可以权限许可下创建、修改接口信息等操作,这对于团队开发是很有好处的。</p>
|
||||
|
||||
<h3 class="subject" id="1 Mock步骤">1 Mock步骤 <a class="hashlink" href="#1 Mock步骤">#</a></h3><h4 class="subject" id="1.1 创建接口">1.1 创建接口 <a class="hashlink" href="#1.1 创建接口">#</a></h4><p>通过点击页面上的"+添加接口"</p>
|
||||
<h3 class="subject" id="1_Mock步骤">1 Mock步骤 <a class="hashlink" href="#1_Mock步骤">#</a></h3><h4 class="subject" id="1.1_创建接口">1.1 创建接口 <a class="hashlink" href="#1.1_创建接口">#</a></h4><p>通过点击页面上的"+添加接口"</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB613bd4f29db038f2b41c03dcfceda2b6?method=download&shareKey=29bfc2b855f6f26ce0079baf567e54cc" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p> 输入协议、URL、接口名、请求头、请求参数、Mock规则(<a href="#mock">点击到Mock规则</a>)等信息。</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB680a37ba304768804b23cf2cf36ed40d?method=download&shareKey=0d750695dce3a4c7abf697fa58d24c57" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
@ -84,14 +84,14 @@
|
||||
<p>取到上面的链接在浏览器中请求就可以得到如下结果。</p>
|
||||
<p><img src="http://note.youdao.com/yws/api/personal/file/WEB1d1f7dc7b83a8cd6f576953cf45e9719?method=download&shareKey=99b4af9baac527b969543dd0a909d2a1" width = "800" style="margin:0px auto;display:block;" alt="图片名称" align=center /></p>
|
||||
<p><span id = "mock"></span></p>
|
||||
<h3 class="subject" id="2.1 Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1 Mock语法规范">#</a></h3><blockquote>
|
||||
<h3 class="subject" id="2.1_Mock语法规范">2.1 Mock语法规范 <a class="hashlink" href="#2.1_Mock语法规范">#</a></h3><blockquote>
|
||||
<p>了解更多Mock详情:<a href="https://github.com/nuysoft/Mock/wiki/Syntax-Specification">Mock.js 官方文档</a></p>
|
||||
</blockquote>
|
||||
<p>Mock.js 的语法规范包括两部分:</p>
|
||||
<p><a href="#DTD">1. 数据模板定义规范(Data Template Definition,DTD)</a></p>
|
||||
<p><a href="#DPD">2. 数据占位符定义规范(Data Placeholder Definition,DPD)</a></p>
|
||||
<p><span id = "DTD"></span></p>
|
||||
<h3 class="subject" id="数据模板定义规范(Data Template Definition,DTD)">数据模板定义规范(Data Template Definition,DTD) <a class="hashlink" href="#数据模板定义规范(Data Template Definition,DTD)">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
|
||||
<h3 class="subject" id="数据模板定义规范(Data_Template_Definition,DTD)">数据模板定义规范(Data Template Definition,DTD) <a class="hashlink" href="#数据模板定义规范(Data_Template_Definition,DTD)">#</a></h3><p>数据模板中的每个属性由 3 部分构成:属性名、生成规则、属性值:</p>
|
||||
<pre><code>// 属性名 name (与生成规则之间用 "|<span class="token string">" 隔开)
|
||||
// 生成规则 rule(生成规则有7种详见下面的生成规则)
|
||||
// 属性值 value(可以含有 "</span>@占位符" 同时也指定了最终值的初始值和类型)
|
||||
@ -107,14 +107,14 @@
|
||||
'name|count.dcount'<span class="token operator">:</span> value
|
||||
'name|+step'<span class="token operator">:</span> value
|
||||
</code></pre><p>下面提供了6种生成规则以及示例包括 String、Number、Boolean、Object、Array:</p>
|
||||
<h4 class="subject" id="1. 属性值是字符串 String">1. 属性值是字符串 String <a class="hashlink" href="#1. 属性值是字符串 String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
|
||||
<h4 class="subject" id="1._属性值是字符串_String">1. 属性值是字符串 String <a class="hashlink" href="#1._属性值是字符串_String">#</a></h4><pre><code><span class="token number">1</span>. 'name|min-max'<span class="token operator">:</span> string
|
||||
|
||||
通过重复 string 生成一个字符串,重复次数大于等于 min,小于等于 max。
|
||||
|
||||
<span class="token number">2</span>. 'name|count'<span class="token operator">:</span> string
|
||||
|
||||
通过重复 string 生成一个字符串,重复次数等于 count。
|
||||
</code></pre><h4 class="subject" id="2. 属性值是数字 Number">2. 属性值是数字 Number <a class="hashlink" href="#2. 属性值是数字 Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
|
||||
</code></pre><h4 class="subject" id="2._属性值是数字_Number">2. 属性值是数字 Number <a class="hashlink" href="#2._属性值是数字_Number">#</a></h4><pre><code><span class="token number">1</span>. 'name|+<span class="token number">1</span>'<span class="token operator">:</span> number
|
||||
|
||||
属性值自动加 <span class="token number">1</span>,初始值为 number。
|
||||
|
||||
@ -140,21 +140,21 @@ Mock.mock(<span class="token punctuation">{</span>
|
||||
<span class="token property">"number3"</span><span class="token operator">:</span> <span class="token number">123.777</span><span class="token punctuation">,</span>
|
||||
<span class="token property">"number4"</span><span class="token operator">:</span> <span class="token number">123.1231091814</span>
|
||||
<span class="token punctuation">}</span>
|
||||
</code></pre><h4 class="subject" id="3. 属性值是布尔型 Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3. 属性值是布尔型 Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
|
||||
</code></pre><h4 class="subject" id="3._属性值是布尔型_Boolean">3. 属性值是布尔型 Boolean <a class="hashlink" href="#3._属性值是布尔型_Boolean">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> boolean
|
||||
|
||||
随机生成一个布尔值,值为 <span class="token boolean">true</span> 的概率是 <span class="token number">1</span>/<span class="token number">2</span>,值为 <span class="token boolean">false</span> 的概率同样是 <span class="token number">1</span>/<span class="token number">2</span>。
|
||||
|
||||
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> value
|
||||
|
||||
随机生成一个布尔值,值为 value 的概率是 min / (min + max<span class="token punctuation">)</span>,值为 !value 的概率是 max / (min + max<span class="token punctuation">)</span>。
|
||||
</code></pre><h4 class="subject" id="4. 属性值是对象 Object">4. 属性值是对象 Object <a class="hashlink" href="#4. 属性值是对象 Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
|
||||
</code></pre><h4 class="subject" id="4._属性值是对象_Object">4. 属性值是对象 Object <a class="hashlink" href="#4._属性值是对象_Object">#</a></h4><pre><code><span class="token number">1</span>. 'name|count'<span class="token operator">:</span> object
|
||||
|
||||
从属性值 object 中随机选取 count 个属性。
|
||||
|
||||
<span class="token number">2</span>. 'name|min-max'<span class="token operator">:</span> object
|
||||
|
||||
从属性值 object 中随机选取 min 到 max 个属性。
|
||||
</code></pre><h4 class="subject" id="5. 属性值是数组 Array">5. 属性值是数组 Array <a class="hashlink" href="#5. 属性值是数组 Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
|
||||
</code></pre><h4 class="subject" id="5._属性值是数组_Array">5. 属性值是数组 Array <a class="hashlink" href="#5._属性值是数组_Array">#</a></h4><pre><code><span class="token number">1</span>. 'name|<span class="token number">1</span>'<span class="token operator">:</span> array
|
||||
|
||||
从属性值 array 中随机选取 <span class="token number">1</span> 个元素,作为最终值。
|
||||
|
||||
@ -170,7 +170,7 @@ Mock.mock(<span class="token punctuation">{</span>
|
||||
|
||||
通过重复属性值 array 生成一个新数组,重复次数为 count。
|
||||
</code></pre><p><span id = "DPD"></span></p>
|
||||
<h3 class="subject" id="数据占位符定义规范(Data Placeholder Definition,DPD)">数据占位符定义规范(Data Placeholder Definition,DPD) <a class="hashlink" href="#数据占位符定义规范(Data Placeholder Definition,DPD)">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
|
||||
<h3 class="subject" id="数据占位符定义规范(Data_Placeholder_Definition,DPD)">数据占位符定义规范(Data Placeholder Definition,DPD) <a class="hashlink" href="#数据占位符定义规范(Data_Placeholder_Definition,DPD)">#</a></h3><pre><code>占位符 只是在属性值字符串中占个位置,并不出现在最终的属性值中。
|
||||
|
||||
占位符 的格式为:
|
||||
|
||||
@ -240,8 +240,8 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
|
||||
var $this = $(this);
|
||||
$this.removeClass('extend').addClass('fold');
|
||||
$this.html('折叠代码');
|
||||
$this.prev().height('auto');
|
||||
$this.prev().parent().height('auto');
|
||||
$this.parent().children('.js-code').height('auto');
|
||||
$this.parent().height('auto');
|
||||
});
|
||||
$('.ydoc-example').delegate('.fold', 'click', function() {
|
||||
var $this = $(this);
|
||||
@ -249,7 +249,7 @@ name<span class="token operator">:</span> <span class="token punctuation">{</spa
|
||||
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
|
||||
$this.removeClass('fold').addClass('extend');
|
||||
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
|
||||
$this.prev().height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
|
||||
$this.html("展开更多……");
|
||||
});
|
||||
}
|
||||
|
@ -129,7 +129,8 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
$('.markdown-body pre').map(function(i, item) {
|
||||
$(item).addClass('ydoc-example');
|
||||
$(item).addClass('ydoc-example').append('<div class="ui-copy js-copy" data-clipboard-action="copy" data-clipboard-target=".js-code-' + i + '" data-copy-number="' + i + '">copy</div><div class="copy-tip copy-tip-' + i + '">已复制</div>');
|
||||
$(item).children('code').addClass('js-code-'+i);
|
||||
});
|
||||
|
||||
var winHeight = $(window).height() - 44,
|
||||
@ -213,4 +214,17 @@ $(document).ready(function() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 代码复制功能
|
||||
var clipboard = new Clipboard('.js-copy');
|
||||
|
||||
clipboard.on('success', function(e) {
|
||||
var copyNumber = $(e.trigger).attr('data-copy-number');
|
||||
$('.copy-tip-'+copyNumber).show();
|
||||
setTimeout(function() {
|
||||
$('.copy-tip-'+copyNumber).hide();
|
||||
}, 1000);
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
});
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -106,6 +106,9 @@ class baseController {
|
||||
return this.$user.role;
|
||||
}
|
||||
|
||||
getUsername() {
|
||||
return this.$user.username;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} id type对应的id
|
||||
|
@ -114,7 +114,7 @@ class followController extends baseController {
|
||||
/**
|
||||
* 添加关注
|
||||
* @interface /follow/add
|
||||
* @method POST
|
||||
* @method GET
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id
|
||||
@ -131,7 +131,8 @@ class followController extends baseController {
|
||||
uid: 'number',
|
||||
projectid: 'number',
|
||||
projectname: 'string',
|
||||
icon: 'string'
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (!params.uid) {
|
||||
@ -153,17 +154,22 @@ class followController extends baseController {
|
||||
if (!params.icon) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目图标标志不能为空');
|
||||
}
|
||||
if (!params.color) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目颜色不能为空');
|
||||
}
|
||||
|
||||
let data = {
|
||||
uid: params.uid,
|
||||
projectid: params.projectid,
|
||||
projectname: params.projectname,
|
||||
icon: params.icon
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
|
||||
};
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon']);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon', 'color']);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
14
static/doc/static/server/controllers/log.js.html
vendored
14
static/doc/static/server/controllers/log.js.html
vendored
@ -59,7 +59,7 @@ class logController extends baseController {
|
||||
* @method GET
|
||||
* @category log
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id, 不能为空
|
||||
* @param {Number} typeid 动态类型id, 不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @returns {Object}
|
||||
@ -69,15 +69,17 @@ class logController extends baseController {
|
||||
async list(ctx) {
|
||||
let typeid = ctx.request.query.typeid,
|
||||
page = ctx.request.query.page || 1,
|
||||
limit = ctx.request.query.limit || 10;
|
||||
|
||||
limit = ctx.request.query.limit || 10,
|
||||
type = ctx.request.query.type;
|
||||
if (!typeid) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'typeid不能为空');
|
||||
}
|
||||
|
||||
if(!type) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.listWithPaging(typeid, page, limit);
|
||||
let count = await this.Model.listCount(typeid);
|
||||
let result = await this.Model.listWithPaging(typeid,type, page, limit);
|
||||
let count = await this.Model.listCount(typeid,type);
|
||||
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: Math.ceil(count / limit),
|
||||
|
@ -32,6 +32,7 @@ import interfaceModel from '../models/interface.js';
|
||||
import groupModel from '../models/group';
|
||||
import commons from '../utils/commons.js';
|
||||
import userModel from '../models/user.js';
|
||||
import logModel from '../models/log.js';
|
||||
import Mock from 'mockjs';
|
||||
const send = require('koa-send');
|
||||
|
||||
@ -41,6 +42,7 @@ class projectController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(projectModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
this.logModel = yapi.getInst(logModel);
|
||||
}
|
||||
|
||||
handleBasepath(basepath) {
|
||||
@ -146,6 +148,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -189,6 +199,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
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);
|
||||
@ -226,6 +244,19 @@ 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);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${i.username}`,
|
||||
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);
|
||||
@ -392,6 +423,21 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}修改了项目${project.name}中成员${i.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,6 +529,16 @@ class projectController extends baseController {
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -550,6 +606,7 @@ class projectController extends baseController {
|
||||
* @method GET
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @author wenbo.dong
|
||||
* @param {String} project_id
|
||||
*/
|
||||
async download(ctx) {
|
||||
|
Loading…
Reference in New Issue
Block a user