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

This commit is contained in:
zwjamnsss 2017-08-15 17:41:59 +08:00
commit fcd310b054
20 changed files with 485 additions and 167 deletions

View File

@ -1,17 +1,20 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import _ from 'underscore'
import {
Form, Select, Input,
Button, Row, Col, Radio, Icon
} from 'antd';
const FormItem = Form.Item;
const Option = Select.Option;
const InputGroup = Input.Group;
const RadioGroup = Radio.Group;
const dataTpl = {
req_query: { name: "", required: "1", desc: "" },
req_headers: { name: "", required: "1", desc: "" }
req_headers: { name: "", required: "1", desc: "" },
req_params: { name: "", desc: "" }
}
const mockEditor = require('./mockEditor.js');
@ -32,12 +35,14 @@ class InterfaceEditForm extends Component {
if (curdata.req_query && curdata.req_query.length === 0) delete curdata.req_query;
if (curdata.req_headers && curdata.req_headers.length === 0) delete curdata.req_headers;
if (curdata.req_body_form && curdata.req_body_form.length === 0) delete curdata.req_body_form;
if (curdata.req_params && curdata.req_params.length === 0) delete curdata.req_params;
this.state = Object.assign({
title: '',
path: '',
status: 'undone',
method: 'get',
req_params: [],
req_query: [{
name: '',
desc: '',
@ -66,23 +71,31 @@ class InterfaceEditForm extends Component {
this.props.form.validateFields((err, values) => {
if (!err) {
if (values.res_body_type === 'json') values.res_body = this.state.res_body;
values.req_params = this.state.req_params;
values.req_body_json = this.state.res_body;
let isfile = false;
if(values.req_body_type === 'form'){
values.req_body_form.forEach((item)=>{
if(item.type === 'file'){
values.method = this.state.method;
let isfile = false, isHavaContentType = false;
if (values.req_body_type === 'form') {
values.req_body_form.forEach((item) => {
if (item.type === 'file') {
isfile = true;
}
})
values.req_headers.filter( (item)=>{
item.name !== 'Content-Type'
values.req_headers.map((item) => {
if (item.name === 'Content-Type') {
item.value = isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded'
isHavaContentType = true;
}
})
values.req_headers.unshift({
name: 'Content-Type',
value: isfile? 'multipart/form-data': 'application/x-www-form-urlencoded'
})
if (isHavaContentType === false) {
values.req_headers.unshift({
name: 'Content-Type',
value: isfile ? 'multipart/form-data' : 'application/x-www-form-urlencoded'
})
}
}
this.props.onSubmit(values)
@ -101,7 +114,7 @@ class InterfaceEditForm extends Component {
})
}
})
resBodyEditor = mockEditor({
container: 'res_body_json',
data: that.state.res_body,
@ -121,9 +134,10 @@ class InterfaceEditForm extends Component {
})
}
addParams = (name) => {
addParams = (name, data) => {
let newValue = {}
newValue[name] = [].concat(this.state[name], dataTpl[name])
data = data || dataTpl[name]
newValue[name] = [].concat(this.state[name], data)
this.setState(newValue)
}
@ -138,6 +152,22 @@ class InterfaceEditForm extends Component {
this.setState(newValue)
}
handlePath = (e) => {
let val = e.target.value;
if (val && val.indexOf(":") !== -1) {
let paths = val.split("/"), name, i;
for(i=1; i< paths.length; i++){
if(paths[i][0] === ':'){
name = paths[i].substr(1);
if(!_.find(this.state.req_params, {name: name})){
this.addParams('req_params', { name: name })
}
}
}
}
}
render() {
const { getFieldDecorator } = this.props.form;
const formItemLayout = {
@ -241,6 +271,33 @@ class InterfaceEditForm extends Component {
</Row>
}
const paramsTpl = (data, index) => {
return <Row key={index}>
<Col span="6">
{getFieldDecorator('req_params[' + index + '].name', {
initialValue: data.name
})(
<Input disabled placeholder="参数名称" />
)}
</Col>
<Col span="8" >
{getFieldDecorator('req_params[' + index + '].desc', {
initialValue: data.desc
})(
<Input placeholder="备注" />
)}
</Col>
<Col span="2" >
<Icon type="delete" className="interface-edit-del-icon" onClick={() => this.delParams(index, 'req_params')} />
</Col>
</Row>
}
const paramsList = this.state.req_params.map((item, index) => {
return paramsTpl(item, index)
})
const QueryList = this.state.req_query.map((item, index) => {
return queryTpl(item, index)
})
@ -275,32 +332,34 @@ class InterfaceEditForm extends Component {
{...formItemLayout}
label="接口路径"
>
{getFieldDecorator('path', {
initialValue: this.state.path,
rules: [{
required: true, message: '清输入接口路径!'
}]
})(
<InputGroup compact>
{getFieldDecorator('method', {
initialValue: 'GET'
})(
<Select style={{ width: "15%" }}>
<Option value="GET">GET</Option>
<Option value="POST">POST</Option>
<Option value="PUT">PUT</Option>
<Option value="DELETE">DELETE</Option>
</Select>
)}
<Input value={this.props.basepath} readOnly onChange={() => { }} style={{ width: '25%'}} />
{getFieldDecorator('path', {
initialValue: this.state.path
})(
<Input placeholder="/path" style={{ width: '60%' }} />
)}
</InputGroup>
<InputGroup compact>
<Select value={this.state.method} onChange={val => this.setState({ method: val })} style={{ width: "15%" }}>
<Option value="GET">GET</Option>
<Option value="POST">POST</Option>
<Option value="PUT">PUT</Option>
<Option value="DELETE">DELETE</Option>
</Select>
<Input value={this.props.basepath} readOnly onChange={() => { }} style={{ width: '25%' }} />
{getFieldDecorator('path', {
initialValue: this.state.path,
rules: [{
required: true, message: '清输入接口路径!'
}]
})(
<Input onBlur={this.handlePath} placeholder="/path" style={{ width: '60%' }} />
)}
</InputGroup>
<Row className="interface-edit-item">
<Col span={18} offset={0}>
{paramsList}
</Col>
</Row>
)}
</FormItem>
<FormItem
@ -462,7 +521,7 @@ class InterfaceEditForm extends Component {
label="预览"
>
<div id="mock-preview" style={{ backgroundColor: "#eee", lineHeight: "20px", minHeight: "300px" }}>
</div>
</FormItem>
@ -470,7 +529,7 @@ class InterfaceEditForm extends Component {
<Row className="interface-edit-item" style={{ display: this.props.form.getFieldValue('res_body_type') === 'raw' ? 'block' : 'none' }}>
<Col span={18} offset={4} >
{getFieldDecorator('res_body', { initialValue: this.state.res_body })(
<Input.TextArea style={{minHeight: "150px"}} placeholder="备注信息" />
<Input.TextArea style={{ minHeight: "150px" }} placeholder="备注信息" />
)}
</Col>

View File

@ -1,13 +1,22 @@
import '../interface.scss'
import './View.scss'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import PropTypes from 'prop-types'
import { formatTime } from '../../../../common.js';
import { Table } from 'antd'
const mockEditor = require('./mockEditor.js')
// import { formatTime } from '../../../../common.js';
// import { Card } from 'antd'
// import { getMockUrl } from '../../reducer/modules/news.js'
@connect()
@connect(state=>{
return {
curData: state.inter.curdata
}
})
class View extends Component {
constructor(props) {
@ -17,69 +26,161 @@ class View extends Component {
viewData: PropTypes.object
}
componentDidMount() {
let that = this;
mockEditor({
container: 'req_body_json',
data: that.props.req_body_form,
onChange: function () {}
})
mockEditor({
container: 'res_body_json',
data: that.props.res_body,
onChange: function () {}
})
mockEditor({
container: 'req_query_json',
data: that.props.req_query,
onChange: function () {}
})
}
render () {
const dataSource = [{
key: 1,
name: '1',
value: '胡彦斌',
desc: 32
}, {
key: 2,
name: '2',
value: '胡彦斌',
desc: 32
}];
const columns = [{
title: '参数名称',
dataIndex: 'name',
key: 'name'
}, {
title: '参数值',
dataIndex: 'value',
key: 'value'
}, {
title: '备注',
dataIndex: 'desc',
key: 'desc',
width: '45%'
}];
return <div className="caseContainer">
{/*<Card title={`接口名:${this.props.viewData.casename}`}></Card>*/}
<div className="casename">
<div className="colName">
<span className="colKey">接口名</span>
<span className="colValue">{this.props.viewData.casename}</span>
</div>
<div className="colTime">
<span className="colKey">添加时间</span>
<span className="colValue">{formatTime(this.props.viewData.add_time/1000)}</span>
</div>
<div className="colTime">
<span className="colKey">更新时间</span>
<span className="colValue">{formatTime(this.props.viewData.up_time/1000)}</span>
</div>
<div className="colEnv">
<span className="colKey">测试环境</span>
<span className="colValue">{this.props.viewData.env}</span>
</div>
<div className="colDomain">
<span className="colKey">域名</span>
<span className="colValue">{this.props.viewData.domain}</span>
<span className="colValue">{this.props.viewData.title}</span>
</div>
<div className="colPath">
<span className="colKey">路径</span>
<span className="colKey">接口路径</span>
<span className="colValue">{this.props.viewData.path}</span>
</div>
<div className="colMethod">
<span className="colKey">请求方法</span>
<span className="colValue">{this.props.viewData.method}</span>
<div className="colstatus">
<span className="colKey">状态</span>
<span className="colValue">{this.props.viewData.status}</span>
</div>
<div className="colMock">
<span className="colKey">Mock地址</span>
<span className="colValue">{this.props.viewData.mockUrl}</span>
</div>
<div className="colDesc">
<span className="colKey">接口描述</span>
<span className="colValue">{this.props.viewData.desc}</span>
</div>
<div className="colHeader">
<span className="colKey">请求Headers</span>
<Table size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
</div>
<div className="colQuery">
<span className="colKey">Query</span>
<div span={18} offset={4} id="req_query_json" style={{ minHeight: "150px" }}></div>
</div>
<div className="colBody">
<span className="colKey">请求Body</span>
<div span={18} offset={4} id="req_body_json" style={{ minHeight: "300px" }}></div>
</div>
<div className="colBody">
<span className="colKey">响应Body</span>
<div span={18} offset={4} id="res_body_json" style={{ minHeight: "300px" }}></div>
</div>
</div>
}
}
let data = {
title: '',
path: '',
status: 'undone',
method: 'get',
req_query: [{
name: '',
desc: '',
required: "1"
}],
req_body_type: 'form',
req_headers: [{
name: '',
value: '', required: "1"
}],
req_body_form: [{
name: '',
type: '',
required: ''
}],
res_body_type: 'json',
res_body: '{a:123}',
desc: 'FP的好处是没有OO的复杂仪式感是沿着数据结构+算法的思路进行抽象和结构化。如果顶层设计做好,代码复用度极高,代码量少。比如要生成一颗树我用迭归算法直接生成',
res_body_mock: '',
mockUrl: "this.props.mockUrl"
}
// {
// casename:"caename",
// uid: 107,
// col_id: 211,
// index: 0,
// project_id: 112,
// add_time: new Date().getTime(),
// up_time: new Date().getTime(),
// env: "测试环境",
// domain: "域名",
// path: "路径",
// method: "GET",
// req_query: [{
// name: "String",
// value: "String",
// required: "1"
// }],
// req_headers: [{
// name: "String",
// value: "String",
// required: "1"
// }],
// req_body_type: "json",
// res_body_form: [{
// name: "String",
// value: "String",
// required: "1"
// }],
// res_body_other: "String"
// }
View.defaultProps = {
viewData: {
casename:"caename",
uid: 107,
col_id: 211,
index: 0,
project_id: 112,
add_time: new Date().getTime(),
up_time: new Date().getTime(),
env: "测试环境",
domain: "域名",
path: "路径",
method: "GET",
req_query: [{
name: "String",
value: "String"
}],
req_headers: [{
name: "String",
value: "String"
}],
req_body_type: "json",
res_body_form: [{
name: "String",
value: "String"
}],
res_body_other: "String"
}
viewData: data
}
export default View

View File

@ -0,0 +1,35 @@
.caseContainer{
padding: 24px;
font-size: 12px;
// display: flex;
overflow: hidden;
>div{
margin: 8px 0px;
// background-color: #ececec;
padding: 16px;
width: 100%;
box-sizing: border-box;
float: left;
.colKey{
font-weight: bolder;
margin-right: 16px;
}
}
.colName,.colPath,.colstatus,.colMock{
width: 50%;
float: left;
padding: 8px 16px;
}
.colDesc{
line-height: 1.5em;
.colKey{
margin-right: 0px;
float: left;
margin-bottom: 8px;
}
.colValue{
float: left;
text-indent: 2em;
}
}
}

View File

@ -65,19 +65,7 @@
}
}
}
.caseContainer{
padding: 24px;
font-size: 12px;
>div{
margin: 8px 0px;
padding: 12px;
background-color: #ececec;
.colKey{
font-weight: bolder;
margin-right: 16px;
}
}
}

View File

@ -152,7 +152,7 @@ class Profile extends Component {
userNameEditHtml = <div >
<span className="text">{userinfo.username}</span>&nbsp;&nbsp;
{/*<span className="text-button" onClick={() => { this.handleEdit('usernameEdit', true) }}><Icon type="edit" />修改</span>*/}
{userType?<Button icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>:""}
{<Button icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>}
</div>
} else {
userNameEditHtml = <div>

View File

@ -9,7 +9,6 @@ import Profile from './Profile.js'
import { Row } from 'antd';
import Subnav from '../../components/Subnav/Subnav.js';
@connect(state=>{
console.log(state);
return {
curUid: state.user.uid,
userType: state.user.type,
@ -31,7 +30,7 @@ class User extends Component {
}
componentDidMount () {
console.log(this.props.match)
// console.log(this.props.match)
}
render () {
@ -41,7 +40,7 @@ class User extends Component {
}];
if(this.props.role === "admin"){
navData.push({
name: '成员管理',
name: '用户管理',
path: '/user/list'
})
}

View File

@ -18,7 +18,8 @@ const initialState = {
uid: null,
email: '',
loginState: LOADING_STATUS,
loginWrapActiveKey: "1"
loginWrapActiveKey: "1",
role: ""
};
export default (state = initialState, action) => {
@ -40,7 +41,8 @@ export default (state = initialState, action) => {
isLogin: true,
loginState: MEMBER_STATUS,
uid: action.payload.data.data.uid,
userName: action.payload.data.data.username
userName: action.payload.data.data.username,
role: action.payload.data.data.role
};
} else {
return state;
@ -52,7 +54,8 @@ export default (state = initialState, action) => {
isLogin: false,
loginState: GUEST_STATUS,
userName: null,
uid: null
uid: null,
role: ""
}
}
case LOGIN_TYPE: {
@ -79,6 +82,7 @@ export default (state = initialState, action) => {
export function checkLoginState() {
return(dispatch)=> {
axios.get('/api/user/status').then((res) => {
console.log(res)
dispatch({
type: GET_LOGIN_STATE,
payload: res

View File

@ -2,7 +2,6 @@
"errcode": 0,
"errmsg": "success",
"data": {
"total": 2,
"list": [
{
"_id": 529,
@ -148,16 +147,6 @@
"107"
]
}
],
"userinfo": {
"107": {
"_id": 107,
"username": "admin",
"email": "admin@admin.com",
"role": "admin",
"add_time": 1500280333,
"up_time": 1500373530
}
}
]
}
}

View File

@ -82,6 +82,7 @@ class groupController extends baseController {
return null;
}
return {
_role: userData.role,
role: role,
uid: userData._id,
username: userData.username,
@ -89,6 +90,19 @@ class groupController extends baseController {
}
}
/**
* 添加项目分组成员
* @interface /group/add_member
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @returns {Object}
* @example
*/
async addMember(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@ -107,6 +121,10 @@ class groupController extends baseController {
if(groupUserdata === null){
return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
}
if(groupUserdata._role === 'admin'){
return ctx.body = yapi.commons.resReturn(null, 400, '不能邀请管理员')
}
delete groupUserdata._role;
try {
let result = await groupInst.addMember(params.id, groupUserdata);
ctx.body = yapi.commons.resReturn(result);
@ -115,6 +133,19 @@ class groupController extends baseController {
}
}
/**
* 修改项目分组成员角色
* @interface /group/change_member_role
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @param {String} role 组长uid
* @returns {Object}
* @example
*/
async changeMemberRole(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@ -128,7 +159,7 @@ class groupController extends baseController {
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
if (await this.checkAuth(id, 'group', 'danger') !== true) {
if (await this.checkAuth(params.id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@ -141,6 +172,16 @@ class groupController extends baseController {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
/**
* 获取所有项目成员
* @interface /group/get_member_list
* @method GET
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @returns {Object}
* @example
*/
async getMemberList(ctx) {
let params = ctx.request.query;
@ -157,6 +198,18 @@ class groupController extends baseController {
}
}
/**
* 删除项目成员
* @interface /group/del_member
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @returns {Object}
* @example
*/
async delMember(ctx) {
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@ -170,7 +223,7 @@ class groupController extends baseController {
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
if (await this.checkAuth(id, 'group', 'danger') !== true) {
if (await this.checkAuth(params.id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}

View File

@ -24,6 +24,7 @@ class interfaceController extends baseController {
* @param {Boolean} [req_headers[].required] 是否是必须默认为否
* @param {String} [req_headers[].desc] header描述
* @param {String} [req_body_type] 请求参数方式["form", "json", "text", "xml"]四种
* @param {Array} [req_params] name, desc两个参数
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form参数是Array数组其他格式请求参数是字符串
* @param {String} [req_body_form[].name] 请求参数名
* @param {String} [req_body_form[].value] 请求参数值可填写生成规则mock@email随机生成一条email
@ -83,13 +84,16 @@ class interfaceController extends baseController {
up_time: yapi.commons.time()
};
if(params.req_query){
if (params.req_query) {
data.req_query = params.req_query;
}
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
if (params.req_params) {
data.req_params = params.req_params;
}
if (params.req_body_other) {
data.req_body_other = params.req_body_other;
}
@ -191,7 +195,7 @@ class interfaceController extends baseController {
params.method = params.method.toUpperCase();
let id = ctx.request.body.id;
if (!id) {
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
}
@ -228,11 +232,14 @@ class interfaceController extends baseController {
if (params.req_headers) {
data.req_headers = params.req_headers;
}
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
if(params.req_query){
if (params.req_params) {
data.req_params = params.req_params;
}
if (params.req_query) {
data.req_query = params.req_query;
}
if (params.req_body_other) {

View File

@ -311,8 +311,7 @@ class projectController extends baseController {
_users[item._id] = item;
});
ctx.body = yapi.commons.resReturn({
list: result,
userinfo: _users
list: result
});
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);

View File

@ -67,7 +67,7 @@ class groupModel extends baseModel {
_id: id,
"members.uid": uid
}, {
"$set": { "members.$.uid": role}
"$set": { "members.$.role": role}
}
);
}

View File

@ -31,6 +31,10 @@ class interfaceModel extends baseModel {
default: "1"
}
}],
req_params:[{
name: String,
desc: String
}],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'file']

View File

@ -77,6 +77,11 @@ const routerConfig = {
"path": "add_member",
"method": "post"
},
{
"action": "changeMemberRole",
"path": "change_member_role",
"method": "post"
},
{
"action": "delMember",
"path": "del_member",
@ -84,7 +89,7 @@ const routerConfig = {
},
{
"action": "getMemberList",
"path": "members",
"path": "get_member_list",
"method": "get"
}
],

View File

@ -214,6 +214,7 @@ var groupController = function (_baseController) {
case 7:
return _context2.abrupt('return', {
_role: userData.role,
role: role,
uid: userData._id,
username: userData.username,
@ -234,6 +235,19 @@ var groupController = function (_baseController) {
return getUserdata;
}()
/**
* 添加项目分组成员
* @interface /group/add_member
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @returns {Object}
* @example
*/
}, {
key: 'addMember',
value: function () {
@ -290,29 +304,38 @@ var groupController = function (_baseController) {
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '组长uid不存在'));
case 16:
_context3.prev = 16;
_context3.next = 19;
if (!(groupUserdata._role === 'admin')) {
_context3.next = 18;
break;
}
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不能邀请管理员'));
case 18:
delete groupUserdata._role;
_context3.prev = 19;
_context3.next = 22;
return groupInst.addMember(params.id, groupUserdata);
case 19:
case 22:
result = _context3.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context3.next = 26;
_context3.next = 29;
break;
case 23:
_context3.prev = 23;
_context3.t0 = _context3['catch'](16);
case 26:
_context3.prev = 26;
_context3.t0 = _context3['catch'](19);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
case 26:
case 29:
case 'end':
return _context3.stop();
}
}
}, _callee3, this, [[16, 23]]);
}, _callee3, this, [[19, 26]]);
}));
function addMember(_x4) {
@ -321,6 +344,20 @@ var groupController = function (_baseController) {
return addMember;
}()
/**
* 修改项目分组成员角色
* @interface /group/change_member_role
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @param {String} role 组长uid
* @returns {Object}
* @example
*/
}, {
key: 'changeMemberRole',
value: function () {
@ -364,7 +401,7 @@ var groupController = function (_baseController) {
case 11:
_context4.next = 13;
return this.checkAuth(id, 'group', 'danger');
return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context4.t0 = _context4.sent;
@ -411,6 +448,17 @@ var groupController = function (_baseController) {
return changeMemberRole;
}()
/**
* 获取所有项目成员
* @interface /group/get_member_list
* @method GET
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @returns {Object}
* @example
*/
}, {
key: 'getMemberList',
value: function () {
@ -462,6 +510,19 @@ var groupController = function (_baseController) {
return getMemberList;
}()
/**
* 删除项目成员
* @interface /group/del_member
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @returns {Object}
* @example
*/
}, {
key: 'delMember',
value: function () {
@ -505,7 +566,7 @@ var groupController = function (_baseController) {
case 11:
_context6.next = 13;
return this.checkAuth(id, 'group', 'danger');
return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context6.t0 = _context6.sent;

View File

@ -70,6 +70,7 @@ var interfaceController = function (_baseController) {
* @param {Boolean} [req_headers[].required] 是否是必须默认为否
* @param {String} [req_headers[].desc] header描述
* @param {String} [req_body_type] 请求参数方式["form", "json", "text", "xml"]四种
* @param {Array} [req_params] name, desc两个参数
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form参数是Array数组其他格式请求参数是字符串
* @param {String} [req_body_form[].name] 请求参数名
* @param {String} [req_body_form[].value] 请求参数值可填写生成规则mock@email随机生成一条email
@ -168,32 +169,35 @@ var interfaceController = function (_baseController) {
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
if (params.req_params) {
data.req_params = params.req_params;
}
if (params.req_body_other) {
data.req_body_other = params.req_body_other;
}
_context.next = 23;
_context.next = 24;
return this.Model.save(data);
case 23:
case 24:
result = _context.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 30;
_context.next = 31;
break;
case 27:
_context.prev = 27;
case 28:
_context.prev = 28;
_context.t0 = _context['catch'](16);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 30:
case 31:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[16, 27]]);
}, _callee, this, [[16, 28]]);
}));
function add(_x) {
@ -443,6 +447,9 @@ var interfaceController = function (_baseController) {
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
if (params.req_params) {
data.req_params = params.req_params;
}
if (params.req_query) {
data.req_query = params.req_query;
}
@ -457,29 +464,29 @@ var interfaceController = function (_baseController) {
data.res_body = params.res_body;
}
_context4.prev = 29;
_context4.next = 32;
_context4.prev = 30;
_context4.next = 33;
return this.Model.up(id, data);
case 32:
case 33:
result = _context4.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context4.next = 39;
_context4.next = 40;
break;
case 36:
_context4.prev = 36;
_context4.t0 = _context4['catch'](29);
case 37:
_context4.prev = 37;
_context4.t0 = _context4['catch'](30);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
case 39:
case 40:
case 'end':
return _context4.stop();
}
}
}, _callee4, this, [[29, 36]]);
}, _callee4, this, [[30, 37]]);
}));
function up(_x4) {

View File

@ -733,8 +733,7 @@ var projectController = function (_baseController) {
_users[item._id] = item;
});
ctx.body = _yapi2.default.commons.resReturn({
list: result,
userinfo: _users
list: result
});
_context7.next = 23;
break;

View File

@ -105,7 +105,7 @@ var groupModel = function (_baseModel) {
_id: id,
"members.uid": uid
}, {
"$set": { "members.$.uid": role }
"$set": { "members.$.role": role }
});
}
}, {

View File

@ -70,6 +70,10 @@ var interfaceModel = function (_baseModel) {
default: "1"
}
}],
req_params: [{
name: String,
desc: String
}],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'file']

View File

@ -108,13 +108,17 @@ var routerConfig = {
"action": "addMember",
"path": "add_member",
"method": "post"
}, {
"action": "changeMemberRole",
"path": "change_member_role",
"method": "post"
}, {
"action": "delMember",
"path": "del_member",
"method": "post"
}, {
"action": "getMemberList",
"path": "members",
"path": "get_member_list",
"method": "get"
}],
"user": [{