diff --git a/client/components/AuthenticatedComponent.js b/client/components/AuthenticatedComponent.js index 8ba04f6b..2932c6ca 100644 --- a/client/components/AuthenticatedComponent.js +++ b/client/components/AuthenticatedComponent.js @@ -2,7 +2,6 @@ import React from 'react'; import { connect } from 'react-redux'; import PropTypes from 'prop-types' import { changeMenuItem } from '../actions/menu' -import { message } from 'antd' export function requireAuthentication(Component) { @@ -27,7 +26,6 @@ export function requireAuthentication(Component) { if( !this.props.isAuthenticated ){ this.props.history.push('/'); this.props.changeMenuItem('/'); - message.info('请先登录',1); } } render() { diff --git a/client/components/Header/Header.js b/client/components/Header/Header.js index 6befff12..e308d072 100644 --- a/client/components/Header/Header.js +++ b/client/components/Header/Header.js @@ -88,6 +88,9 @@ class HeaderCom extends Component { } linkTo = (e) =>{ this.props.changeMenuItem(e.key); + if(!this.props.login){ + message.info('请先登录',1); + } } relieveLink = () => { this.props.changeMenuItem(""); diff --git a/server/controllers/interface.js b/server/controllers/interface.js index 67dfd945..a01f3bb1 100644 --- a/server/controllers/interface.js +++ b/server/controllers/interface.js @@ -38,6 +38,7 @@ class interfaceController extends baseController{ async add(ctx){ let params = ctx.request.body; params = yapi.commons.handleParams(params, { + project_id: 'number', title: 'string', path: 'string', method: 'string', @@ -57,8 +58,9 @@ class interfaceController extends baseController{ if(!yapi.commons.verifyPath(params.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){ 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){ - 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){ return ctx.body = yapi.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'); } diff --git a/server/models/interface.js b/server/models/interface.js index c7b9598d..d0cb3f56 100644 --- a/server/models/interface.js +++ b/server/models/interface.js @@ -54,8 +54,9 @@ class interfaceModel extends baseModel{ }).exec() } - checkRepeat(path, method){ + checkRepeat(id, path, method){ return this.model.count({ + project_id: id, path: path, method: method }) diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js index 603da0d3..039bd5ad 100644 --- a/server_dist/controllers/interface.js +++ b/server_dist/controllers/interface.js @@ -95,6 +95,7 @@ var interfaceController = function (_baseController) { params = ctx.request.body; params = _yapi2.default.commons.handleParams(params, { + project_id: 'number', title: 'string', path: 'string', method: 'string', @@ -129,7 +130,7 @@ var interfaceController = function (_baseController) { case 11: _context.next = 13; - return this.Model.checkRepeat(params.path, params.method); + return this.Model.checkRepeat(params.project_id, params.path, params.method); case 13: checkRepeat = _context.sent; @@ -393,7 +394,7 @@ var interfaceController = function (_baseController) { } _context4.next = 15; - return this.Model.checkRepeat(params.path, params.method); + return this.Model.checkRepeat(interfaceData.project_id, params.path, params.method); case 15: checkRepeat = _context4.sent; diff --git a/server_dist/models/interface.js b/server_dist/models/interface.js index 82d6e22b..15242016 100644 --- a/server_dist/models/interface.js +++ b/server_dist/models/interface.js @@ -96,8 +96,9 @@ var interfaceModel = function (_baseModel) { } }, { key: 'checkRepeat', - value: function checkRepeat(path, method) { + value: function checkRepeat(id, path, method) { return this.model.count({ + project_id: id, path: path, method: method });