mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
feat: fix group member some bug and perfect
This commit is contained in:
parent
17fcb8c418
commit
7ab03e0142
@ -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>
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
@ -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, '没有权限');
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -67,7 +67,7 @@ class groupModel extends baseModel {
|
||||
_id: id,
|
||||
"members.uid": uid
|
||||
}, {
|
||||
"$set": { "members.$.uid": role}
|
||||
"$set": { "members.$.role": role}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -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']
|
||||
|
@ -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"
|
||||
}
|
||||
],
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -105,7 +105,7 @@ var groupModel = function (_baseModel) {
|
||||
_id: id,
|
||||
"members.uid": uid
|
||||
}, {
|
||||
"$set": { "members.$.uid": role }
|
||||
"$set": { "members.$.role": role }
|
||||
});
|
||||
}
|
||||
}, {
|
||||
|
@ -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']
|
||||
|
@ -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": [{
|
||||
|
Loading…
Reference in New Issue
Block a user