mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
db66f448d2
@ -254,9 +254,6 @@ class AddInterface extends Component {
|
|||||||
<Result isSave={isSave} mockJson={mockJson} />
|
<Result isSave={isSave} mockJson={mockJson} />
|
||||||
<MockUrl mockURL={mockURL} />
|
<MockUrl mockURL={mockURL} />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
{
|
|
||||||
// <TabPane tab="Mock" key="2">mock</TabPane>
|
|
||||||
}
|
|
||||||
<TabPane tab="请求接口" key="3">
|
<TabPane tab="请求接口" key="3">
|
||||||
<InterfaceTest />
|
<InterfaceTest />
|
||||||
</TabPane>
|
</TabPane>
|
||||||
|
@ -65,10 +65,14 @@ class InterfaceTable extends Component {
|
|||||||
title: '接口名称',
|
title: '接口名称',
|
||||||
dataIndex: 'title',
|
dataIndex: 'title',
|
||||||
key: 'title'
|
key: 'title'
|
||||||
}, {
|
},{
|
||||||
title: '接口URL',
|
title: '接口URL',
|
||||||
dataIndex: 'path',
|
dataIndex: 'path',
|
||||||
key: 'path'
|
key: 'path'
|
||||||
|
},{
|
||||||
|
title: '请求方式',
|
||||||
|
dataIndex: 'method',
|
||||||
|
key: 'method'
|
||||||
},{
|
},{
|
||||||
title: '更新日期',
|
title: '更新日期',
|
||||||
dataIndex: 'add_time',
|
dataIndex: 'add_time',
|
||||||
|
@ -38,6 +38,7 @@ class interfaceController extends baseController{
|
|||||||
async add(ctx){
|
async add(ctx){
|
||||||
let params = ctx.request.body;
|
let params = ctx.request.body;
|
||||||
params = yapi.commons.handleParams(params, {
|
params = yapi.commons.handleParams(params, {
|
||||||
|
project_id: 'number',
|
||||||
title: 'string',
|
title: 'string',
|
||||||
path: 'string',
|
path: 'string',
|
||||||
method: 'string',
|
method: 'string',
|
||||||
@ -57,8 +58,9 @@ class interfaceController extends baseController{
|
|||||||
if(!yapi.commons.verifyPath(params.path)){
|
if(!yapi.commons.verifyPath(params.path)){
|
||||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/')
|
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let checkRepeat = await this.Model.checkRepeat(params.project_id, params.path, params.method);
|
||||||
|
|
||||||
let checkRepeat = await this.Model.checkRepeat(params.path, params.method);
|
|
||||||
if(checkRepeat > 0){
|
if(checkRepeat > 0){
|
||||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
||||||
}
|
}
|
||||||
@ -184,7 +186,7 @@ class interfaceController extends baseController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method){
|
if(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method){
|
||||||
let checkRepeat = await this.Model.checkRepeat(params.path, params.method);
|
let checkRepeat = await this.Model.checkRepeat(interfaceData.project_id,params.path, params.method);
|
||||||
if(checkRepeat > 0){
|
if(checkRepeat > 0){
|
||||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']');
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,9 @@ class interfaceModel extends baseModel{
|
|||||||
}).exec()
|
}).exec()
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRepeat(path, method){
|
checkRepeat(id, path, method){
|
||||||
return this.model.count({
|
return this.model.count({
|
||||||
|
project_id: id,
|
||||||
path: path,
|
path: path,
|
||||||
method: method
|
method: method
|
||||||
})
|
})
|
||||||
|
@ -95,6 +95,7 @@ var interfaceController = function (_baseController) {
|
|||||||
params = ctx.request.body;
|
params = ctx.request.body;
|
||||||
|
|
||||||
params = _yapi2.default.commons.handleParams(params, {
|
params = _yapi2.default.commons.handleParams(params, {
|
||||||
|
project_id: 'number',
|
||||||
title: 'string',
|
title: 'string',
|
||||||
path: 'string',
|
path: 'string',
|
||||||
method: 'string',
|
method: 'string',
|
||||||
@ -129,7 +130,7 @@ var interfaceController = function (_baseController) {
|
|||||||
|
|
||||||
case 11:
|
case 11:
|
||||||
_context.next = 13;
|
_context.next = 13;
|
||||||
return this.Model.checkRepeat(params.path, params.method);
|
return this.Model.checkRepeat(params.project_id, params.path, params.method);
|
||||||
|
|
||||||
case 13:
|
case 13:
|
||||||
checkRepeat = _context.sent;
|
checkRepeat = _context.sent;
|
||||||
@ -393,7 +394,7 @@ var interfaceController = function (_baseController) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_context4.next = 15;
|
_context4.next = 15;
|
||||||
return this.Model.checkRepeat(params.path, params.method);
|
return this.Model.checkRepeat(interfaceData.project_id, params.path, params.method);
|
||||||
|
|
||||||
case 15:
|
case 15:
|
||||||
checkRepeat = _context4.sent;
|
checkRepeat = _context4.sent;
|
||||||
|
@ -96,8 +96,9 @@ var interfaceModel = function (_baseModel) {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
key: 'checkRepeat',
|
key: 'checkRepeat',
|
||||||
value: function checkRepeat(path, method) {
|
value: function checkRepeat(id, path, method) {
|
||||||
return this.model.count({
|
return this.model.count({
|
||||||
|
project_id: id,
|
||||||
path: path,
|
path: path,
|
||||||
method: method
|
method: method
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user