fix: 解决冲突

This commit is contained in:
zwjamnsss 2017-08-14 21:23:57 +08:00
commit 4af8846935
14 changed files with 160 additions and 110 deletions

View File

@ -165,7 +165,7 @@ export default class HeaderCom extends Component {
<Header className="header-box m-header"> <Header className="header-box m-header">
<div className="content g-row"> <div className="content g-row">
<div className="logo"> <div className="logo">
<Link to="/" onClick={this.relieveLink} className="href"> <Link to="/group" onClick={this.relieveLink} className="href">
<img className="img" src="/image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span> <img className="img" src="/image/logo_header@1x.png" /><span className="logo-name">YAPI<span className="ui-badge"></span></span>
</Link> </Link>
</div> </div>

View File

@ -35,13 +35,15 @@ class InterfaceEditForm extends Component {
req_body_type: 'form', req_body_type: 'form',
req_headers: [{ req_headers: [{
name: 'Content-Type', name: 'Content-Type',
value: 'application/urlencode', required: "1" value: 'application/x-www-form-urlencoded', required: "1"
}], }],
req_body_form: [{ req_body_form: [{
name: 'id', name: 'id',
type: 'text', type: 'text',
required: '1' required: '1'
}] }],
res_body_type: 'json',
res_body: ''
} }
} }
@ -50,20 +52,29 @@ class InterfaceEditForm extends Component {
this.props.form.validateFields((err, values) => { this.props.form.validateFields((err, values) => {
if (!err) { if (!err) {
console.log('Received values of form: ', values); console.log('Received values of form: ', values);
console.log(this.props.form.getFieldValue('keys'))
} }
}); });
} }
componentDidMount() { componentDidMount() {
let that = this;
mockEditor({ mockEditor({
container: 'req_body_json', container: 'req_body_json',
data: { data: that.state.req_body_json,
name: "@name"
},
onChange: function (d) { onChange: function (d) {
console.log(this) that.setState({
console.log(d) req_body_json: d.text
})
}
})
mockEditor({
container: 'res_body_json',
data: that.state.res_body,
onChange: function (d) {
that.setState({
res_body: d.text
})
} }
}) })
} }
@ -294,13 +305,14 @@ class InterfaceEditForm extends Component {
<Radio value="form">form</Radio> <Radio value="form">form</Radio>
<Radio value="json">json</Radio> <Radio value="json">json</Radio>
<Radio value="file">file</Radio> <Radio value="file">file</Radio>
<Radio value="raw">raw</Radio>
</RadioGroup> </RadioGroup>
)} )}
</FormItem> </FormItem>
{this.props.form.getFieldValue('req_body_type') === 'form' ?
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'form' ? 'block' : 'none' }}> <Row >
<Col span={14} offset={6} style={{ minHeight: "300px", padding: "15px" }}> <Col span={14} offset={6} style={{ minHeight: "50px", padding: "15px" }}>
<Row> <Row>
<Col span="24"> <Col span="24">
@ -313,14 +325,74 @@ class InterfaceEditForm extends Component {
</Col> </Col>
</Row> </Row>
:
null
}
<Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'json' ? 'block' : 'none' }}> <Row style={{ display: this.props.form.getFieldValue('req_body_type') === 'json' ? 'block' : 'none' }}>
<Col span={14} offset={6} id="req_body_json" style={{ minHeight: "300px", padding: "15px" }}> <Col span={14} offset={6} id="req_body_json" style={{ minHeight: "300px", padding: "15px" }}>
</Col>
</Row>
{this.props.form.getFieldValue('req_body_type') === 'file' ?
<Row >
<Col span={14} offset={6} style={{ padding: "15px" }}>
{getFieldDecorator('req_body_other', { initialValue: this.state.req_body_other })(
<Input.TextArea placeholder="备注信息" />
)}
</Col>
</Row>
:
null
}
{this.props.form.getFieldValue('req_body_type') === 'raw' ?
<Row>
<Col span={14} offset={6} style={{ padding: "15px" }}>
{getFieldDecorator('req_body_other', { initialValue: this.state.req_body_other })(
<Input.TextArea placeholder="备注信息" />
)}
</Col>
</Row>
: null
}
<FormItem style={{ marginBottom: "5px" }}
{...formItemLayout}
label="响应Body"
>
{getFieldDecorator('res_body_type', {
initialValue: this.state.res_body_type
})(
<RadioGroup>
<Radio value="json">json</Radio>
<Radio value="raw">raw</Radio>
</RadioGroup>
)}
</FormItem>
<Row style={{ display: this.props.form.getFieldValue('res_body_type') === 'json' ? 'block' : 'none' }}>
<Col span={14} offset={6} id="res_body_json" style={{ minHeight: "300px", padding: "15px" }}>
</Col> </Col>
</Row> </Row>
<Row style={{ display: this.props.form.getFieldValue('res_body_type') === 'raw' ? 'block' : 'none' }}>
<Col span={14} offset={6} style={{ padding: "15px" }}>
{getFieldDecorator('req_body_other', { initialValue: this.state.res_body })(
<Input.TextArea placeholder="备注信息" />
)}
</Col>
</Row>
<FormItem <FormItem
wrapperCol={{ span: 12, offset: 6 }} wrapperCol={{ span: 12, offset: 6 }}
> >

View File

@ -3,8 +3,6 @@ var ace = require('brace'),
require('brace/mode/javascript'); require('brace/mode/javascript');
require('brace/theme/xcode'); require('brace/theme/xcode');
require("brace/ext/language_tools.js"); require("brace/ext/language_tools.js");
require("brace/snippets/javascript.js");
var json5 = require('json5'); var json5 = require('json5');
var langTools = ace.acequire("ace/ext/language_tools"), var langTools = ace.acequire("ace/ext/language_tools"),
@ -76,8 +74,9 @@ function run(options) {
editor.setTheme('ace/theme/xcode'); editor.setTheme('ace/theme/xcode');
editor.setOptions({ editor.setOptions({
enableBasicAutocompletion: true, enableBasicAutocompletion: true,
enableSnippets: true, enableSnippets: false,
enableLiveAutocompletion: true enableLiveAutocompletion: true,
useWorker: false
}); });
mockEditor = { mockEditor = {
curData: {}, curData: {},

View File

@ -3,7 +3,7 @@ import { message } from 'antd';
export default () => next => action => { export default () => next => action => {
if (action.error) { if (action.error) {
message.error((action.payload && action.payload.message) || '服务器错误'); message.error((action.payload && action.payload.message) || '服务器错误');
} else if (action.payload && action.payload.data && action.payload.data.errcode) { } else if (action.payload && action.payload.data && action.payload.data.errcode && action.payload.data.errcode !== 40011) {
message.error(action.payload.data.errmsg); message.error(action.payload.data.errmsg);
} }
return next(action); return next(action);

View File

@ -72,7 +72,7 @@ class baseController {
result.server_ip = yapi.WEBCONFIG.server_ip; result.server_ip = yapi.WEBCONFIG.server_ip;
return ctx.body = yapi.commons.resReturn(result); return ctx.body = yapi.commons.resReturn(result);
} }
return ctx.body = yapi.commons.resReturn(null, 300, 'Please login.'); return ctx.body = yapi.commons.resReturn(null, 40011, '请登录...');
} }
getRole() { getRole() {

View File

@ -24,6 +24,11 @@ class interfaceColController extends baseController{
try { try {
let id = ctx.query.project_id; let id = ctx.query.project_id;
let result = await this.colModel.list(id); let result = await this.colModel.list(id);
for(let i=0; i< result.length;i++){
result[i] = result[i].toObject();
result[i].caseList = await this.caseModel.list(result[i]._id)
}
ctx.body = yapi.commons.resReturn(result); ctx.body = yapi.commons.resReturn(result);
} catch (e) { } catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message); ctx.body = yapi.commons.resReturn(null, 402, e.message);
@ -134,13 +139,7 @@ class interfaceColController extends baseController{
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'); return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
} }
if (!params.col_id) { if (!params.col_id) {
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'); return ctx.body = yapi.commons.resReturn(null, 400, '接口集id不能为空');
}
if (!params.env) {
return ctx.body = yapi.commons.resReturn(null, 400, '缺少环境配置');
}
if (!params.path) {
return ctx.body = yapi.commons.resReturn(null, 400, 'path 不能为空');
} }

View File

@ -42,26 +42,12 @@ class interfaceModel extends baseModel {
default: "1" default: "1"
} }
}], }],
req_body_json_doc: [{
json_path: String, desc: String,required:{
type:String,
enum: ["1", "0"],
default: "1"
}
}],
req_body_other: String, req_body_other: String,
res_body_type: { res_body_type: {
type: String, type: String,
enum: ['json', 'text', 'xml'] enum: ['json', 'text', 'xml']
}, },
res_body: String, res_body: String
res_body_json_doc: [{
json_path: String, desc: String,required:{
type:String,
enum: ["1", "0"],
default: "1"
}
}]
}; };
} }

View File

@ -15,10 +15,10 @@ class interfaceCase extends baseModel {
project_id: { type: Number, required: true }, project_id: { type: Number, required: true },
add_time: Number, add_time: Number,
up_time: Number, up_time: Number,
env: { type: String, required: true }, env: { type: String },
domain: {type: String }, domain: {type: String },
path: { type: String, required: true }, path: { type: String },
method: { type: String, required: true }, method: { type: String },
req_query: [{ req_query: [{
name: String, value: String name: String, value: String
}], }],
@ -48,8 +48,10 @@ class interfaceCase extends baseModel {
}).exec(); }).exec();
} }
list() { list(col_id) {
return this.model.find().select("casename uid col_id _id index").exec(); return this.model.find({
col_id: col_id
}).select("casename uid col_id _id index").exec();
} }
del(id) { del(id) {

View File

@ -320,7 +320,7 @@ function createAction(controller, action, path, method) {
if (inst.$auth === true) { if (inst.$auth === true) {
await inst[action].call(inst, ctx); await inst[action].call(inst, ctx);
} else { } else {
ctx.body = yapi.commons.resReturn(null, 40011, '请登录.'); ctx.body = yapi.commons.resReturn(null, 40011, '请登录...');
} }
}); });
} }

View File

@ -193,7 +193,7 @@ var baseController = function () {
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result)); return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
case 7: case 7:
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 300, 'Please login.')); return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录...'));
case 8: case 8:
case 'end': case 'end':

View File

@ -75,7 +75,7 @@ var interfaceColController = function (_baseController) {
key: 'list', key: 'list',
value: function () { value: function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) { var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
var id, result; var id, result, i;
return _regenerator2.default.wrap(function _callee$(_context) { return _regenerator2.default.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
@ -87,23 +87,43 @@ var interfaceColController = function (_baseController) {
case 4: case 4:
result = _context.sent; result = _context.sent;
i = 0;
ctx.body = _yapi2.default.commons.resReturn(result); case 6:
_context.next = 11; if (!(i < result.length)) {
_context.next = 14;
break;
}
result[i] = result[i].toObject();
_context.next = 10;
return this.caseModel.list(result[i]._id);
case 10:
result[i].caseList = _context.sent;
case 11:
i++;
_context.next = 6;
break; break;
case 8: case 14:
_context.prev = 8; ctx.body = _yapi2.default.commons.resReturn(result);
_context.next = 20;
break;
case 17:
_context.prev = 17;
_context.t0 = _context['catch'](0); _context.t0 = _context['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message); ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
case 11: case 20:
case 'end': case 'end':
return _context.stop(); return _context.stop();
} }
} }
}, _callee, this, [[0, 8]]); }, _callee, this, [[0, 17]]);
})); }));
function list(_x) { function list(_x) {
@ -309,62 +329,46 @@ var interfaceColController = function (_baseController) {
break; break;
} }
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空')); return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口集id不能为空'));
case 7: case 7:
if (params.env) {
_context4.next = 9;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '缺少环境配置'));
case 9:
if (params.path) {
_context4.next = 11;
break;
}
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'path 不能为空'));
case 11:
if (params.casename) { if (params.casename) {
_context4.next = 13; _context4.next = 9;
break; break;
} }
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空')); return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
case 13: case 9:
params.uid = this.getUid(); params.uid = this.getUid();
params.index = 0; params.index = 0;
params.add_time = _yapi2.default.commons.time(); params.add_time = _yapi2.default.commons.time();
params.up_time = _yapi2.default.commons.time(); params.up_time = _yapi2.default.commons.time();
_context4.next = 19; _context4.next = 15;
return this.caseModel.save(params); return this.caseModel.save(params);
case 19: case 15:
result = _context4.sent; result = _context4.sent;
ctx.body = _yapi2.default.commons.resReturn(result); ctx.body = _yapi2.default.commons.resReturn(result);
_context4.next = 26; _context4.next = 22;
break; break;
case 23: case 19:
_context4.prev = 23; _context4.prev = 19;
_context4.t0 = _context4['catch'](0); _context4.t0 = _context4['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message); ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
case 26: case 22:
case 'end': case 'end':
return _context4.stop(); return _context4.stop();
} }
} }
}, _callee4, this, [[0, 23]]); }, _callee4, this, [[0, 19]]);
})); }));
function addCase(_x4) { function addCase(_x4) {

View File

@ -81,26 +81,12 @@ var interfaceModel = function (_baseModel) {
default: "1" default: "1"
} }
}], }],
req_body_json_doc: [{
json_path: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}],
req_body_other: String, req_body_other: String,
res_body_type: { res_body_type: {
type: String, type: String,
enum: ['json', 'text', 'xml'] enum: ['json', 'text', 'xml']
}, },
res_body: String, res_body: String
res_body_json_doc: [{
json_path: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}]
}; };
} }
}, { }, {

View File

@ -54,10 +54,10 @@ var interfaceCase = function (_baseModel) {
project_id: { type: Number, required: true }, project_id: { type: Number, required: true },
add_time: Number, add_time: Number,
up_time: Number, up_time: Number,
env: { type: String, required: true }, env: { type: String },
domain: { type: String }, domain: { type: String },
path: { type: String, required: true }, path: { type: String },
method: { type: String, required: true }, method: { type: String },
req_query: [{ req_query: [{
name: String, value: String name: String, value: String
}], }],
@ -90,8 +90,10 @@ var interfaceCase = function (_baseModel) {
} }
}, { }, {
key: 'list', key: 'list',
value: function list() { value: function list(col_id) {
return this.model.find().select("casename uid col_id _id index").exec(); return this.model.find({
col_id: col_id
}).select("casename uid col_id _id index").exec();
} }
}, { }, {
key: 'del', key: 'del',

View File

@ -339,7 +339,7 @@ function createAction(controller, action, path, method) {
break; break;
case 8: case 8:
ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录.'); ctx.body = _yapi2.default.commons.resReturn(null, 40011, '请登录...');
case 9: case 9:
case 'end': case 'end':