mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-06 15:00:26 +08:00
feat: modify db config
This commit is contained in:
parent
553d3faca0
commit
ef1a26c222
@ -1,5 +1,6 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col, Icon , Input, Button, Select} from 'antd'
|
||||
import axios from 'axios';
|
||||
|
||||
class Profile extends Component {
|
||||
|
||||
@ -11,6 +12,7 @@ class Profile extends Component {
|
||||
secureEdit: false,
|
||||
roleEdit: false
|
||||
}
|
||||
this.getUserInfo(101)
|
||||
}
|
||||
|
||||
handleEdit = (key, val) =>{
|
||||
@ -19,6 +21,14 @@ class Profile extends Component {
|
||||
this.setState(s)
|
||||
}
|
||||
|
||||
getUserInfo = (id) => {
|
||||
axios.get('/user/find', {
|
||||
id: id
|
||||
}).then((res) =>{
|
||||
console.log(res)
|
||||
})
|
||||
}
|
||||
|
||||
render() {
|
||||
let ButtonGroup = Button.Group;
|
||||
let userNameEditHtml, emailEditHtml,secureEditHtml, roleEditHtml;
|
||||
|
@ -30,9 +30,8 @@ class User extends Component {
|
||||
|
||||
<LeftMenu />
|
||||
|
||||
<Route path={this.props.match.path + '/list'} component={List} />
|
||||
<Route path={this.props.match.path + '/profile'} component={Profile
|
||||
} />
|
||||
<Route path={this.props.match.path + '/list/:uid'} component={List} />
|
||||
<Route path={this.props.match.path + '/profile'} component={Profile} />
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
|
@ -6,8 +6,8 @@
|
||||
"servername": "10.86.40.194",
|
||||
"DATABASE": "yapi",
|
||||
"port": 27017,
|
||||
"user": "yapi",
|
||||
"pass": "yapi"
|
||||
"user": "test1",
|
||||
"pass": "test1"
|
||||
},
|
||||
"mail": {
|
||||
"host": "smtp.163.com",
|
||||
|
@ -38,7 +38,7 @@ createAction('group', 'del', 'post', 'del')
|
||||
createAction('user', 'login', 'post', 'login')
|
||||
createAction('user', 'reg', 'post', 'reg')
|
||||
createAction('user', 'list', 'get', 'list')
|
||||
createAction('user', 'find', 'post', 'findById')
|
||||
createAction('user', 'find', 'get', 'findById')
|
||||
createAction('user', 'update', 'post', 'update')
|
||||
createAction('user', 'del', 'post', 'del')
|
||||
createAction('user', 'status', 'get', 'getLoginStatus')
|
||||
|
@ -36,6 +36,7 @@ function setupSql() {
|
||||
var userInst = _yapi2.default.getInst(_user2.default);
|
||||
var passsalt = _yapi2.default.commons.randStr();
|
||||
var result = userInst.save({
|
||||
username: _yapi2.default.WEBCONFIG.adminAccount.substr(0, _yapi2.default.WEBCONFIG.adminAccount.indexOf('@')),
|
||||
email: _yapi2.default.WEBCONFIG.adminAccount,
|
||||
password: _yapi2.default.commons.generatePassword('qunar.com', passsalt),
|
||||
passsalt: passsalt,
|
||||
|
@ -28,7 +28,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
||||
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var hostname, config, projectInst, projects, matchProject, i, l, _project, project, interfaceData, interfaceInst;
|
||||
var hostname, config, projectInst, projects, matchProject, maxBasepath, i, l, _project, project, interfaceData, interfaceInst;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -71,17 +71,21 @@ module.exports = function () {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 403, _context.t0.message));
|
||||
|
||||
case 18:
|
||||
matchProject = [];
|
||||
matchProject = false, maxBasepath = 0;
|
||||
|
||||
for (i = 0, l = projects.length; i < l; i++) {
|
||||
_project = projects[i];
|
||||
|
||||
if (ctx.path && ctx.path.indexOf(_project.basepath) === 0 && _project.basepath[_project.basepath.length - 1] === '/') {
|
||||
matchProject.push(_project);
|
||||
if (_project.basepath.length > maxBasepath) {
|
||||
maxBasepath = _project.basepath.length;
|
||||
matchProject = _project;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(matchProject.length === 0)) {
|
||||
if (!(matchProject === false)) {
|
||||
_context.next = 22;
|
||||
break;
|
||||
}
|
||||
@ -89,63 +93,55 @@ module.exports = function () {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不存在的domain'));
|
||||
|
||||
case 22:
|
||||
if (!(matchProject.length > 1)) {
|
||||
_context.next = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '存在多个project,请检查数据库'));
|
||||
|
||||
case 24:
|
||||
project = matchProject[0], interfaceData = void 0;
|
||||
project = matchProject, interfaceData = void 0;
|
||||
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
||||
_context.prev = 26;
|
||||
_context.next = 29;
|
||||
_context.prev = 24;
|
||||
_context.next = 27;
|
||||
return interfaceInst.getByPath(project._id, ctx.path.substr(project.basepath.length));
|
||||
|
||||
case 29:
|
||||
case 27:
|
||||
interfaceData = _context.sent;
|
||||
|
||||
if (!(!interfaceData || interfaceData.length === 0)) {
|
||||
_context.next = 32;
|
||||
_context.next = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 404, '不存在的api'));
|
||||
|
||||
case 32:
|
||||
case 30:
|
||||
if (!(interfaceData.length > 1)) {
|
||||
_context.next = 34;
|
||||
_context.next = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '存在多个api,请检查数据库'));
|
||||
|
||||
case 34:
|
||||
case 32:
|
||||
|
||||
interfaceData = interfaceData[0];
|
||||
|
||||
if (!(interfaceData.res_body_type === 'json')) {
|
||||
_context.next = 37;
|
||||
_context.next = 35;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _mockjs2.default.mock(_yapi2.default.commons.json_parse(interfaceData.res_body)));
|
||||
|
||||
case 37:
|
||||
case 35:
|
||||
return _context.abrupt('return', ctx.body = interfaceData.res_body);
|
||||
|
||||
case 40:
|
||||
_context.prev = 40;
|
||||
_context.t1 = _context['catch'](26);
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.t1 = _context['catch'](24);
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 409, _context.t1.message));
|
||||
|
||||
case 43:
|
||||
case 41:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, undefined, [[9, 15], [26, 40]]);
|
||||
}, _callee, undefined, [[9, 15], [24, 38]]);
|
||||
}));
|
||||
|
||||
return function (_x, _x2) {
|
||||
|
@ -65,7 +65,7 @@ createAction('group', 'del', 'post', 'del');
|
||||
createAction('user', 'login', 'post', 'login');
|
||||
createAction('user', 'reg', 'post', 'reg');
|
||||
createAction('user', 'list', 'get', 'list');
|
||||
createAction('user', 'find', 'post', 'findById');
|
||||
createAction('user', 'find', 'get', 'findById');
|
||||
createAction('user', 'update', 'post', 'update');
|
||||
createAction('user', 'del', 'post', 'del');
|
||||
createAction('user', 'status', 'get', 'getLoginStatus');
|
||||
|
@ -27,7 +27,10 @@ function connect() {
|
||||
_mongoose2.default.Promise = global.Promise;
|
||||
var config = _yapi2.default.WEBCONFIG;
|
||||
|
||||
var db = _mongoose2.default.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE);
|
||||
var db = _mongoose2.default.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE, {
|
||||
user: config.db.user,
|
||||
pass: config.db.pass
|
||||
});
|
||||
|
||||
db.then(function (res) {
|
||||
_yapi2.default.commons.log('mongodb load success...');
|
||||
|
Loading…
x
Reference in New Issue
Block a user