mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
a02b4e585a
@ -3,6 +3,37 @@ import PropTypes from 'prop-types';
|
||||
import { AutoComplete } from 'antd';
|
||||
import axios from 'axios';
|
||||
|
||||
/**
|
||||
* 用户名输入框自动完成组件
|
||||
*
|
||||
* @component UsernameAutoComplete
|
||||
* @examplelanguage js
|
||||
*
|
||||
* * 用户名输入框自动完成组件
|
||||
* * 用户名输入框自动完成组件
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* 获取自动输入的用户信息
|
||||
*
|
||||
* 获取子组件state
|
||||
* @property callbackState
|
||||
* @type function
|
||||
* @description 类型提示:支持数组传值;也支持用函数格式化字符串:函数有两个参数(scale, index);
|
||||
* 受控属性:滑块滑到某一刻度时所展示的刻度文本信息。如果不需要标签,请将该属性设置为 [] 空列表来覆盖默认转换函数。
|
||||
* @returns {object} {uid: xxx, username: xxx}
|
||||
* @examplelanguage js
|
||||
* @example
|
||||
* onUserSelect(childState) {
|
||||
* this.setState({
|
||||
* uid: childState.uid,
|
||||
* username: childState.username
|
||||
* })
|
||||
* }
|
||||
*
|
||||
*/
|
||||
class UsernameAutoComplete extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { message, Row, Col } from 'antd';
|
||||
import { message, Row, Col, Icon } from 'antd';
|
||||
import { addProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../reducer/modules/project';
|
||||
import ProjectCard from '../../../components/ProjectCard/ProjectCard.js';
|
||||
// import variable from '../../../constants/variable';
|
||||
@ -26,52 +26,6 @@ import './ProjectList.scss'
|
||||
// return handle;
|
||||
// };
|
||||
|
||||
// const getColumns = (data, props) => {
|
||||
// const { changeUpdateModal, userInfo } = props;
|
||||
// return [{
|
||||
// title: '项目名称',
|
||||
// dataIndex: 'name',
|
||||
// key: 'name',
|
||||
// render: (text, record) => {
|
||||
// return <Link to={`/project/${record._id}`}>{text}</Link>
|
||||
// }
|
||||
// },{
|
||||
// title: 'Mock基本URL',
|
||||
// key: 'domain',
|
||||
// render: (item) => {
|
||||
// return 'http://'+ item.prd_host + item.basepath;
|
||||
// }
|
||||
//
|
||||
// }, {
|
||||
// title: '创建人',
|
||||
// dataIndex: 'owner',
|
||||
// key: 'owner',
|
||||
// render: (text, record, index) => {
|
||||
// // data是projectList的列表值
|
||||
// // 根据序号找到对应项的uid,根据uid获取对应项目的创建人
|
||||
// return <span>{userInfo[data[index].uid] ? userInfo[data[index].uid].username : ''}</span>;
|
||||
// }
|
||||
// }, {
|
||||
// title: '创建时间',
|
||||
// dataIndex: 'add_time',
|
||||
// key: 'add_time',
|
||||
// render: time => <span>{common.formatTime(time)}</span>
|
||||
// }, {
|
||||
// title: '操作',
|
||||
// key: 'action',
|
||||
// render: (text, record, index) => {
|
||||
// const id = record._id;
|
||||
// return (
|
||||
// <span>
|
||||
// <a onClick={() => changeUpdateModal(true, index)}>修改</a>
|
||||
// <span className="ant-divider" />
|
||||
// <Popconfirm title="你确定要删除项目吗?" onConfirm={deleteConfirm(id, props)} okText="确定" cancelText="取消">
|
||||
// <a href="#">删除</a>
|
||||
// </Popconfirm>
|
||||
// </span>
|
||||
// )}
|
||||
// }];
|
||||
// }
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
@ -180,12 +134,15 @@ class ProjectList extends Component {
|
||||
return (
|
||||
<div className="m-panel">
|
||||
<Row gutter={16}>
|
||||
{projectData.map((item, index) => {
|
||||
{projectData.length ? projectData.map((item, index) => {
|
||||
return (
|
||||
<Col span={8} key={index}>
|
||||
<ProjectCard projectData={item} />
|
||||
</Col>);
|
||||
})}
|
||||
}) : (<div className="empty-tip">
|
||||
<p><Icon type="frown-o" /> 该分组还没有项目呢</p>
|
||||
<p>请点击右上角 “<Icon type="plus-circle" />” 按钮新建项目</p>
|
||||
</div>)}
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
|
@ -31,3 +31,9 @@
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.empty-tip {
|
||||
text-align: center;
|
||||
font-size: .14rem;
|
||||
color: #999;
|
||||
}
|
||||
|
@ -42,20 +42,18 @@ class Activity extends Component {
|
||||
}
|
||||
render () {
|
||||
return (
|
||||
<div>
|
||||
<div className="g-row">
|
||||
<section className="news-box">
|
||||
<div className="logHead">
|
||||
{/*<Breadcrumb />*/}
|
||||
<div className="Mockurl">
|
||||
<span>Mock地址:</span>
|
||||
<p>{this.state.mockURL}</p>
|
||||
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
|
||||
</div>
|
||||
<div className="g-row">
|
||||
<section className="news-box">
|
||||
<div className="logHead">
|
||||
{/*<Breadcrumb />*/}
|
||||
<div className="Mockurl">
|
||||
<span>Mock地址:</span>
|
||||
<p>{this.state.mockURL}</p>
|
||||
<Button type="primary"><a href = {`/api/project/download?project_id=${this.props.match.params.id}`}>下载Mock数据</a></Button>
|
||||
</div>
|
||||
<TimeTree typeid = {+this.props.match.params.id} />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<TimeTree typeid = {+this.props.match.params.id} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
font-size: 0.14rem;
|
||||
background: #FFF;
|
||||
display: block;
|
||||
min-height: 550px;
|
||||
|
||||
.news-timeline{
|
||||
padding: 24px;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Timeline, Spin } from 'antd'
|
||||
import { Timeline, Spin, Avatar } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { formatTime } from '../../../../common.js';
|
||||
@ -58,7 +58,8 @@ function timeago(timestamp) {
|
||||
state => {
|
||||
return {
|
||||
newsData: state.news.newsData,
|
||||
curpage: state.news.curpage
|
||||
curpage: state.news.curpage,
|
||||
curUid: state.user.uid
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -75,7 +76,8 @@ class TimeTree extends Component {
|
||||
setLoading: PropTypes.func,
|
||||
loading: PropTypes.bool,
|
||||
curpage: PropTypes.number,
|
||||
typeid: PropTypes.number
|
||||
typeid: PropTypes.number,
|
||||
curUid: PropTypes.number
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -109,8 +111,9 @@ class TimeTree extends Component {
|
||||
render() {
|
||||
let data = this.props.newsData ? this.props.newsData.list : [];
|
||||
if (data && data.length) {
|
||||
|
||||
data = data.map(function (item, i) {
|
||||
return (<Timeline.Item key={i}>
|
||||
return (<Timeline.Item dot={<Avatar src={`/api/user/avatar?uid=${item.uid}`} />} key={i}>
|
||||
<span className="logoTimeago">{timeago(item.add_time)}</span>
|
||||
<span className="logusername"><Link to={`/user/profile/${item.uid}`}>{item.username}</Link></span>
|
||||
<span className="logtype">{item.type}</span>
|
||||
|
@ -1,11 +1,12 @@
|
||||
import React,{Component} from 'react'
|
||||
import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux';
|
||||
import InterfaceEditForm from './InterfaceEditForm.js'
|
||||
import { updateInterfaceData } from '../../../../reducer/modules/interface.js';
|
||||
import axios from 'axios'
|
||||
import {message} from 'antd'
|
||||
import { message } from 'antd'
|
||||
import './Edit.scss'
|
||||
import { withRouter, Link } from 'react-router-dom';
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
@ -13,64 +14,93 @@ import './Edit.scss'
|
||||
curdata: state.inter.curdata,
|
||||
currProject: state.project.currProject
|
||||
}
|
||||
},{
|
||||
}, {
|
||||
updateInterfaceData
|
||||
}
|
||||
)
|
||||
|
||||
class InterfaceEdit extends Component{
|
||||
class InterfaceEdit extends Component {
|
||||
static propTypes = {
|
||||
curdata: PropTypes.object,
|
||||
currProject:PropTypes.object,
|
||||
updateInterfaceData: PropTypes.func
|
||||
currProject: PropTypes.object,
|
||||
updateInterfaceData: PropTypes.func,
|
||||
match: PropTypes.object
|
||||
}
|
||||
|
||||
constructor(props){
|
||||
constructor(props) {
|
||||
super(props)
|
||||
const {curdata, currProject} = this.props;
|
||||
const { curdata, currProject } = this.props;
|
||||
this.state = {
|
||||
mockUrl: location.protocol + '//' + location.hostname + (location.port !== "" ? ":" + location.port : "") + `/mock/${currProject._id}${currProject.basepath}${curdata.path}`
|
||||
mockUrl: location.protocol + '//' + location.hostname + (location.port !== "" ? ":" + location.port : "") + `/mock/${currProject._id}${currProject.basepath}${curdata.path}`,
|
||||
curdata: {},
|
||||
status: 0
|
||||
}
|
||||
}
|
||||
|
||||
onSubmit =async (params)=>{
|
||||
onSubmit = async (params) => {
|
||||
params.id = params._id = this.props.curdata._id;
|
||||
let result =await axios.post('/api/interface/up', params);
|
||||
if(result.data.errcode === 0){
|
||||
let result = await axios.post('/api/interface/up', params);
|
||||
if (result.data.errcode === 0) {
|
||||
this.props.updateInterfaceData(params);
|
||||
message.success('保存成功');
|
||||
}else{
|
||||
} else {
|
||||
message.success(result.data.errmsg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount(){
|
||||
let s = new WebSocket('ws://yapi.local.qunar.com:3000/api/interface/solve_conflict?id=1');
|
||||
s.onopen = (e)=>{
|
||||
console.log('open',e)
|
||||
s.send('abc')
|
||||
componentWillUnmount(){
|
||||
console.log('unmount')
|
||||
try{
|
||||
if(this.state.status === 1){
|
||||
this.WebSocket.close()
|
||||
}
|
||||
}catch(e){
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
let s = new WebSocket('ws://yapi.local.qunar.com:3000/api/interface/solve_conflict?id=' + this.props.match.params.actionId);
|
||||
s.onopen = () => {
|
||||
this.WebSocket = s;
|
||||
}
|
||||
|
||||
s.onclose = (e)=>{
|
||||
console.log('close',e)
|
||||
}
|
||||
s.onmessage = (e) => {
|
||||
let result = JSON.parse(e.data);
|
||||
if (result.errno === 0) {
|
||||
this.setState({
|
||||
curdata: result.data,
|
||||
status: 1
|
||||
})
|
||||
} else {
|
||||
this.setState({
|
||||
curdata: result.data,
|
||||
status: 2
|
||||
})
|
||||
}
|
||||
|
||||
s.onmessage = (e)=>{
|
||||
console.log('message',e)
|
||||
}
|
||||
|
||||
s.onerror = (e)=>{
|
||||
console.log('error',e)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
render(){
|
||||
render() {
|
||||
console.log(this.state.status)
|
||||
return <div className="interface-edit">
|
||||
<InterfaceEditForm mockUrl={this.state.mockUrl} basepath={this.props.currProject.basepath} onSubmit={this.onSubmit} curdata={this.props.curdata} />
|
||||
{this.state.status === 1 ?
|
||||
<InterfaceEditForm mockUrl={this.state.mockUrl} basepath={this.props.currProject.basepath} onSubmit={this.onSubmit} curdata={this.state.curdata} />
|
||||
:
|
||||
null}
|
||||
{
|
||||
this.state.status === 2 ?
|
||||
<div style={{textAlign: 'center', fontSize: '14px', paddingTop: '10px'}}>
|
||||
<Link to={'/user/profile/' + this.state.curdata.uid}><b>{this.state.curdata.username}</b></Link>
|
||||
<span>正在编辑该接口,请稍后再试...</span>
|
||||
</div>
|
||||
:
|
||||
null}
|
||||
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
export default InterfaceEdit;
|
||||
export default withRouter(InterfaceEdit);
|
@ -219,7 +219,7 @@ class View extends Component {
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
return <div className="caseContainer">
|
||||
return this.props.curData.title?<div className="caseContainer">
|
||||
<div className="colName">
|
||||
<span className="colKey">接口名:</span>
|
||||
<span className="colValue">{this.props.curData.title}</span>
|
||||
@ -271,7 +271,7 @@ class View extends Component {
|
||||
desc: "123",
|
||||
required: 0
|
||||
}])}*/}
|
||||
</div>
|
||||
</div>:<div className="caseContainer">接口不存在</div>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import { Subnav } from '../../components/index'
|
||||
import { getProject } from '../../reducer/modules/project';
|
||||
import Interface from './Interface/Interface.js'
|
||||
import Activity from './Activity/Activity.js'
|
||||
import { Setting } from './Setting/Setting.js'
|
||||
import Setting from './Setting/Setting.js'
|
||||
|
||||
|
||||
@connect(
|
||||
|
@ -0,0 +1,359 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Form, Input, Icon, Tooltip, Select, Button, Row, Col, message } from 'antd';
|
||||
import PropTypes from 'prop-types';
|
||||
import { updateProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../reducer/modules/project';
|
||||
import { connect } from 'react-redux';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
|
||||
// layout
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
lg: { span: 3 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
lg: { span: 21 },
|
||||
xs: { span: 24 },
|
||||
sm: { span: 14 }
|
||||
},
|
||||
className: 'form-item'
|
||||
};
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: { span: 24, offset: 0 },
|
||||
sm: { span: 20, offset: 6 }
|
||||
}
|
||||
};
|
||||
let uuid = 0;
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
handleUpdateIndex: state.project.handleUpdateIndex,
|
||||
tableLoading: state.project.tableLoading,
|
||||
currGroup: state.group.currGroup
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchProjectList,
|
||||
updateProject,
|
||||
delProject,
|
||||
changeUpdateModal,
|
||||
changeTableLoading
|
||||
}
|
||||
)
|
||||
class Setting extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
protocol: 'http:\/\/',
|
||||
envProtocolChange: 'http:\/\/'
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
form: PropTypes.object,
|
||||
fetchProjectList: PropTypes.func,
|
||||
updateProject: PropTypes.func,
|
||||
delProject: PropTypes.func,
|
||||
changeUpdateModal: PropTypes.func,
|
||||
changeTableLoading: PropTypes.func,
|
||||
projectList: PropTypes.array,
|
||||
currGroup: PropTypes.object,
|
||||
handleUpdateIndex: PropTypes.number
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
this.setState({
|
||||
protocol: value
|
||||
})
|
||||
}
|
||||
|
||||
handleCancel = () => {
|
||||
this.props.form.resetFields();
|
||||
this.props.changeUpdateModal(false, -1);
|
||||
}
|
||||
|
||||
// 确认修改
|
||||
handleOk = (e) => {
|
||||
e.preventDefault();
|
||||
const { form, updateProject, changeUpdateModal, currGroup, projectList, handleUpdateIndex, fetchProjectList, changeTableLoading } = this.props;
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
// console.log(projectList[handleUpdateIndex]);
|
||||
let assignValue = Object.assign(projectList[handleUpdateIndex], values);
|
||||
values.protocol = this.state.protocol.split(':')[0];
|
||||
assignValue.env = assignValue.envs.map((item, index) => {
|
||||
return {
|
||||
name: values['envs-name-' + index],
|
||||
domain: values['envs-protocol-' + index] + values['envs-domain-' + index]
|
||||
}
|
||||
});
|
||||
// console.log(assignValue);
|
||||
|
||||
changeTableLoading(true);
|
||||
updateProject(assignValue).then((res) => {
|
||||
if (res.payload.data.errcode == 0) {
|
||||
changeUpdateModal(false, -1);
|
||||
message.success('修改成功! ');
|
||||
fetchProjectList(currGroup._id).then(() => {
|
||||
changeTableLoading(false);
|
||||
});
|
||||
} else {
|
||||
changeTableLoading(false);
|
||||
message.error(res.payload.data.errmsg);
|
||||
}
|
||||
}).catch(() => {
|
||||
changeTableLoading(false);
|
||||
});
|
||||
form.resetFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 删除一项环境配置
|
||||
remove = (id) => {
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
// We need at least one passenger
|
||||
if (envs.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// can use data-binding to set
|
||||
form.setFieldsValue({
|
||||
envs: envs.filter(key => {
|
||||
const realKey = key._id ? key._id : key
|
||||
return realKey !== id;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 项目的修改操作 - 添加一项环境配置
|
||||
add = () => {
|
||||
uuid++;
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
const nextKeys = envs.concat(uuid);
|
||||
// can use data-binding to set
|
||||
// important! notify form to detect changes
|
||||
form.setFieldsValue({
|
||||
envs: nextKeys
|
||||
});
|
||||
}
|
||||
|
||||
render () {
|
||||
const { getFieldDecorator, getFieldValue } = this.props.form;
|
||||
// const that = this;
|
||||
const { projectList, handleUpdateIndex } = this.props;
|
||||
console.log(this.props);
|
||||
let initFormValues = {};
|
||||
let envMessage = [];
|
||||
// 如果列表存在且用户点击修改按钮时,设置表单默认值
|
||||
if (projectList.length !== 0 && handleUpdateIndex !== -1) {
|
||||
// console.log(projectList[handleUpdateIndex]);
|
||||
const { name, basepath, desc, env } = projectList[handleUpdateIndex];
|
||||
initFormValues = { name, basepath, desc, env };
|
||||
if (env.length !== 0) {
|
||||
envMessage = env;
|
||||
}
|
||||
initFormValues.prd_host = projectList[handleUpdateIndex].prd_host;
|
||||
initFormValues.prd_protocol = projectList[handleUpdateIndex].protocol + '\:\/\/';
|
||||
|
||||
}
|
||||
|
||||
getFieldDecorator('envs', { initialValue: envMessage });
|
||||
const envs = getFieldValue('envs');
|
||||
const formItems = envs.map((k, index) => {
|
||||
const secondIndex = 'next' + index; // 为保证key的唯一性
|
||||
return (
|
||||
<Row key={index} type="flex" justify="space-between" align={index === 0 ? 'middle' : 'top'}>
|
||||
<Col span={10} offset={2}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境名称</span>) : ''}
|
||||
required={false}
|
||||
key={index}
|
||||
>
|
||||
{getFieldDecorator(`envs-name-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 ? k.name : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else if (/prd/.test(value)) {
|
||||
callback('环境域名不能是"prd"');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境名称" style={{ width: '90%', marginRight: 8 }} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={10}>
|
||||
<FormItem
|
||||
label={index === 0 ? (
|
||||
<span>环境域名</span>) : ''}
|
||||
required={false}
|
||||
key={secondIndex}
|
||||
>
|
||||
{getFieldDecorator(`envs-domain-${index}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[1] : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
message: "请输入环境域名",
|
||||
validator(rule, value, callback) {
|
||||
if (value) {
|
||||
if (value.length === 0) {
|
||||
callback('请输入环境域名');
|
||||
} else if (!/\S/.test(value)) {
|
||||
callback('请输入环境域名');
|
||||
} else {
|
||||
return callback();
|
||||
}
|
||||
} else {
|
||||
callback('请输入环境域名');
|
||||
}
|
||||
}
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境域名" style={{ width: '90%', marginRight: 8 }} addonBefore={
|
||||
getFieldDecorator(`envs-protocol-${index}`, {
|
||||
initialValue: envMessage.length !== 0 && k.domain ? k.domain.split('\/\/')[0] + '\/\/' : 'http\:\/\/',
|
||||
rules: [{
|
||||
required: true
|
||||
}]
|
||||
})(
|
||||
<Select>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>
|
||||
)} />
|
||||
)}
|
||||
</FormItem>
|
||||
</Col>
|
||||
<Col span={2}>
|
||||
{/* 新增的项中,只有最后一项有删除按钮 */}
|
||||
{(envs.length > 0 && k._id) || (envs.length == index + 1) ? (
|
||||
<Icon
|
||||
className="dynamic-delete-button"
|
||||
type="minus-circle-o"
|
||||
onClick={() => {
|
||||
return this.remove(k._id ? k._id : k);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</Col>
|
||||
</Row>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className="g-row m-container">
|
||||
<Form>
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="项目名称"
|
||||
>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: initFormValues.name,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目名称!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
<span>
|
||||
线上域名
|
||||
<Tooltip title="将根据配置的线上域名访问mock数据">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{getFieldDecorator('prd_host', {
|
||||
initialValue: initFormValues.prd_host,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目线上域名!'
|
||||
}]
|
||||
})(
|
||||
<Input addonBefore={(
|
||||
<Select defaultValue={initFormValues.prd_protocol} onChange={this.protocolChange}>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>)} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
<span>
|
||||
基本路径
|
||||
<Tooltip title="基本路径为空表示根路径">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{getFieldDecorator('basepath', {
|
||||
initialValue: initFormValues.basepath,
|
||||
rules: [{
|
||||
required: false, message: '请输入项目基本路径! '
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="描述"
|
||||
>
|
||||
{getFieldDecorator('desc', {
|
||||
initialValue: initFormValues.desc,
|
||||
rules: [{
|
||||
required: false, message: '请输入描述!'
|
||||
}]
|
||||
})(
|
||||
<TextArea rows={4} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{formItems}
|
||||
<FormItem {...formItemLayoutWithOutLabel}>
|
||||
<Button type="dashed" onClick={this.add} style={{ width: '60%' }}>
|
||||
<Icon type="plus" /> 添加环境配置
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(Setting);
|
4
client/containers/Project/Setting/Setting.scss
Normal file
4
client/containers/Project/Setting/Setting.scss
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
.form-item {
|
||||
margin-bottom: .16rem;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
|
||||
import userModel from '../models/user.js';
|
||||
|
||||
class interfaceController extends baseController {
|
||||
constructor(ctx) {
|
||||
@ -306,14 +306,31 @@ class interfaceController extends baseController {
|
||||
}
|
||||
|
||||
async solveConflict(ctx) {
|
||||
let id = parseInt(ctx.query.id, 10);
|
||||
if(!id) return ctx.websocket.send("id 参数有误");
|
||||
|
||||
ctx.websocket.send('Hello World');
|
||||
ctx.websocket.on('message', function (message) {
|
||||
// do something with the message from client
|
||||
console.log(message);
|
||||
});
|
||||
try {
|
||||
let id = parseInt(ctx.query.id, 10), result, userInst, userinfo, data;
|
||||
if (!id) return ctx.websocket.send("id 参数有误");
|
||||
result = await this.Model.get(id), userinfo;
|
||||
if(result.edit_uid !== 0 && result.edit_uid !== this.getUid()){
|
||||
userInst = yapi.getInst(userModel);
|
||||
userinfo = await userInst.findById(result.edit_uid);
|
||||
data = {
|
||||
errno: result.edit_uid,
|
||||
data: {uid: result.edit_uid, username: userinfo.username}
|
||||
}
|
||||
}else{
|
||||
this.Model.upEditUid(id, this.getUid() ).then()
|
||||
data = {
|
||||
errno: 0,
|
||||
data: result
|
||||
}
|
||||
}
|
||||
ctx.websocket.send(JSON.stringify(data));
|
||||
ctx.websocket.on('close', ()=> {
|
||||
this.Model.upEditUid(id, 0).then()
|
||||
})
|
||||
} catch (err) {
|
||||
yapi.commons.log(err, 'error')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
});
|
||||
|
||||
if (await this.checkAuth(params.group_id, 'group', 'edit') !== true) {
|
||||
@ -92,6 +94,8 @@ class projectController extends baseController {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
@ -104,7 +108,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: params.group_id,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -113,7 +119,7 @@ class projectController extends baseController {
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加项目
|
||||
* 添加项目成员
|
||||
* @interface /project/add_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -152,12 +158,15 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -166,7 +175,7 @@ class projectController extends baseController {
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加项目
|
||||
* 删除项目成员
|
||||
* @interface /project/del_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -204,7 +213,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -254,7 +265,7 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目
|
||||
* 获取项目信息
|
||||
* @interface /project/get
|
||||
* @method GET
|
||||
* @category project
|
||||
@ -337,7 +348,7 @@ class projectController extends baseController {
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
|
||||
if (await this.checkAuth(id, 'project', 'danger') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
@ -386,7 +397,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -420,7 +433,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
@ -457,7 +472,8 @@ class projectController extends baseController {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
if(params.color) data.color = params.color;
|
||||
if(params.icon) data.icon = params.icon;
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
@ -466,7 +482,9 @@ class projectController extends baseController {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
typeid: id,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
|
@ -13,7 +13,7 @@ class interfaceModel extends baseModel {
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
project_id: { type: Number, required: true },
|
||||
edit_uid: {type: Number},
|
||||
edit_uid: {type: Number, default: 0},
|
||||
status: {type: String, enum: ['undone', 'done'], default: 'undone'},
|
||||
desc: String,
|
||||
add_time: Number,
|
||||
@ -54,7 +54,7 @@ class interfaceModel extends baseModel {
|
||||
enum: ['json', 'text', 'xml']
|
||||
},
|
||||
res_body: String
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
save(data) {
|
||||
@ -123,7 +123,15 @@ class interfaceModel extends baseModel {
|
||||
data.up_time = yapi.commons.time();
|
||||
return this.model.update({
|
||||
_id: id
|
||||
}, data, { runValidators: true });
|
||||
}, data, {runValidators: true });
|
||||
}
|
||||
|
||||
upEditUid(id, uid){
|
||||
return this.model.update({
|
||||
_id: id
|
||||
},
|
||||
{edit_uid: uid},
|
||||
{runValidators: true });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ class interfaceCase extends baseModel {
|
||||
method: { type: String },
|
||||
req_params: [{
|
||||
name: String, value: String
|
||||
}],
|
||||
}],
|
||||
req_query: [{
|
||||
name: String, value: String
|
||||
}],
|
||||
|
@ -20,6 +20,8 @@ class projectModel extends baseModel {
|
||||
env: [
|
||||
{ name: String, domain: String }
|
||||
],
|
||||
icon: String,
|
||||
color: String,
|
||||
add_time: Number,
|
||||
up_time: Number
|
||||
};
|
||||
@ -58,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).select("_id uid name basepath desc group_id project_type env add_time up_time").sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type color icon env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
|
||||
listWithPaging(group_id, page, limit) {
|
||||
|
@ -1,14 +1,13 @@
|
||||
import koaRouter from 'koa-router';
|
||||
const route = require('koa-route');
|
||||
import interfaceController from './controllers/interface.js';
|
||||
|
||||
const router = koaRouter();
|
||||
|
||||
function websocket(app) {
|
||||
console.log('load websocket...')
|
||||
app.ws.use(function (ctx, next) {
|
||||
return next(ctx);
|
||||
});
|
||||
app.ws.use(route.all('/api/interface/solve_conflict', async function (ctx) {
|
||||
router.get('/api/interface/solve_conflict', async function (ctx) {
|
||||
let inst = new interfaceController(ctx);
|
||||
await inst.init(ctx);
|
||||
if (inst.$auth === true) {
|
||||
@ -16,8 +15,10 @@ function websocket(app) {
|
||||
} else {
|
||||
ctx.ws.send('请登录...');
|
||||
}
|
||||
}));
|
||||
})
|
||||
|
||||
app.ws.use(router.routes())
|
||||
app.ws.use(router.allowedMethods());
|
||||
}
|
||||
|
||||
module.exports = websocket
|
@ -1,5 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var _stringify = require('babel-runtime/core-js/json/stringify');
|
||||
|
||||
var _stringify2 = _interopRequireDefault(_stringify);
|
||||
|
||||
var _regenerator = require('babel-runtime/regenerator');
|
||||
|
||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||
@ -40,6 +44,10 @@ var _yapi = require('../yapi.js');
|
||||
|
||||
var _yapi2 = _interopRequireDefault(_yapi);
|
||||
|
||||
var _user = require('../models/user.js');
|
||||
|
||||
var _user2 = _interopRequireDefault(_user);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var interfaceController = function (_baseController) {
|
||||
@ -593,34 +601,77 @@ var interfaceController = function (_baseController) {
|
||||
key: 'solveConflict',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var id;
|
||||
var _this2 = this;
|
||||
|
||||
var id, result, userInst, userinfo, data;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
case 0:
|
||||
id = parseInt(ctx.query.id, 10);
|
||||
_context6.prev = 0;
|
||||
id = parseInt(ctx.query.id, 10), result = void 0, userInst = void 0, userinfo = void 0, data = void 0;
|
||||
|
||||
if (id) {
|
||||
_context6.next = 3;
|
||||
_context6.next = 4;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.websocket.send("id 参数有误"));
|
||||
|
||||
case 3:
|
||||
case 4:
|
||||
_context6.next = 6;
|
||||
return this.Model.get(id);
|
||||
|
||||
ctx.websocket.send('Hello World');
|
||||
ctx.websocket.on('message', function (message) {
|
||||
// do something with the message from client
|
||||
console.log(message);
|
||||
case 6:
|
||||
result = _context6.sent;
|
||||
userinfo;
|
||||
|
||||
if (!(result.edit_uid !== 0 && result.edit_uid !== this.getUid())) {
|
||||
_context6.next = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
userInst = _yapi2.default.getInst(_user2.default);
|
||||
_context6.next = 12;
|
||||
return userInst.findById(result.edit_uid);
|
||||
|
||||
case 12:
|
||||
userinfo = _context6.sent;
|
||||
|
||||
data = {
|
||||
errno: result.edit_uid,
|
||||
data: { uid: result.edit_uid, username: userinfo.username }
|
||||
};
|
||||
_context6.next = 18;
|
||||
break;
|
||||
|
||||
case 16:
|
||||
this.Model.upEditUid(id, this.getUid()).then();
|
||||
data = {
|
||||
errno: 0,
|
||||
data: result
|
||||
};
|
||||
|
||||
case 18:
|
||||
ctx.websocket.send((0, _stringify2.default)(data));
|
||||
ctx.websocket.on('close', function () {
|
||||
_this2.Model.upEditUid(id, 0).then();
|
||||
});
|
||||
_context6.next = 25;
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case 22:
|
||||
_context6.prev = 22;
|
||||
_context6.t0 = _context6['catch'](0);
|
||||
|
||||
_yapi2.default.commons.log(_context6.t0, 'error');
|
||||
|
||||
case 25:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this);
|
||||
}, _callee6, this, [[0, 22]]);
|
||||
}));
|
||||
|
||||
function solveConflict(_x6) {
|
||||
|
@ -138,7 +138,9 @@ var projectController = function (_baseController) {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
});
|
||||
|
||||
_context.next = 4;
|
||||
@ -204,6 +206,8 @@ var projectController = function (_baseController) {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
@ -220,7 +224,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: params.group_id,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 32;
|
||||
@ -247,7 +253,7 @@ var projectController = function (_baseController) {
|
||||
return add;
|
||||
}()
|
||||
/**
|
||||
* 添加项目
|
||||
* 添加项目成员
|
||||
* @interface /project/add_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -262,7 +268,7 @@ var projectController = function (_baseController) {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, check, userdata, result, username;
|
||||
var params, check, userdata, result, username, project;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -337,30 +343,37 @@ var projectController = function (_baseController) {
|
||||
case 24:
|
||||
result = _context2.sent;
|
||||
username = this.getUsername();
|
||||
_context2.next = 28;
|
||||
return this.Model.get(params.id);
|
||||
|
||||
case 28:
|
||||
project = _context2.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE\u6210\u5458' + userdata.username,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 33;
|
||||
_context2.next = 36;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context2.prev = 30;
|
||||
case 33:
|
||||
_context2.prev = 33;
|
||||
_context2.t1 = _context2['catch'](21);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t1.message);
|
||||
|
||||
case 33:
|
||||
case 36:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[21, 30]]);
|
||||
}, _callee2, this, [[21, 33]]);
|
||||
}));
|
||||
|
||||
function addMember(_x2) {
|
||||
@ -370,7 +383,7 @@ var projectController = function (_baseController) {
|
||||
return addMember;
|
||||
}()
|
||||
/**
|
||||
* 添加项目
|
||||
* 删除项目成员
|
||||
* @interface /project/del_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -459,7 +472,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 33;
|
||||
@ -595,7 +610,7 @@ var projectController = function (_baseController) {
|
||||
}()
|
||||
|
||||
/**
|
||||
* 添加项目
|
||||
* 获取项目信息
|
||||
* @interface /project/get
|
||||
* @method GET
|
||||
* @category project
|
||||
@ -923,7 +938,9 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 35;
|
||||
@ -986,7 +1003,9 @@ var projectController = function (_baseController) {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (_id2) {
|
||||
@ -1060,11 +1079,12 @@ var projectController = function (_baseController) {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
_context10.next = 31;
|
||||
if (params.color) data.color = params.color;
|
||||
if (params.icon) data.icon = params.icon;
|
||||
_context10.next = 33;
|
||||
return this.Model.up(_id2, data);
|
||||
|
||||
case 31:
|
||||
case 33:
|
||||
result = _context10.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
@ -1073,24 +1093,26 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: _id2
|
||||
typeid: _id2,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 40;
|
||||
_context10.next = 42;
|
||||
break;
|
||||
|
||||
case 37:
|
||||
_context10.prev = 37;
|
||||
case 39:
|
||||
_context10.prev = 39;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
|
||||
case 40:
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 37]]);
|
||||
}, _callee10, this, [[0, 39]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
|
@ -52,7 +52,7 @@ var interfaceModel = function (_baseModel) {
|
||||
path: { type: String, required: true },
|
||||
method: { type: String, required: true },
|
||||
project_id: { type: Number, required: true },
|
||||
edit_uid: { type: Number },
|
||||
edit_uid: { type: Number, default: 0 },
|
||||
status: { type: String, enum: ['undone', 'done'], default: 'undone' },
|
||||
desc: String,
|
||||
add_time: Number,
|
||||
@ -170,6 +170,13 @@ var interfaceModel = function (_baseModel) {
|
||||
_id: id
|
||||
}, data, { runValidators: true });
|
||||
}
|
||||
}, {
|
||||
key: 'upEditUid',
|
||||
value: function upEditUid(id, uid) {
|
||||
return this.model.update({
|
||||
_id: id
|
||||
}, { edit_uid: uid }, { runValidators: true });
|
||||
}
|
||||
}]);
|
||||
return interfaceModel;
|
||||
}(_base2.default);
|
||||
|
@ -55,6 +55,8 @@ var projectModel = function (_baseModel) {
|
||||
project_type: { type: String, required: true, enum: ['public', 'private'] },
|
||||
members: [{ uid: Number, role: { type: String, enum: ['owner', 'dev'] }, username: String, email: String }],
|
||||
env: [{ name: String, domain: String }],
|
||||
icon: String,
|
||||
color: String,
|
||||
add_time: Number,
|
||||
up_time: Number
|
||||
};
|
||||
@ -99,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).select("_id uid name basepath desc group_id project_type env add_time up_time").sort({ _id: -1 }).exec();
|
||||
return this.model.find(params).select("_id uid name basepath desc group_id project_type color icon env add_time up_time").sort({ _id: -1 }).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
|
@ -18,15 +18,14 @@ var _interface2 = _interopRequireDefault(_interface);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var route = require('koa-route');
|
||||
|
||||
var router = (0, _koaRouter2.default)();
|
||||
|
||||
function websocket(app) {
|
||||
console.log('load websocket...');
|
||||
app.ws.use(function (ctx, next) {
|
||||
return next(ctx);
|
||||
});
|
||||
app.ws.use(route.all('/api/interface/solve_conflict', function () {
|
||||
router.get('/api/interface/solve_conflict', function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var inst;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
@ -64,7 +63,10 @@ function websocket(app) {
|
||||
return function (_x) {
|
||||
return _ref.apply(this, arguments);
|
||||
};
|
||||
}()));
|
||||
}());
|
||||
|
||||
app.ws.use(router.routes());
|
||||
app.ws.use(router.allowedMethods());
|
||||
}
|
||||
|
||||
module.exports = websocket;
|
@ -362,7 +362,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#11" target="_blank">./server/controllers/group.js:11</a>
|
||||
<a href="./static/server/controllers/group.js.html#13" target="_blank">./server/controllers/group.js:13</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -424,7 +424,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#38" target="_blank">./server/controllers/group.js:38</a>
|
||||
<a href="./static/server/controllers/group.js.html#40" target="_blank">./server/controllers/group.js:40</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -488,7 +488,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>
|
||||
@ -519,7 +519,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#119" target="_blank">./server/controllers/group.js:119</a>
|
||||
<a href="./static/server/controllers/group.js.html#121" target="_blank">./server/controllers/group.js:121</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -568,6 +568,18 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>role</td>
|
||||
<td>String</td>
|
||||
<td>成员角色,owner or dev</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -593,7 +605,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#165" target="_blank">./server/controllers/group.js:165</a>
|
||||
<a href="./static/server/controllers/group.js.html#170" target="_blank">./server/controllers/group.js:170</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -679,7 +691,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#203" target="_blank">./server/controllers/group.js:203</a>
|
||||
<a href="./static/server/controllers/group.js.html#208" target="_blank">./server/controllers/group.js:208</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -741,7 +753,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#229" target="_blank">./server/controllers/group.js:229</a>
|
||||
<a href="./static/server/controllers/group.js.html#234" target="_blank">./server/controllers/group.js:234</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -815,13 +827,13 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#266" target="_blank">./server/controllers/group.js:266</a>
|
||||
<a href="./static/server/controllers/group.js.html#271" target="_blank">./server/controllers/group.js:271</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
@ -877,7 +889,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#285" target="_blank">./server/controllers/group.js:285</a>
|
||||
<a href="./static/server/controllers/group.js.html#290" target="_blank">./server/controllers/group.js:290</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -919,7 +931,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>
|
||||
@ -949,7 +961,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#322" target="_blank">./server/controllers/group.js:322</a>
|
||||
<a href="./static/server/controllers/group.js.html#330" target="_blank">./server/controllers/group.js:330</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1015,7 +1027,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>
|
||||
@ -1103,7 +1115,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>
|
||||
@ -1142,7 +1154,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>
|
||||
@ -1233,7 +1245,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>
|
||||
@ -1329,7 +1341,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>
|
||||
@ -1814,7 +1826,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>
|
||||
@ -2015,7 +2027,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>
|
||||
@ -2051,12 +2063,12 @@
|
||||
</blockquote>
|
||||
<p>
|
||||
<small class="text-muted">描述:</small>
|
||||
添加项目
|
||||
添加项目成员
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#114" target="_blank">./server/controllers/project.js:114</a>
|
||||
<a href="./static/server/controllers/project.js.html#120" target="_blank">./server/controllers/project.js:120</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2110,7 +2122,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>
|
||||
@ -2135,12 +2147,12 @@
|
||||
</blockquote>
|
||||
<p>
|
||||
<small class="text-muted">描述:</small>
|
||||
添加项目
|
||||
删除项目成员
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#165" target="_blank">./server/controllers/project.js:165</a>
|
||||
<a href="./static/server/controllers/project.js.html#176" target="_blank">./server/controllers/project.js:176</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2194,7 +2206,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>
|
||||
@ -2224,7 +2236,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#231" target="_blank">./server/controllers/project.js:231</a>
|
||||
<a href="./static/server/controllers/project.js.html#241" target="_blank">./server/controllers/project.js:241</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2266,7 +2278,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>
|
||||
@ -2297,12 +2309,12 @@
|
||||
</blockquote>
|
||||
<p>
|
||||
<small class="text-muted">描述:</small>
|
||||
添加项目
|
||||
获取项目信息
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#256" target="_blank">./server/controllers/project.js:256</a>
|
||||
<a href="./static/server/controllers/project.js.html#266" target="_blank">./server/controllers/project.js:266</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2344,7 +2356,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>
|
||||
@ -2385,7 +2397,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#283" target="_blank">./server/controllers/project.js:283</a>
|
||||
<a href="./static/server/controllers/project.js.html#293" target="_blank">./server/controllers/project.js:293</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2427,7 +2439,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>
|
||||
@ -2601,7 +2613,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#323" target="_blank">./server/controllers/project.js:323</a>
|
||||
<a href="./static/server/controllers/project.js.html#333" target="_blank">./server/controllers/project.js:333</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2643,7 +2655,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>
|
||||
@ -2673,7 +2685,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#398" target="_blank">./server/controllers/project.js:398</a>
|
||||
<a href="./static/server/controllers/project.js.html#409" target="_blank">./server/controllers/project.js:409</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2779,7 +2791,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>
|
||||
@ -2821,7 +2833,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#479" target="_blank">./server/controllers/project.js:479</a>
|
||||
<a href="./static/server/controllers/project.js.html#494" target="_blank">./server/controllers/project.js:494</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2863,7 +2875,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>
|
||||
@ -2916,7 +2928,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#533" target="_blank">./server/controllers/project.js:533</a>
|
||||
<a href="./static/server/controllers/project.js.html#548" target="_blank">./server/controllers/project.js:548</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2981,7 +2993,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#10" target="_blank">./server/controllers/interface.js:10</a>
|
||||
<a href="./static/server/controllers/interface.js.html#11" target="_blank">./server/controllers/interface.js:11</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3209,7 +3221,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>
|
||||
|
||||
@ -3302,7 +3314,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#107" target="_blank">./server/controllers/interface.js:107</a>
|
||||
<a href="./static/server/controllers/interface.js.html#111" target="_blank">./server/controllers/interface.js:111</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3344,7 +3356,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>
|
||||
@ -3367,7 +3379,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#132" target="_blank">./server/controllers/interface.js:132</a>
|
||||
<a href="./static/server/controllers/interface.js.html#136" target="_blank">./server/controllers/interface.js:136</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3409,7 +3421,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>
|
||||
@ -3432,7 +3444,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#157" target="_blank">./server/controllers/interface.js:157</a>
|
||||
<a href="./static/server/controllers/interface.js.html#161" target="_blank">./server/controllers/interface.js:161</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3634,7 +3646,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>
|
||||
@ -3665,7 +3677,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/interface.js.html#264" target="_blank">./server/controllers/interface.js:264</a>
|
||||
<a href="./static/server/controllers/interface.js.html#272" target="_blank">./server/controllers/interface.js:272</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -3707,7 +3719,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>
|
||||
@ -3802,7 +3814,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>
|
||||
@ -3867,7 +3879,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>
|
||||
@ -3968,7 +3980,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>
|
||||
@ -4659,7 +4671,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/log.js.html#28" target="_blank">./server/controllers/log.js:28</a>
|
||||
<a href="./static/server/controllers/log.js.html#12" target="_blank">./server/controllers/log.js:12</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -4721,7 +4733,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>
|
||||
@ -4776,8 +4788,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);
|
||||
@ -4785,7 +4797,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
@ -30,12 +30,14 @@ import yapi from '../yapi.js';
|
||||
import baseController from './base.js';
|
||||
import projectModel from '../models/project.js';
|
||||
import userModel from '../models/user.js';
|
||||
import interfaceModel from '../models/interface.js';
|
||||
import interfaceColModel from '../models/interfaceCol.js';
|
||||
import interfaceCaseModel from '../models/interfaceCase.js';
|
||||
|
||||
class groupController extends baseController {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目分组
|
||||
* @interface /group/get
|
||||
@ -152,6 +154,7 @@ class groupController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {String} id 项目分组id
|
||||
* @param {String} member_uid 项目分组成员uid
|
||||
* @param {String} role 成员角色,owner or dev
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -169,11 +172,13 @@ class groupController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空');
|
||||
}
|
||||
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
|
||||
var check = await groupInst.checkMemberRepeat(params.id, params.member_uid);
|
||||
if (check > 0) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '成员已存在');
|
||||
}
|
||||
let groupUserdata = await this.getUserdata(params.member_uid);
|
||||
let groupUserdata = await this.getUserdata(params.member_uid, params.role);
|
||||
if (groupUserdata === null) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
|
||||
}
|
||||
@ -328,18 +333,21 @@ class groupController extends baseController {
|
||||
try {
|
||||
let groupInst = yapi.getInst(groupModel);
|
||||
let projectInst = yapi.getInst(projectModel);
|
||||
let interfaceInst = yapi.getInst(interfaceModel);
|
||||
let interfaceColInst = yapi.getInst(interfaceColModel);
|
||||
let interfaceCaseInst = yapi.getInst(interfaceCaseModel);
|
||||
let id = ctx.request.body.id;
|
||||
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
|
||||
}
|
||||
|
||||
let count = await projectInst.countByGroupId(id);
|
||||
|
||||
if (count > 0) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 403, '请先删除该分组下的项目');
|
||||
}
|
||||
|
||||
let projectList =await projectInst.list(id, true);
|
||||
projectList.forEach(async (p) => {
|
||||
await interfaceInst.delByProjectId(p._id)
|
||||
await interfaceCaseInst.delByProjectId(p._id)
|
||||
await interfaceColInst.delByProjectId(p._id)
|
||||
})
|
||||
await projectInst.delByGroupid(id);
|
||||
let result = await groupInst.del(id);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (err) {
|
||||
|
@ -29,6 +29,7 @@
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
|
||||
|
||||
class interfaceController extends baseController {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
@ -118,8 +119,11 @@ class interfaceController extends baseController {
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params) {
|
||||
if (params.req_params && Array.isArray(params.req_params) && params.req_params.length > 0) {
|
||||
data.type = 'var'
|
||||
data.req_params = params.req_params;
|
||||
} else {
|
||||
data.type = 'static'
|
||||
}
|
||||
if (params.req_body_other) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
@ -263,9 +267,13 @@ class interfaceController extends baseController {
|
||||
if (params.req_body_form) {
|
||||
data.req_body_form = params.req_body_form;
|
||||
}
|
||||
if (params.req_params) {
|
||||
if (params.req_params && Array.isArray(params.req_params) && params.req_params.length > 0) {
|
||||
data.type = 'var'
|
||||
data.req_params = params.req_params;
|
||||
} else {
|
||||
data.type = 'static'
|
||||
}
|
||||
|
||||
if (params.req_query) {
|
||||
data.req_query = params.req_query;
|
||||
}
|
||||
@ -323,6 +331,21 @@ class interfaceController extends baseController {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async solveConflict(ctx) {
|
||||
let id = parseInt(ctx.query.id, 10);
|
||||
if(!id) return ctx.websocket.send("id 参数有误");
|
||||
|
||||
ctx.websocket.send('Hello World');
|
||||
ctx.websocket.on('message', function (message) {
|
||||
// do something with the message from client
|
||||
console.log(message);
|
||||
});
|
||||
|
||||
ctx.websocket.on('close', function(){
|
||||
console.log('websocket: close')
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = interfaceController;
|
||||
|
16
static/doc/static/server/controllers/log.js.html
vendored
16
static/doc/static/server/controllers/log.js.html
vendored
@ -35,22 +35,6 @@ class logController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(logModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
try{
|
||||
// var res = this.Model.save({
|
||||
// uid: 107,
|
||||
// typeid: 21,
|
||||
// type: 'project',
|
||||
// username: '小明明宝宝',
|
||||
// content: '小明应该修改了的项目宝宝',
|
||||
// time: yapi.commons.time()
|
||||
// });
|
||||
// var res = this.Model.del(107);
|
||||
// ctx.body = yapi.commons.resReturn(null, 200,res);
|
||||
}catch(err){
|
||||
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
101
static/doc/static/server/controllers/project.js.html
vendored
101
static/doc/static/server/controllers/project.js.html
vendored
@ -84,7 +84,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
color: 'string',
|
||||
icon: 'string'
|
||||
});
|
||||
|
||||
if (await this.checkAuth(params.group_id, 'group', 'edit') !== true) {
|
||||
@ -119,6 +121,8 @@ class projectController extends baseController {
|
||||
project_type: params.project_type || 'private',
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
};
|
||||
@ -126,12 +130,14 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
typeid: params.group_id,
|
||||
color: params.color,
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -140,7 +146,7 @@ class projectController extends baseController {
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加项目
|
||||
* 添加项目成员
|
||||
* @interface /project/add_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -168,7 +174,9 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目成员已存在');
|
||||
}
|
||||
|
||||
let userdata = await this.getUserdata(params.member_uid);
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
|
||||
let userdata = await this.getUserdata(params.member_uid, params.role);
|
||||
if(userdata === null){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '成员uid不存在')
|
||||
}
|
||||
@ -177,12 +185,15 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
let project = await this.Model.get(params.id);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -191,7 +202,7 @@ class projectController extends baseController {
|
||||
|
||||
}
|
||||
/**
|
||||
* 添加项目
|
||||
* 删除项目成员
|
||||
* @interface /project/del_member
|
||||
* @method POST
|
||||
* @category project
|
||||
@ -223,17 +234,16 @@ class projectController extends baseController {
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${member.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -282,7 +292,7 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目
|
||||
* 获取项目信息
|
||||
* @interface /project/get
|
||||
* @method GET
|
||||
* @category project
|
||||
@ -365,15 +375,18 @@ class projectController extends baseController {
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
let interfaceInst = yapi.getInst(interfaceModel);
|
||||
let count = await interfaceInst.countByProjectId(id);
|
||||
if (count > 0) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '请先删除该项目下所有接口');
|
||||
}
|
||||
|
||||
if (await this.checkAuth(id, 'project', 'danger') !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
let interfaceInst = yapi.getInst(interfaceModel);
|
||||
let interfaceColInst = yapi.getInst(interfaceColModel);
|
||||
let interfaceCaseInst = yapi.getInst(interfaceCaseModel);
|
||||
await interfaceInst.delByProjectId(id)
|
||||
await interfaceCaseInst.delByProjectId(id)
|
||||
await interfaceColInst.delByProjectId(id)
|
||||
|
||||
let result = await this.Model.del(id);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (err) {
|
||||
@ -405,18 +418,16 @@ class projectController extends baseController {
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let member = await yapi.getInst(userModel).findByUids(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}修改了项目${project.name}中成员${member.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -449,7 +460,9 @@ class projectController extends baseController {
|
||||
name: 'string',
|
||||
basepath: 'string',
|
||||
group_id: 'number',
|
||||
desc: 'string'
|
||||
desc: 'string',
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
@ -486,18 +499,20 @@ class projectController extends baseController {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
if(params.color) data.color = params.color;
|
||||
if(params.icon) data.icon = params.icon;
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}更新了项目${projectData.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
typeid: id,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
Loading…
Reference in New Issue
Block a user