Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
sean 2017-09-05 17:05:33 +08:00
commit a85a6a283e
61 changed files with 114 additions and 10480 deletions

View File

@ -3,6 +3,7 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Row, Col } from 'antd';
import { Icon } from 'antd'
import packageJson from '../../../package.json';
class Footer extends Component {
constructor(props) {
super(props)
@ -100,7 +101,7 @@ Footer.defaultProps = {
iconType: 'layout',
linkList: [
{
itemTitle: '版本: 1.0',
itemTitle: '版本: '+packageJson.version,
itemLink: 'javascript:'
}
]

View File

@ -19,7 +19,7 @@ class Subnav extends Component {
<div className="m-subnav">
<Menu
onClick={this.handleClick}
defaultSelectedKeys={[this.props.default]}
selectedKeys={[this.props.default]}
mode="horizontal"
className="g-row m-subnav-menu"
>
@ -29,7 +29,7 @@ class Subnav extends Component {
item.name = item.name[0] + ' ' + item.name[1];
}
return (
<Menu.Item className="item" key={item.name}>
<Menu.Item className="item" key={item.name.replace(' ', '')}>
<Link to={item.path}>{this.props.data[index].name}</Link>
</Menu.Item>
)

View File

@ -79,6 +79,7 @@ class Interface extends Component {
render() {
const { action } = this.props.match.params;
const activeKey = action === 'api' ? 'api' : 'colOrCase';
// console.log(matchPath(this.props.location.pathname, contentRouter));
return <div className="web-content g-row" style={{ marginBottom: "15px" }}>
<Row gutter={16} >
<Col span={6}>

View File

@ -5,6 +5,7 @@
.menu-title {
display: flex;
justify-content: space-between;
overflow: hidden;
.case-delete-icon{
display: none;
}

View File

@ -14,7 +14,9 @@ const TreeNode = Tree.TreeNode;
@connect(
state => {
return {
list: state.inter.list,
inter: state.inter.curdata,
@ -213,8 +215,38 @@ class InterfaceMenu extends Component {
render() {
const matchParams = this.props.match.params;
let menuList = this.props.list;
const searchBox = <div className="interface-filter">
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
<Modal
title="添加接口"
visible={this.state.visible}
onCancel={() => this.changeModal('visible', false)}
footer={null}
>
<AddInterfaceForm catdata={this.props.curProject.cat} catid={this.state.curCatid} onCancel={() => this.changeModal('visible', false)} onSubmit={this.handleAddInterface} />
</Modal>
<Modal
title="添加分类"
visible={this.state.add_cat_modal_visible}
onCancel={() => this.changeModal('add_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm onCancel={() => this.changeModal('add_cat_modal_visible', false)} onSubmit={this.handleAddInterfaceCat} />
</Modal>
<Modal
title="修改分类"
visible={this.state.change_cat_modal_visible}
onCancel={() => this.changeModal('change_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm catdata={this.state.curCatdata} onCancel={() => this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} />
</Modal>
</div>
if(menuList.length === 0){
return null;
return searchBox;
}
const defaultExpandedKeys = () => {
const { router, inter, list } = this.props, rNull = { expands: [], selects: [] };
@ -307,36 +339,7 @@ class InterfaceMenu extends Component {
}
}
return <div>
<div className="interface-filter">
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
<Modal
title="添加接口"
visible={this.state.visible}
onCancel={() => this.changeModal('visible', false)}
footer={null}
>
<AddInterfaceForm catdata={this.props.curProject.cat} catid={this.state.curCatid} onCancel={() => this.changeModal('visible', false)} onSubmit={this.handleAddInterface} />
</Modal>
<Modal
title="添加分类"
visible={this.state.add_cat_modal_visible}
onCancel={() => this.changeModal('add_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm onCancel={() => this.changeModal('add_cat_modal_visible', false)} onSubmit={this.handleAddInterfaceCat} />
</Modal>
<Modal
title="修改分类"
visible={this.state.change_cat_modal_visible}
onCancel={() => this.changeModal('change_cat_modal_visible', false)}
footer={null}
>
<AddInterfaceCatForm catdata={this.state.curCatdata} onCancel={() => this.changeModal('change_cat_modal_visible', false)} onSubmit={this.handleChangeInterfaceCat} />
</Modal>
</div>
{searchBox}
{menuList.length > 0 ?
<Tree
className="interface-list"
@ -356,7 +359,7 @@ class InterfaceMenu extends Component {
</Dropdown>
</div>}
key={'cat_' + item._id}
className="interface-item-nav"
className={`interface-item-nav ${item.list.length?"":"cat_switch_hidden"}`}
>
{item.list.map(item_interface_create)}

View File

@ -31,9 +31,10 @@ class View extends Component {
req_body_form(req_body_type,req_body_form){
if(req_body_type === 'json'){
let h = this.countEnter(this.props.curData.req_body_other);
return <div style={{display:this.props.curData.req_body_other?"block":"none"}} className="colBody">
<span className="colKey">请求Body</span>
<div id="vreq_body_json" style={{ minHeight: "200px" }}></div>
<div id="vreq_body_json" style={{ minHeight: h*16+20 }}></div>
</div>
}else if(req_body_type === 'form'){
@ -92,9 +93,10 @@ class View extends Component {
}
res_body(res_body_type,res_body){
if(res_body_type === 'json'){
let h = this.countEnter(this.props.curData.req_body_other);
return <div style={{display:this.props.curData.res_body?"":"none"}} className="colBody">
<span className="colKey">返回Body</span>
<div id="vres_body_json" style={{ minHeight: "200px" }}></div>
<div id="vres_body_json" style={{ minHeight: h*16+20 }}></div>
</div>
}else if(res_body_type === 'raw'){
return <div style={{display:this.props.curData.res_body?"":"none"}} className="colBody">
@ -135,9 +137,19 @@ class View extends Component {
return <Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />;
}
countEnter(str){
let i = 0;
let c = 0;
if(!str||!str.indexOf) return 0;
while(str.indexOf('\n',i)>-1){
i = str.indexOf('\n',i) + 2;
c++;
}
return c;
}
bindAceEditor(){
if(this.props.curData.req_body_type === "json"&&this.props.curData.title){
// console.log(this.props.curData.req_body_other.indexOf("\n"));
mockEditor({
container: 'vreq_body_json',
data: this.props.curData.req_body_other,

View File

@ -93,4 +93,9 @@
text-indent: 2em;
}
}
// .ace_scroller{
// position: relative;
// margin-left: 50px;
// overflow:visible;
// }
}

View File

@ -51,6 +51,13 @@
background-color: #efefef
}
.interface-list{
.cat_switch_hidden{
.ant-tree-switcher{
visibility: hidden;
}
}
a{
color: #333
}
@ -85,7 +92,7 @@
}
}
}
.right-content{
margin:3px;
min-height: 5rem;

5
doc/page/usage/api.md Normal file
View File

@ -0,0 +1,5 @@
## 介绍
## 接口配置
## 接口调试

View File

@ -1,5 +1,7 @@
## 介绍
## 组长职责
## 安装 crossRequest chrome 插件
## 使用说明
## 权限列表

View File

View File

@ -1,3 +0,0 @@
## 介绍
## 配置说明

View File

@ -1,3 +0,0 @@
## 什么是组长
## 组长职责

View File

@ -1,102 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('./yapi.js');
var commons = require('./utils/commons');
yapi.commons = commons;
var dbModule = require('./utils/db.js');
var mockServer = require('./middleware/mockServer.js');
var Koa = require('koa');
var koaStatic = require('koa-static');
var bodyParser = require('koa-bodyparser');
var router = require('./router.js');
var websockify = require('koa-websocket');
var websocket = require('./websocket.js');
yapi.connect = dbModule.connect();
var app = websockify(new Koa());
var indexFile = process.argv[2] === 'dev' ? 'dev.html' : 'index.html';
app.use(mockServer);
app.use(bodyParser({ multipart: true }));
app.use(router.routes());
app.use(router.allowedMethods());
websocket(app);
app.use(function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!/^\/(?!api)[a-zA-Z0-9\/\-_]*$/.test(ctx.path)) {
_context.next = 6;
break;
}
ctx.path = "/";
_context.next = 4;
return next();
case 4:
_context.next = 8;
break;
case 6:
_context.next = 8;
return next();
case 8:
case 'end':
return _context.stop();
}
}
}, _callee, undefined);
}));
return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}());
app.use(function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx, next) {
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (ctx.path.indexOf('/prd') === 0) {
if (yapi.commons.fileExist(yapi.path.join(yapi.WEBROOT, 'static', ctx.path + '.gz'))) {
ctx.set('Content-Encoding', 'gzip');
ctx.path = ctx.path + '.gz';
}
}
_context2.next = 3;
return next();
case 3:
case 'end':
return _context2.stop();
}
}
}, _callee2, undefined);
}));
return function (_x3, _x4) {
return _ref2.apply(this, arguments);
};
}());
app.use(koaStatic(yapi.path.join(yapi.WEBROOT, 'static'), { index: indexFile, gzip: true }));
app.listen(yapi.WEBCONFIG.port);
commons.log('the server is start at port ' + yapi.WEBCONFIG.port);

View File

@ -1,427 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var projectModel = require('../models/project.js');
var userModel = require('../models/user.js');
var interfaceModel = require('../models/interface.js');
var groupModel = require('../models/group.js');
var _ = require('underscore');
var jwt = require('jsonwebtoken');
var baseController = function () {
function baseController(ctx) {
(0, _classCallCheck3.default)(this, baseController);
this.ctx = ctx;
//网站上线后role对象key是不能修改的value可以修改
this.roles = {
admin: 'Admin',
member: '网站会员'
};
}
(0, _createClass3.default)(baseController, [{
key: 'init',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var ignoreRouter;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
this.$user = null;
ignoreRouter = ['/api/user/login_by_token', '/api/user/login', '/api/user/reg', '/api/user/status', '/api/user/logout'];
if (!(ignoreRouter.indexOf(ctx.path) > -1)) {
_context.next = 6;
break;
}
this.$auth = true;
_context.next = 8;
break;
case 6:
_context.next = 8;
return this.checkLogin(ctx);
case 8:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function init(_x) {
return _ref.apply(this, arguments);
}
return init;
}()
}, {
key: 'getUid',
value: function getUid() {
return parseInt(this.$uid, 10);
}
}, {
key: 'checkLogin',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var token, uid, userInst, result, decoded;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
token = ctx.cookies.get('_yapi_token');
uid = ctx.cookies.get('_yapi_uid');
_context2.prev = 2;
if (!(!token || !uid)) {
_context2.next = 5;
break;
}
return _context2.abrupt('return', false);
case 5:
userInst = yapi.getInst(userModel); //创建user实体
_context2.next = 8;
return userInst.findById(uid);
case 8:
result = _context2.sent;
decoded = jwt.verify(token, result.passsalt);
if (!(decoded.uid == uid)) {
_context2.next = 15;
break;
}
this.$uid = uid;
this.$auth = true;
this.$user = result;
return _context2.abrupt('return', true);
case 15:
return _context2.abrupt('return', false);
case 18:
_context2.prev = 18;
_context2.t0 = _context2['catch'](2);
return _context2.abrupt('return', false);
case 21:
case 'end':
return _context2.stop();
}
}
}, _callee2, this, [[2, 18]]);
}));
function checkLogin(_x2) {
return _ref2.apply(this, arguments);
}
return checkLogin;
}()
/**
*
* @param {*} ctx
*/
}, {
key: 'getLoginStatus',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return this.checkLogin(ctx);
case 2:
_context3.t0 = _context3.sent;
if (!(_context3.t0 === true)) {
_context3.next = 7;
break;
}
result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role', 'type']);
result.server_ip = yapi.WEBCONFIG.server_ip;
return _context3.abrupt('return', ctx.body = yapi.commons.resReturn(result));
case 7:
return _context3.abrupt('return', ctx.body = yapi.commons.resReturn(null, 40011, '请登录...'));
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, this);
}));
function getLoginStatus(_x3) {
return _ref3.apply(this, arguments);
}
return getLoginStatus;
}()
}, {
key: 'getRole',
value: function getRole() {
return this.$user.role;
}
}, {
key: 'getUsername',
value: function getUsername() {
return this.$user.username;
}
}, {
key: 'getProjectRole',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(id, type) {
var _this = this;
var result, interfaceInst, interfaceData, projectInst, projectData, memberData, groupInst, groupData, groupMemberData;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
result = {};
_context4.prev = 1;
if (!(this.getRole() === 'admin')) {
_context4.next = 4;
break;
}
return _context4.abrupt('return', 'admin');
case 4:
if (!(type === 'interface')) {
_context4.next = 14;
break;
}
interfaceInst = yapi.getInst(interfaceModel);
_context4.next = 8;
return interfaceInst.get(id);
case 8:
interfaceData = _context4.sent;
result.interfaceData = interfaceData;
if (!(interfaceData.uid === this.getUid())) {
_context4.next = 12;
break;
}
return _context4.abrupt('return', 'owner');
case 12:
type = 'project';
id = interfaceData.project_id;
case 14:
if (!(type === 'project')) {
_context4.next = 30;
break;
}
projectInst = yapi.getInst(projectModel);
_context4.next = 18;
return projectInst.get(id);
case 18:
projectData = _context4.sent;
if (!(projectData.uid === this.getUid())) {
_context4.next = 21;
break;
}
return _context4.abrupt('return', 'owner');
case 21:
memberData = _.find(projectData.members, function (m) {
if (m.uid === _this.getUid()) {
return true;
}
});
if (!(memberData && memberData.role)) {
_context4.next = 28;
break;
}
if (!(memberData.role === 'owner')) {
_context4.next = 27;
break;
}
return _context4.abrupt('return', 'owner');
case 27:
return _context4.abrupt('return', 'dev');
case 28:
type = 'group';
id = projectData.group_id;
case 30:
if (!(type === 'group')) {
_context4.next = 42;
break;
}
groupInst = yapi.getInst(groupModel);
_context4.next = 34;
return groupInst.get(id);
case 34:
groupData = _context4.sent;
groupMemberData = _.find(groupData.members, function (m) {
if (m.uid === _this.getUid()) {
return true;
}
});
if (!(groupMemberData && groupMemberData.role)) {
_context4.next = 42;
break;
}
if (!(groupMemberData.role === 'owner')) {
_context4.next = 41;
break;
}
return _context4.abrupt('return', 'owner');
case 41:
return _context4.abrupt('return', 'dev');
case 42:
return _context4.abrupt('return', 'member');
case 45:
_context4.prev = 45;
_context4.t0 = _context4['catch'](1);
yapi.commons.log(_context4.t0.message, 'error');
return _context4.abrupt('return', false);
case 49:
case 'end':
return _context4.stop();
}
}
}, _callee4, this, [[1, 45]]);
}));
function getProjectRole(_x4, _x5) {
return _ref4.apply(this, arguments);
}
return getProjectRole;
}()
/**
*
* @param {*} id type对应的id
* @param {*} type enum[interface, project, group]
* @param {*} action enum[ danger , edit ] danger只有owner或管理员才能操作,edit只要是dev或以上就能执行
*/
}, {
key: 'checkAuth',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(id, type, action) {
var role;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return this.getProjectRole(id, type);
case 2:
role = _context5.sent;
if (!(action === 'danger')) {
_context5.next = 8;
break;
}
if (!(role === 'admin' || role === 'owner')) {
_context5.next = 6;
break;
}
return _context5.abrupt('return', true);
case 6:
_context5.next = 11;
break;
case 8:
if (!(action === 'edit')) {
_context5.next = 11;
break;
}
if (!(role === 'admin' || role === 'owner' || role === 'dev')) {
_context5.next = 11;
break;
}
return _context5.abrupt('return', true);
case 11:
return _context5.abrupt('return', false);
case 12:
case 'end':
return _context5.stop();
}
}
}, _callee5, this);
}));
function checkAuth(_x6, _x7, _x8) {
return _ref5.apply(this, arguments);
}
return checkAuth;
}()
}]);
return baseController;
}();
module.exports = baseController;

View File

@ -1,293 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseController = require('./base.js');
var followModel = require('../models/follow');
var projectModel = require('../models/project');
var followController = function (_baseController) {
(0, _inherits3.default)(followController, _baseController);
function followController(ctx) {
(0, _classCallCheck3.default)(this, followController);
var _this = (0, _possibleConstructorReturn3.default)(this, (followController.__proto__ || (0, _getPrototypeOf2.default)(followController)).call(this, ctx));
_this.Model = yapi.getInst(followModel);
_this.projectModel = yapi.getInst(projectModel);
return _this;
}
/**
* 获取关注项目列表
* @interface /follow/list
* @method GET
* @category follow
* @foldnumber 10
* @param {Number} [page] 分页页码
* @param {Number} [limit] 分页大小
* @returns {Object}
* @example /follow/list
*/
(0, _createClass3.default)(followController, [{
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var uid, page, limit, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
uid = this.getUid(), page = ctx.request.query.page || 1, limit = ctx.request.query.limit || 10;
if (uid) {
_context.next = 3;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '用户id不能为空'));
case 3:
_context.prev = 3;
_context.next = 6;
return this.Model.list(uid);
case 6:
result = _context.sent;
ctx.body = yapi.commons.resReturn({
list: result
});
_context.next = 13;
break;
case 10:
_context.prev = 10;
_context.t0 = _context['catch'](3);
ctx.body = yapi.commons.resReturn(null, 402, _context.t0.message);
case 13:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[3, 10]]);
}));
function list(_x) {
return _ref.apply(this, arguments);
}
return list;
}()
/**
* 取消关注
* @interface /follow/del
* @method POST
* @category follow
* @foldnumber 10
* @param {Number} projectid
* @returns {Object}
* @example /follow/del
*/
}, {
key: 'del',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var params, uid, checkRepeat, result;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
params = ctx.request.body, uid = this.getUid();
if (params.projectid) {
_context2.next = 3;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'));
case 3:
_context2.next = 5;
return this.Model.checkProjectRepeat(uid, params.projectid);
case 5:
checkRepeat = _context2.sent;
if (!(checkRepeat == 0)) {
_context2.next = 8;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 401, '项目未关注'));
case 8:
_context2.prev = 8;
_context2.next = 11;
return this.Model.del(params.projectid, this.getUid());
case 11:
result = _context2.sent;
ctx.body = yapi.commons.resReturn(result);
_context2.next = 18;
break;
case 15:
_context2.prev = 15;
_context2.t0 = _context2['catch'](8);
ctx.body = yapi.commons.resReturn(null, 402, _context2.t0.message);
case 18:
case 'end':
return _context2.stop();
}
}
}, _callee2, this, [[8, 15]]);
}));
function del(_x2) {
return _ref2.apply(this, arguments);
}
return del;
}()
/**
* 添加关注
* @interface /follow/add
* @method GET
* @category follow
* @foldnumber 10
* @param {Number} projectid 项目id
* @param {String} projectname 项目名
* @param {String} icon 项目icon
* @returns {Object}
* @example /follow/add
*/
}, {
key: 'add',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
var params, uid, checkRepeat, project, data, result;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
params = ctx.request.body;
params = yapi.commons.handleParams(params, {
projectid: 'number'
});
uid = this.getUid();
if (params.projectid) {
_context3.next = 5;
break;
}
return _context3.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'));
case 5:
_context3.next = 7;
return this.Model.checkProjectRepeat(uid, params.projectid);
case 7:
checkRepeat = _context3.sent;
if (!checkRepeat) {
_context3.next = 10;
break;
}
return _context3.abrupt('return', ctx.body = yapi.commons.resReturn(null, 401, '项目已关注'));
case 10:
_context3.prev = 10;
_context3.next = 13;
return this.projectModel.get(params.projectid);
case 13:
project = _context3.sent;
data = {
uid: uid,
projectid: params.projectid,
projectname: project.name,
icon: project.icon,
color: project.color
};
_context3.next = 17;
return this.Model.save(data);
case 17:
result = _context3.sent;
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon', 'color']);
ctx.body = yapi.commons.resReturn(result);
_context3.next = 25;
break;
case 22:
_context3.prev = 22;
_context3.t0 = _context3['catch'](10);
ctx.body = yapi.commons.resReturn(null, 402, _context3.t0.message);
case 25:
case 'end':
return _context3.stop();
}
}
}, _callee3, this, [[10, 22]]);
}));
function add(_x3) {
return _ref3.apply(this, arguments);
}
return add;
}()
}]);
return followController;
}(baseController);
module.exports = followController;

View File

@ -1,930 +0,0 @@
'use strict';
var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var groupModel = require('../models/group.js');
var yapi = require('../yapi.js');
var baseController = require('./base.js');
var projectModel = require('../models/project.js');
var userModel = require('../models/user.js');
var interfaceModel = require('../models/interface.js');
var interfaceColModel = require('../models/interfaceCol.js');
var interfaceCaseModel = require('../models/interfaceCase.js');
var groupController = function (_baseController) {
(0, _inherits3.default)(groupController, _baseController);
function groupController(ctx) {
(0, _classCallCheck3.default)(this, groupController);
return (0, _possibleConstructorReturn3.default)(this, (groupController.__proto__ || (0, _getPrototypeOf2.default)(groupController)).call(this, ctx));
}
/**
* 添加项目分组
* @interface /group/get
* @method GET
* @category group
* @foldnumber 10
* @param {String} id 项目分组ID
* @returns {Object}
* @example
*/
(0, _createClass3.default)(groupController, [{
key: 'get',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var params, groupInst, result;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.prev = 0;
params = ctx.request.query;
if (params.id) {
_context.next = 4;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空'));
case 4:
groupInst = yapi.getInst(groupModel);
_context.next = 7;
return groupInst.getGroupById(params.id);
case 7:
result = _context.sent;
result = result.toObject();
_context.next = 11;
return this.getProjectRole(params.id, 'group');
case 11:
result.role = _context.sent;
ctx.body = yapi.commons.resReturn(result);
_context.next = 18;
break;
case 15:
_context.prev = 15;
_context.t0 = _context['catch'](0);
ctx.body = yapi.commons.resReturn(null, 400, _context.t0.message);
case 18:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[0, 15]]);
}));
function get(_x) {
return _ref.apply(this, arguments);
}
return get;
}()
/**
* 添加项目分组
* @interface /group/add
* @method POST
* @category group
* @foldnumber 10
* @param {String} group_name 项目分组名称不能为空
* @param {String} [group_desc] 项目分组描述
* @param {String} owner_uid 组长uid
* @returns {Object}
* @example ./api/group/add.json
*/
}, {
key: 'add',
value: function () {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
var params, groupUserdata, groupInst, checkRepeat, data, result;
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
params = ctx.request.body;
params = yapi.commons.handleParams(params, {
group_name: 'string',
group_desc: 'string',
owner_uid: 'number'
});
if (!(this.getRole() !== 'admin')) {
_context2.next = 4;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 401, '没有权限'));
case 4:
if (params.group_name) {
_context2.next = 6;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '项目分组名不能为空'));
case 6:
if (params.owner_uid) {
_context2.next = 8;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '项目分组必须添加一个组长'));
case 8:
_context2.next = 10;
return this.getUserdata(params.owner_uid, 'owner');
case 10:
groupUserdata = _context2.sent;
if (!(groupUserdata === null)) {
_context2.next = 13;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在'));
case 13:
groupInst = yapi.getInst(groupModel);
_context2.next = 16;
return groupInst.checkRepeat(params.group_name);
case 16:
checkRepeat = _context2.sent;
if (!(checkRepeat > 0)) {
_context2.next = 19;
break;
}
return _context2.abrupt('return', ctx.body = yapi.commons.resReturn(null, 401, '项目分组名已存在'));
case 19:
data = {
group_name: params.group_name,
group_desc: params.group_desc,
uid: this.getUid(),
add_time: yapi.commons.time(),
up_time: yapi.commons.time(),
members: [groupUserdata]
};
_context2.prev = 20;
_context2.next = 23;
return groupInst.save(data);
case 23:
result = _context2.sent;
result = yapi.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid', 'members']);
ctx.body = yapi.commons.resReturn(result);
_context2.next = 31;
break;
case 28:
_context2.prev = 28;
_context2.t0 = _context2['catch'](20);
ctx.body = yapi.commons.resReturn(null, 402, _context2.t0.message);
case 31:
case 'end':
return _context2.stop();
}
}
}, _callee2, this, [[20, 28]]);
}));
function add(_x2) {
return _ref2.apply(this, arguments);
}
return add;
}()
}, {
key: 'getUserdata',
value: function () {
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
var userInst, userData;
return _regenerator2.default.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
role = role || 'dev';
userInst = yapi.getInst(userModel);
_context3.next = 4;
return userInst.findById(uid);
case 4:
userData = _context3.sent;
if (userData) {
_context3.next = 7;
break;
}
return _context3.abrupt('return', null);
case 7:
return _context3.abrupt('return', {
_role: userData.role,
role: role,
uid: userData._id,
username: userData.username,
email: userData.email
});
case 8:
case 'end':
return _context3.stop();
}
}
}, _callee3, this);
}));
function getUserdata(_x3, _x4) {
return _ref3.apply(this, arguments);
}
return getUserdata;
}()
/**
* 添加项目分组成员
* @interface /group/add_member
* @method POST
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @param {String} member_uid 项目分组成员uid
* @param {String} role 成员角色owner or dev
* @returns {Object}
* @example
*/
}, {
key: 'addMember',
value: function () {
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
var params, groupInst, check, groupUserdata, result;
return _regenerator2.default.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
params = ctx.request.body;
groupInst = yapi.getInst(groupModel);
if (params.member_uid) {
_context4.next = 4;
break;
}
return _context4.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空'));
case 4:
if (params.id) {
_context4.next = 6;
break;
}
return _context4.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空'));
case 6:
params.role = params.role === 'owner' ? 'owner' : 'dev';
_context4.next = 9;
return groupInst.checkMemberRepeat(params.id, params.member_uid);
case 9:
check = _context4.sent;
if (!(check > 0)) {
_context4.next = 12;
break;
}
return _context4.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '成员已存在'));
case 12:
_context4.next = 14;
return this.getUserdata(params.member_uid, params.role);
case 14:
groupUserdata = _context4.sent;
if (!(groupUserdata === null)) {
_context4.next = 17;
break;
}
return _context4.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在'));
case 17:
if (!(groupUserdata._role === 'admin')) {
_context4.next = 19;
break;
}
return _context4.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '不能邀请管理员'));
case 19:
delete groupUserdata._role;
_context4.prev = 20;
_context4.next = 23;
return groupInst.addMember(params.id, groupUserdata);
case 23:
result = _context4.sent;
ctx.body = yapi.commons.resReturn(result);
_context4.next = 30;
break;
case 27:
_context4.prev = 27;
_context4.t0 = _context4['catch'](20);
ctx.body = yapi.commons.resReturn(null, 402, _context4.t0.message);
case 30:
case 'end':
return _context4.stop();
}
}
}, _callee4, this, [[20, 27]]);
}));
function addMember(_x5) {
return _ref4.apply(this, arguments);
}
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 权限 ['owner'|'dev']
* @returns {Object}
* @example
*/
}, {
key: 'changeMemberRole',
value: function () {
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
params = ctx.request.body;
groupInst = yapi.getInst(groupModel);
if (params.member_uid) {
_context5.next = 4;
break;
}
return _context5.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空'));
case 4:
if (params.id) {
_context5.next = 6;
break;
}
return _context5.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空'));
case 6:
_context5.next = 8;
return groupInst.checkMemberRepeat(params.id, params.member_uid);
case 8:
check = _context5.sent;
if (!(check === 0)) {
_context5.next = 11;
break;
}
return _context5.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在'));
case 11:
_context5.next = 13;
return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context5.t0 = _context5.sent;
if (!(_context5.t0 !== true)) {
_context5.next = 16;
break;
}
return _context5.abrupt('return', ctx.body = yapi.commons.resReturn(null, 405, '没有权限'));
case 16:
params.role = params.role === 'owner' ? 'owner' : 'dev';
_context5.prev = 17;
_context5.next = 20;
return groupInst.changeMemberRole(params.id, params.member_uid, params.role);
case 20:
result = _context5.sent;
ctx.body = yapi.commons.resReturn(result);
_context5.next = 27;
break;
case 24:
_context5.prev = 24;
_context5.t1 = _context5['catch'](17);
ctx.body = yapi.commons.resReturn(null, 402, _context5.t1.message);
case 27:
case 'end':
return _context5.stop();
}
}
}, _callee5, this, [[17, 24]]);
}));
function changeMemberRole(_x6) {
return _ref5.apply(this, arguments);
}
return changeMemberRole;
}()
/**
* 获取所有项目成员
* @interface /group/get_member_list
* @method GET
* @category group
* @foldnumber 10
* @param {String} id 项目分组id
* @returns {Object}
* @example
*/
}, {
key: 'getMemberList',
value: function () {
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
var params, groupInst, group;
return _regenerator2.default.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
params = ctx.request.query;
if (params.id) {
_context6.next = 3;
break;
}
return _context6.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空'));
case 3:
_context6.prev = 3;
groupInst = yapi.getInst(groupModel);
_context6.next = 7;
return groupInst.get(params.id);
case 7:
group = _context6.sent;
ctx.body = yapi.commons.resReturn(group.members);
_context6.next = 14;
break;
case 11:
_context6.prev = 11;
_context6.t0 = _context6['catch'](3);
ctx.body = yapi.commons.resReturn(null, 402, _context6.t0.message);
case 14:
case 'end':
return _context6.stop();
}
}
}, _callee6, this, [[3, 11]]);
}));
function getMemberList(_x7) {
return _ref6.apply(this, arguments);
}
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 () {
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
var params, groupInst, check, result;
return _regenerator2.default.wrap(function _callee7$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
params = ctx.request.body;
groupInst = yapi.getInst(groupModel);
if (params.member_uid) {
_context7.next = 4;
break;
}
return _context7.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组成员uid不能为空'));
case 4:
if (params.id) {
_context7.next = 6;
break;
}
return _context7.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组id不能为空'));
case 6:
_context7.next = 8;
return groupInst.checkMemberRepeat(params.id, params.member_uid);
case 8:
check = _context7.sent;
if (!(check === 0)) {
_context7.next = 11;
break;
}
return _context7.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在'));
case 11:
_context7.next = 13;
return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context7.t0 = _context7.sent;
if (!(_context7.t0 !== true)) {
_context7.next = 16;
break;
}
return _context7.abrupt('return', ctx.body = yapi.commons.resReturn(null, 405, '没有权限'));
case 16:
_context7.prev = 16;
_context7.next = 19;
return groupInst.delMember(params.id, params.member_uid);
case 19:
result = _context7.sent;
ctx.body = yapi.commons.resReturn(result);
_context7.next = 26;
break;
case 23:
_context7.prev = 23;
_context7.t1 = _context7['catch'](16);
ctx.body = yapi.commons.resReturn(null, 402, _context7.t1.message);
case 26:
case 'end':
return _context7.stop();
}
}
}, _callee7, this, [[16, 23]]);
}));
function delMember(_x8) {
return _ref7.apply(this, arguments);
}
return delMember;
}()
/**
* 获取项目分组列表
* @interface /group/list
* @method get
* @category group
* @foldnumber 10
* @returns {Object}
* @example ./api/group/list.json
*/
}, {
key: 'list',
value: function () {
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
var groupInst, result;
return _regenerator2.default.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
_context8.prev = 0;
groupInst = yapi.getInst(groupModel);
_context8.next = 4;
return groupInst.list();
case 4:
result = _context8.sent;
ctx.body = yapi.commons.resReturn(result);
_context8.next = 11;
break;
case 8:
_context8.prev = 8;
_context8.t0 = _context8['catch'](0);
ctx.body = yapi.commons.resReturn(null, 402, _context8.t0.message);
case 11:
case 'end':
return _context8.stop();
}
}
}, _callee8, this, [[0, 8]]);
}));
function list(_x9) {
return _ref8.apply(this, arguments);
}
return list;
}()
/**
* 删除项目分组
* @interface /group/del
* @method post
* @param {String} id 项目分组id
* @category group
* @foldnumber 10
* @returns {Object}
* @example ./api/group/del.json
*/
}, {
key: 'del',
value: function () {
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var _this2 = this;
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, id, projectList, result;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
if (!(this.getRole() !== 'admin')) {
_context10.next = 2;
break;
}
return _context10.abrupt('return', ctx.body = yapi.commons.resReturn(null, 401, '没有权限'));
case 2:
_context10.prev = 2;
groupInst = yapi.getInst(groupModel);
projectInst = yapi.getInst(projectModel);
interfaceInst = yapi.getInst(interfaceModel);
interfaceColInst = yapi.getInst(interfaceColModel);
interfaceCaseInst = yapi.getInst(interfaceCaseModel);
id = ctx.request.body.id;
if (id) {
_context10.next = 11;
break;
}
return _context10.abrupt('return', ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空'));
case 11:
_context10.next = 13;
return projectInst.list(id, true);
case 13:
projectList = _context10.sent;
projectList.forEach(function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
return _regenerator2.default.wrap(function _callee9$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
_context9.next = 2;
return interfaceInst.delByProjectId(p._id);
case 2:
_context9.next = 4;
return interfaceCaseInst.delByProjectId(p._id);
case 4:
_context9.next = 6;
return interfaceColInst.delByProjectId(p._id);
case 6:
case 'end':
return _context9.stop();
}
}
}, _callee9, _this2);
}));
return function (_x11) {
return _ref10.apply(this, arguments);
};
}());
_context10.next = 17;
return projectInst.delByGroupid(id);
case 17:
_context10.next = 19;
return groupInst.del(id);
case 19:
result = _context10.sent;
ctx.body = yapi.commons.resReturn(result);
_context10.next = 26;
break;
case 23:
_context10.prev = 23;
_context10.t0 = _context10['catch'](2);
ctx.body = yapi.commons.resReturn(null, 402, _context10.t0.message);
case 26:
case 'end':
return _context10.stop();
}
}
}, _callee10, this, [[2, 23]]);
}));
function del(_x10) {
return _ref9.apply(this, arguments);
}
return del;
}()
/**
* 更新项目分组
* @interface /group/up
* @method post
* @param {String} id 项目分组id
* @param {String} group_name 项目分组名称
* @param {String} group_desc 项目分组描述
* @category group
* @foldnumber 10
* @returns {Object}
* @example ./api/group/up.json
*/
}, {
key: 'up',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var groupInst, id, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
groupInst = yapi.getInst(groupModel);
id = ctx.request.body.id;
data = {};
_context11.next = 5;
return this.checkAuth(id, 'group', 'danger');
case 5:
_context11.t0 = _context11.sent;
if (!(_context11.t0 !== true)) {
_context11.next = 8;
break;
}
return _context11.abrupt('return', ctx.body = yapi.commons.resReturn(null, 405, '没有权限'));
case 8:
_context11.prev = 8;
ctx.request.body = yapi.commons.handleParams(ctx.request.body, {
id: 'number',
group_name: 'string',
group_desc: 'string'
});
ctx.request.body.group_name && (data.group_name = ctx.request.body.group_name);
ctx.request.body.group_desc && (data.group_desc = ctx.request.body.group_desc);
if ((0, _keys2.default)(data).length === 0) {
ctx.body = yapi.commons.resReturn(null, 404, '分组名和分组描述不能为空');
}
_context11.next = 15;
return groupInst.up(id, data);
case 15:
result = _context11.sent;
ctx.body = yapi.commons.resReturn(result);
_context11.next = 22;
break;
case 19:
_context11.prev = 19;
_context11.t1 = _context11['catch'](8);
ctx.body = yapi.commons.resReturn(null, 402, _context11.t1.message);
case 22:
case 'end':
return _context11.stop();
}
}
}, _callee11, this, [[8, 19]]);
}));
function up(_x12) {
return _ref11.apply(this, arguments);
}
return up;
}()
}]);
return groupController;
}(baseController);
module.exports = groupController;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,135 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var logModel = require('../models/log.js');
var yapi = require('../yapi.js');
var baseController = require('./base.js');
var groupModel = require('../models/group');
var logController = function (_baseController) {
(0, _inherits3.default)(logController, _baseController);
function logController(ctx) {
(0, _classCallCheck3.default)(this, logController);
var _this = (0, _possibleConstructorReturn3.default)(this, (logController.__proto__ || (0, _getPrototypeOf2.default)(logController)).call(this, ctx));
_this.Model = yapi.getInst(logModel);
_this.groupModel = yapi.getInst(groupModel);
return _this;
}
/**
* 获取动态列表
* @interface /log/list
* @method GET
* @category log
* @foldnumber 10
* @param {Number} typeid 动态类型id 不能为空
* @param {Number} [page] 分页页码
* @param {Number} [limit] 分页大小
* @returns {Object}
* @example /log/list
*/
(0, _createClass3.default)(logController, [{
key: 'list',
value: function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var typeid, page, limit, type, result, count;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
typeid = ctx.request.query.typeid, page = ctx.request.query.page || 1, limit = ctx.request.query.limit || 10, type = ctx.request.query.type;
if (typeid) {
_context.next = 3;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, 'typeid不能为空'));
case 3:
if (type) {
_context.next = 5;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空'));
case 5:
_context.prev = 5;
_context.next = 8;
return this.Model.listWithPaging(typeid, type, page, limit);
case 8:
result = _context.sent;
_context.next = 11;
return this.Model.listCount(typeid, type);
case 11:
count = _context.sent;
ctx.body = yapi.commons.resReturn({
total: Math.ceil(count / limit),
list: result
});
_context.next = 18;
break;
case 15:
_context.prev = 15;
_context.t0 = _context['catch'](5);
ctx.body = yapi.commons.resReturn(null, 402, _context.t0.message);
case 18:
case 'end':
return _context.stop();
}
}
}, _callee, this, [[5, 15]]);
}));
function list(_x) {
return _ref.apply(this, arguments);
}
return list;
}()
}]);
return logController;
}(baseController);
module.exports = logController;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,140 +0,0 @@
'use strict';
var fs = require('fs-extra');
var yapi = require('./yapi.js');
var commons = require('./utils/commons');
var dbModule = require('./utils/db.js');
var userModel = require('./models/user.js');
var mongoose = require('mongoose');
yapi.commons = commons;
yapi.connect = dbModule.connect();
function install() {
var exist = yapi.commons.fileExist(yapi.path.join(yapi.WEBROOT_RUNTIME, 'init.lock'));
if (exist) {
yapi.commons.log('runtime/init.lock文件已存在请确认您是否已安装。如果需要重新安装请删掉runtime/init.lock文件');
process.exit(0);
}
setupSql();
}
function setupSql() {
var userInst = yapi.getInst(userModel);
var passsalt = yapi.commons.randStr();
var result = userInst.save({
username: yapi.WEBCONFIG.adminAccount.substr(0, yapi.WEBCONFIG.adminAccount.indexOf('@')),
email: yapi.WEBCONFIG.adminAccount,
password: yapi.commons.generatePassword('qunar.com', passsalt),
passsalt: passsalt,
role: 'admin',
add_time: yapi.commons.time(),
up_time: yapi.commons.time()
});
yapi.connect.then(function () {
var userCol = mongoose.connection.db.collection('user');
userCol.ensureIndex({
username: 1
});
userCol.ensureIndex({
email: 1
}, {
unique: true
});
var projectCol = mongoose.connection.db.collection('project');
projectCol.ensureIndex({
uid: 1
});
projectCol.ensureIndex({
name: 1
});
projectCol.ensureIndex({
group_id: 1
});
var logCol = mongoose.connection.db.collection('log');
logCol.ensureIndex({
uid: 1
});
logCol.ensureIndex({
typeid: 1,
type: 1
});
var interfaceColCol = mongoose.connection.db.collection('interface_col');
interfaceColCol.ensureIndex({
uid: 1
});
interfaceColCol.ensureIndex({
project_id: 1
});
var interfaceCatCol = mongoose.connection.db.collection('interface_cat');
interfaceCatCol.ensureIndex({
uid: 1
});
interfaceCatCol.ensureIndex({
project_id: 1
});
var interfaceCaseCol = mongoose.connection.db.collection('interface_case');
interfaceCaseCol.ensureIndex({
uid: 1
});
interfaceCaseCol.ensureIndex({
col_id: 1
});
interfaceCaseCol.ensureIndex({
project_id: 1
});
var interfaceCol = mongoose.connection.db.collection('interface');
interfaceCol.ensureIndex({
uid: 1
});
interfaceCol.ensureIndex({
path: 1,
method: 1
});
interfaceCol.ensureIndex({
project_id: 1
});
var groupCol = mongoose.connection.db.collection('group');
groupCol.ensureIndex({
uid: 1
});
groupCol.ensureIndex({
group_name: 1
});
var avatarCol = mongoose.connection.db.collection('avatar');
avatarCol.ensureIndex({
uid: 1
});
var followCol = mongoose.connection.db.collection('follow');
followCol.ensureIndex({
uid: 1
});
followCol.ensureIndex({
project_id: 1
});
result.then(function () {
fs.ensureFileSync(yapi.path.join(yapi.WEBROOT_RUNTIME, 'init.lock'));
console.log('\u521D\u59CB\u5316\u7BA1\u7406\u5458\u8D26\u53F7 "' + yapi.WEBCONFIG.adminAccount + '" \u6210\u529F'); // eslint-disable-line
process.exit(0);
}, function (err) {
console.log('\u521D\u59CB\u5316\u7BA1\u7406\u5458\u8D26\u53F7 "' + yapi.WEBCONFIG.adminAccount + '" \u5931\u8D25, ' + err.message); // eslint-disable-line
process.exit(0);
});
});
}
install();

View File

@ -1,211 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var projectModel = require('../models/project.js');
var interfaceModel = require('../models/interface.js');
var mockExtra = require('../../common/mock-extra.js');
var _ = require('underscore');
var Mock = require('mockjs');
function matchApi(apiPath, apiRule) {
var apiRules = apiRule.split("/");
if (apiPaths.length !== apiRules.length) {
return false;
}
for (var i = 0; i < apiRules.length; i++) {
if (apiRules[i] && apiRules[i].indexOf(":") !== 0) {
if (apiRules[i] !== apiPaths[i]) {
return false;
}
}
}
return true;
}
module.exports = function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
var hostname, config, path, paths, projectId, projectInst, project, interfaceData, newData, newpath, interfaceInst, _newData, findInterface, res;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
hostname = ctx.hostname;
config = yapi.WEBCONFIG;
path = ctx.path;
if (!(path.indexOf('/mock/') !== 0)) {
_context.next = 8;
break;
}
if (!next) {
_context.next = 7;
break;
}
_context.next = 7;
return next();
case 7:
return _context.abrupt('return', true);
case 8:
paths = path.split("/");
projectId = paths[2];
paths.splice(0, 3);
path = "/" + paths.join("/");
if (projectId) {
_context.next = 14;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, 'projectId不能为空'));
case 14:
yapi.commons.log('MockServer Running...');
projectInst = yapi.getInst(projectModel), project = void 0;
_context.prev = 16;
_context.next = 19;
return projectInst.get(projectId);
case 19:
project = _context.sent;
_context.next = 25;
break;
case 22:
_context.prev = 22;
_context.t0 = _context['catch'](16);
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 403, _context.t0.message));
case 25:
if (!(project === false)) {
_context.next = 27;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 400, '不存在的项目'));
case 27:
interfaceData = void 0, newData = void 0, newpath = void 0;
interfaceInst = yapi.getInst(interfaceModel);
_context.prev = 29;
newpath = path.substr(project.basepath.length);
_context.next = 33;
return interfaceInst.getByPath(project._id, newpath, ctx.method);
case 33:
interfaceData = _context.sent;
if (!(!interfaceData || interfaceData.length === 0)) {
_context.next = 49;
break;
}
if (!(ctx.method === 'OPTIONS')) {
_context.next = 39;
break;
}
ctx.set("Access-Control-Allow-Origin", "*");
ctx.set("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE");
return _context.abrupt('return', ctx.body = 'ok');
case 39:
_context.next = 41;
return interfaceInst.getVar(project._id, ctx.method);
case 41:
_newData = _context.sent;
findInterface = _.find(_newData, function (item) {
return matchApi(newpath, item.path);
});
if (findInterface) {
_context.next = 45;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 404, '不存在的api'));
case 45:
_context.next = 47;
return interfaceInst.get(findInterface._id);
case 47:
_context.t1 = _context.sent;
interfaceData = [_context.t1];
case 49:
if (!(interfaceData.length > 1)) {
_context.next = 51;
break;
}
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 405, '存在多个api请检查数据库'));
case 51:
interfaceData = interfaceData[0];
ctx.set("Access-Control-Allow-Origin", "*");
if (!(interfaceData.res_body_type === 'json')) {
_context.next = 63;
break;
}
_context.prev = 54;
res = mockExtra(yapi.commons.json_parse(interfaceData.res_body), {
query: ctx.request.query,
body: ctx.request.body
});
return _context.abrupt('return', ctx.body = Mock.mock(res));
case 59:
_context.prev = 59;
_context.t2 = _context['catch'](54);
yapi.commons.log(_context.t2, 'error');
return _context.abrupt('return', ctx.body = {
errcode: 400,
errmsg: 'mock json数据格式有误',
data: interfaceData.res_body
});
case 63:
return _context.abrupt('return', ctx.body = interfaceData.res_body);
case 66:
_context.prev = 66;
_context.t3 = _context['catch'](29);
console.error(_context.t3);
return _context.abrupt('return', ctx.body = yapi.commons.resReturn(null, 409, _context.t3.message));
case 70:
case 'end':
return _context.stop();
}
}
}, _callee, undefined, [[16, 22], [29, 66], [54, 59]]);
}));
return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}();

View File

@ -1,75 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
// const userModel = require('../models/user.js');
var avatarModel = function (_baseModel) {
(0, _inherits3.default)(avatarModel, _baseModel);
function avatarModel() {
(0, _classCallCheck3.default)(this, avatarModel);
return (0, _possibleConstructorReturn3.default)(this, (avatarModel.__proto__ || (0, _getPrototypeOf2.default)(avatarModel)).apply(this, arguments));
}
(0, _createClass3.default)(avatarModel, [{
key: 'getName',
value: function getName() {
return 'avatar';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
uid: { type: Number, required: true },
basecode: String,
type: String
};
}
}, {
key: 'get',
value: function get(uid) {
return this.model.findOne({
uid: uid
});
}
}, {
key: 'up',
value: function up(uid, basecode, type) {
return this.model.update({
uid: uid
}, {
type: type,
basecode: basecode
}, {
upsert: true
});
}
}]);
return avatarModel;
}(baseModel);
module.exports = avatarModel;

View File

@ -1,74 +0,0 @@
'use strict';
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var mongoose = require('mongoose');
var autoIncrement = require('mongoose-auto-increment');
/**
* 所有的model都需要继承baseModel, 且需要 getSchema和getName方法不然会报错
*/
var baseModel = function () {
function baseModel() {
(0, _classCallCheck3.default)(this, baseModel);
this.schema = new mongoose.Schema(this.getSchema());
this.name = this.getName();
if (this.isNeedAutoIncrement() === true) {
this.schema.plugin(autoIncrement.plugin, {
model: this.name,
field: this.getPrimaryKey(),
startAt: 11,
incrementBy: yapi.commons.rand(1, 10)
});
}
this.model = yapi.db(this.name, this.schema);
}
(0, _createClass3.default)(baseModel, [{
key: 'isNeedAutoIncrement',
value: function isNeedAutoIncrement() {
return true;
}
/**
* 可通过覆盖此方法生成其他自增字段
*/
}, {
key: 'getPrimaryKey',
value: function getPrimaryKey() {
return '_id';
}
/**
* 获取collection的schema结构
*/
}, {
key: 'getSchema',
value: function getSchema() {
yapi.commons.log('Model Class need getSchema function', 'error');
}
}, {
key: 'getName',
value: function getName() {
yapi.commons.log('Model Class need name', 'error');
}
}]);
return baseModel;
}();
module.exports = baseModel;

View File

@ -1,116 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var baseModel = require('./base.js');
var followModel = function (_baseModel) {
(0, _inherits3.default)(followModel, _baseModel);
function followModel() {
(0, _classCallCheck3.default)(this, followModel);
return (0, _possibleConstructorReturn3.default)(this, (followModel.__proto__ || (0, _getPrototypeOf2.default)(followModel)).apply(this, arguments));
}
(0, _createClass3.default)(followModel, [{
key: 'getName',
value: function getName() {
return 'follow';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
uid: { type: Number, required: true },
projectid: { type: Number, required: true },
projectname: { type: String, required: true },
icon: String,
color: String
};
}
/**
* @param {Number} uid 用户id
* @param {Number} projectid 项目id
* @param {String} projectname 项目名
* @param {String} icon 项目图标
*/
}, {
key: 'save',
value: function save(data) {
//关注
var saveData = {
uid: data.uid,
projectid: data.projectid,
projectname: data.projectname,
icon: data.icon,
color: data.color
};
var follow = new this.model(saveData);
return follow.save();
}
}, {
key: 'del',
value: function del(projectid, uid) {
return this.model.deleteOne({
projectid: projectid,
uid: uid
});
}
}, {
key: 'list',
value: function list(uid) {
return this.model.find({
uid: uid
}).exec();
}
}, {
key: 'listByProjectId',
value: function listByProjectId(projectid) {
return this.model.find({
projectid: projectid
});
}
}, {
key: 'checkProjectRepeat',
value: function checkProjectRepeat(uid, projectid) {
return this.model.count({
uid: uid,
projectid: projectid
});
}
}, {
key: 'updateById',
value: function updateById(id, typeid, data) {
return this.model.update({
uid: id,
projectid: typeid
}, data, { runValidators: true });
}
}]);
return followModel;
}(baseModel);
module.exports = followModel;

View File

@ -1,155 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
var groupModel = function (_baseModel) {
(0, _inherits3.default)(groupModel, _baseModel);
function groupModel() {
(0, _classCallCheck3.default)(this, groupModel);
return (0, _possibleConstructorReturn3.default)(this, (groupModel.__proto__ || (0, _getPrototypeOf2.default)(groupModel)).apply(this, arguments));
}
(0, _createClass3.default)(groupModel, [{
key: 'getName',
value: function getName() {
return 'group';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
uid: Number,
group_name: String,
group_desc: String,
add_time: Number,
up_time: Number,
members: [{
uid: Number,
role: { type: String, enum: ['owner', 'dev'] },
username: String,
email: String
}]
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'getGroupById',
value: function getGroupById(id) {
return this.model.findOne({
_id: id
}).select("uid group_name group_desc add_time up_time").exec();
}
}, {
key: 'checkRepeat',
value: function checkRepeat(name) {
return this.model.count({
group_name: name
});
}
}, {
key: 'addMember',
value: function addMember(id, data) {
return this.model.update({
_id: id
}, {
$push: { members: data }
});
}
}, {
key: 'delMember',
value: function delMember(id, uid) {
return this.model.update({
_id: id
}, {
$pull: { members: { uid: uid } }
});
}
}, {
key: 'changeMemberRole',
value: function changeMemberRole(id, uid, role) {
return this.model.update({
_id: id,
"members.uid": uid
}, {
"$set": { "members.$.role": role }
});
}
}, {
key: 'checkMemberRepeat',
value: function checkMemberRepeat(id, uid) {
return this.model.count({
_id: id,
"members.uid": uid
});
}
}, {
key: 'list',
value: function list() {
return this.model.find().select('group_name _id group_desc add_time up_time').exec();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'up',
value: function up(id, data) {
return this.model.update({
_id: id
}, {
group_name: data.group_name,
group_desc: data.group_desc,
up_time: yapi.commons.time()
});
}
}, {
key: 'search',
value: function search(keyword) {
return this.model.find({
group_name: new RegExp(keyword, 'i')
}).limit(10);
}
}]);
return groupModel;
}(baseModel);
module.exports = groupModel;

View File

@ -1,203 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
var interfaceModel = function (_baseModel) {
(0, _inherits3.default)(interfaceModel, _baseModel);
function interfaceModel() {
(0, _classCallCheck3.default)(this, interfaceModel);
return (0, _possibleConstructorReturn3.default)(this, (interfaceModel.__proto__ || (0, _getPrototypeOf2.default)(interfaceModel)).apply(this, arguments));
}
(0, _createClass3.default)(interfaceModel, [{
key: 'getName',
value: function getName() {
return 'interface';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
title: { type: String, required: true },
uid: { type: Number, required: true },
path: { type: String, required: true },
method: { type: String, required: true },
project_id: { type: Number, required: true },
catid: { type: Number, required: true },
edit_uid: { type: Number, default: 0 },
status: { type: String, enum: ['undone', 'done'], default: 'undone' },
desc: String,
add_time: Number,
up_time: Number,
type: { type: String, enum: ['static', 'var'], default: 'static' },
req_query: [{
name: String, value: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}],
req_headers: [{
name: String, value: String, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}],
req_params: [{
name: String,
desc: String
}],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'file', 'raw']
},
req_body_form: [{
name: String, type: { type: String, enum: ['text', 'file'] }, desc: String, required: {
type: String,
enum: ["1", "0"],
default: "1"
}
}],
req_body_other: String,
res_body_type: {
type: String,
enum: ['json', 'text', 'xml', 'raw']
},
res_body: String
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'getBaseinfo',
value: function getBaseinfo(id) {
return this.model.findOne({
_id: id
}).select('path method uid title project_id cat_id status').exec();
}
}, {
key: 'getVar',
value: function getVar(project_id, method) {
return this.model.find({
type: 'var',
method: method
}).select('_id path').exec();
}
}, {
key: 'getByPath',
value: function getByPath(project_id, path, method) {
return this.model.find({
project_id: project_id,
path: path,
method: method
}).exec();
}
}, {
key: 'checkRepeat',
value: function checkRepeat(id, path, method) {
return this.model.count({
project_id: id,
path: path,
method: method
});
}
}, {
key: 'countByProjectId',
value: function countByProjectId(id) {
return this.model.count({
project_id: id
});
}
}, {
key: 'list',
value: function list(project_id, select) {
select = select || '_id title uid path method project_id catid edit_uid status desc add_time up_time';
return this.model.find({
project_id: project_id
}).select(select).sort({ _id: -1 }).exec();
}
}, {
key: 'listByCatid',
value: function listByCatid(catid, select) {
select = select || '_id title uid path method project_id catid edit_uid status desc add_time up_time';
return this.model.find({
catid: catid
}).select(select).exec();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'delByCatid',
value: function delByCatid(id) {
return this.model.deleteMany({
catid: id
});
}
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.deleteMany({
project_id: id
});
}
}, {
key: 'up',
value: function up(id, data) {
data.up_time = yapi.commons.time();
return this.model.update({
_id: id
}, data, { runValidators: true });
}
}, {
key: 'upEditUid',
value: function upEditUid(id, uid) {
return this.model.update({
_id: id
}, { edit_uid: uid }, { runValidators: true });
}
}]);
return interfaceModel;
}(baseModel);
module.exports = interfaceModel;

View File

@ -1,149 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
var interfaceCase = function (_baseModel) {
(0, _inherits3.default)(interfaceCase, _baseModel);
function interfaceCase() {
(0, _classCallCheck3.default)(this, interfaceCase);
return (0, _possibleConstructorReturn3.default)(this, (interfaceCase.__proto__ || (0, _getPrototypeOf2.default)(interfaceCase)).apply(this, arguments));
}
(0, _createClass3.default)(interfaceCase, [{
key: 'getName',
value: function getName() {
return 'interface_case';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
casename: { type: String, required: true },
uid: { type: Number, required: true },
col_id: { type: Number, required: true },
index: { type: Number, default: 0 },
project_id: { type: Number, required: true },
interface_id: { type: Number, required: true },
add_time: Number,
up_time: Number,
case_env: { type: String },
// path: { type: String },
// method: { type: String },
req_params: [{
name: String, value: String
}],
req_query: [{
name: String, value: String
}],
// req_headers: [{
// name: String, value: String
// }],
// req_body_type: {
// type: String,
// enum: ['form', 'json', 'text', 'xml']
// },
req_body_form: [{
name: String, value: String
}],
req_body_other: String
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'list',
value: function list(col_id, select) {
select = select || 'casename uid col_id _id index';
if (select === 'all') {
return this.model.find({
col_id: col_id
}).exec();
}
return this.model.find({
col_id: col_id
}).select("casename uid col_id _id index").exec();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.deleteMany({
project_id: id
});
}
}, {
key: 'delByInterfaceId',
value: function delByInterfaceId(id) {
return this.model.deleteMany({
interface_id: id
});
}
}, {
key: 'delByCol',
value: function delByCol(id) {
return this.model.deleteMany({
col_id: id
});
}
}, {
key: 'up',
value: function up(id, data) {
data.up_time = yapi.commons.time();
return this.model.update({ _id: id }, data);
}
}, {
key: 'upCaseIndex',
value: function upCaseIndex(id, index) {
return this.model.update({
_id: id
}, {
index: index
});
}
}]);
return interfaceCase;
}(baseModel);
module.exports = interfaceCase;

View File

@ -1,110 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
/**
* 接口分类
*/
var interfaceCat = function (_baseModel) {
(0, _inherits3.default)(interfaceCat, _baseModel);
function interfaceCat() {
(0, _classCallCheck3.default)(this, interfaceCat);
return (0, _possibleConstructorReturn3.default)(this, (interfaceCat.__proto__ || (0, _getPrototypeOf2.default)(interfaceCat)).apply(this, arguments));
}
(0, _createClass3.default)(interfaceCat, [{
key: 'getName',
value: function getName() {
return 'interface_cat';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
name: { type: String, required: true },
uid: { type: Number, required: true },
project_id: { type: Number, required: true },
desc: String,
add_time: Number,
up_time: Number
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'checkRepeat',
value: function checkRepeat(name) {
return this.model.count({
name: name
});
}
}, {
key: 'list',
value: function list(project_id) {
return this.model.find({
project_id: project_id
}).exec();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.deleteMany({
project_id: id
});
}
}, {
key: 'up',
value: function up(id, data) {
data.up_time = yapi.commons.time();
return this.model.update({
_id: id
}, data);
}
}]);
return interfaceCat;
}(baseModel);
module.exports = interfaceCat;

View File

@ -1,106 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
var interfaceCol = function (_baseModel) {
(0, _inherits3.default)(interfaceCol, _baseModel);
function interfaceCol() {
(0, _classCallCheck3.default)(this, interfaceCol);
return (0, _possibleConstructorReturn3.default)(this, (interfaceCol.__proto__ || (0, _getPrototypeOf2.default)(interfaceCol)).apply(this, arguments));
}
(0, _createClass3.default)(interfaceCol, [{
key: 'getName',
value: function getName() {
return 'interface_col';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
name: { type: String, required: true },
uid: { type: Number, required: true },
project_id: { type: Number, required: true },
desc: String,
add_time: Number,
up_time: Number
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'checkRepeat',
value: function checkRepeat(name) {
return this.model.count({
name: name
});
}
}, {
key: 'list',
value: function list(project_id) {
return this.model.find({
project_id: project_id
}).exec();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.deleteMany({
project_id: id
});
}
}, {
key: 'up',
value: function up(id, data) {
data.up_time = yapi.commons.time();
return this.model.update({
_id: id
}, data);
}
}]);
return interfaceCol;
}(baseModel);
module.exports = interfaceCol;

View File

@ -1,117 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
// const userModel = require('../models/user.js');
var logModel = function (_baseModel) {
(0, _inherits3.default)(logModel, _baseModel);
function logModel() {
(0, _classCallCheck3.default)(this, logModel);
return (0, _possibleConstructorReturn3.default)(this, (logModel.__proto__ || (0, _getPrototypeOf2.default)(logModel)).apply(this, arguments));
}
(0, _createClass3.default)(logModel, [{
key: 'getName',
value: function getName() {
return 'log';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
uid: { type: Number, required: true },
typeid: { type: Number, required: true },
type: { type: String, enum: ['user', 'group', 'interface', 'project', 'other', 'interface_col'], required: true },
content: { type: String, required: true },
username: { type: String, required: true },
add_time: Number
};
}
/**
* @param {String} content log内容
* @param {Enum} type log类型 ['user', 'group', 'interface', 'project', 'other']
* @param {Number} uid 用户id
* @param {String} username 用户名
* @param {Number} typeid 类型id
* @param {Number} add_time 时间
*/
}, {
key: 'save',
value: function save(data) {
var saveData = {
content: data.content,
type: data.type,
uid: data.uid,
username: data.username,
typeid: data.typeid,
add_time: yapi.commons.time()
};
var log = new this.model(saveData);
return log.save();
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'list',
value: function list(typeid, type) {
return this.model.find({
typeid: typeid,
type: type
}).exec();
}
}, {
key: 'listWithPaging',
value: function listWithPaging(typeid, type, page, limit) {
page = parseInt(page);
limit = parseInt(limit);
return this.model.find({
type: type,
typeid: typeid
}).sort({ add_time: -1 }).skip((page - 1) * limit).limit(limit).exec();
}
}, {
key: 'listCount',
value: function listCount(typeid, type) {
return this.model.count({
typeid: typeid,
type: type
});
}
}]);
return logModel;
}(baseModel);
module.exports = logModel;

View File

@ -1,208 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var yapi = require('../yapi.js');
var baseModel = require('./base.js');
var projectModel = function (_baseModel) {
(0, _inherits3.default)(projectModel, _baseModel);
function projectModel() {
(0, _classCallCheck3.default)(this, projectModel);
return (0, _possibleConstructorReturn3.default)(this, (projectModel.__proto__ || (0, _getPrototypeOf2.default)(projectModel)).apply(this, arguments));
}
(0, _createClass3.default)(projectModel, [{
key: 'getName',
value: function getName() {
return 'project';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
uid: { type: Number, required: true },
name: { type: String, required: true },
basepath: { type: String },
desc: String,
group_id: { type: Number, required: true },
project_type: { type: String, required: true, enum: ['public', 'private'] },
members: [{ uid: Number, role: { type: String, enum: ['owner', 'dev'] }, username: String, email: String }],
env: [{ name: String, domain: String }],
icon: String,
color: String,
add_time: Number,
up_time: Number
};
}
}, {
key: 'save',
value: function save(data) {
var m = new this.model(data);
return m.save();
}
}, {
key: 'get',
value: function get(id) {
return this.model.findOne({
_id: id
}).exec();
}
}, {
key: 'getBaseInfo',
value: function getBaseInfo(id) {
return this.model.findOne({
_id: id
}).select('_id uid name basepath desc group_id project_type env icon color add_time up_time').exec();
}
}, {
key: 'getByDomain',
value: function getByDomain(domain) {
return this.model.find({
prd_host: domain
}).exec();
}
}, {
key: 'checkNameRepeat',
value: function checkNameRepeat(name) {
return this.model.count({
name: name
});
}
}, {
key: 'checkDomainRepeat',
value: function checkDomainRepeat(domain, basepath) {
return this.model.count({
prd_host: domain,
basepath: basepath
});
}
}, {
key: 'list',
value: function list(group_id) {
var params = { group_id: group_id };
return this.model.find(params).select("_id uid name basepath desc group_id project_type color icon env add_time up_time").sort({ _id: -1 }).exec();
}
}, {
key: 'listWithPaging',
value: function listWithPaging(group_id, page, limit) {
page = parseInt(page);
limit = parseInt(limit);
return this.model.find({
group_id: group_id
}).sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).exec();
}
}, {
key: 'listCount',
value: function listCount(group_id) {
return this.model.count({
group_id: group_id
});
}
}, {
key: 'countByGroupId',
value: function countByGroupId(group_id) {
return this.model.count({
group_id: group_id
});
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'delByGroupid',
value: function delByGroupid(groupId) {
return this.model.deleteMany({
group_id: groupId
});
}
}, {
key: 'up',
value: function up(id, data) {
data.up_time = yapi.commons.time();
return this.model.update({
_id: id
}, data, { runValidators: true });
}
}, {
key: 'addMember',
value: function addMember(id, data) {
return this.model.update({
_id: id
}, {
$push: { members: data }
});
}
}, {
key: 'delMember',
value: function delMember(id, uid) {
return this.model.update({
_id: id
}, {
$pull: { members: { uid: uid } }
});
}
}, {
key: 'checkMemberRepeat',
value: function checkMemberRepeat(id, uid) {
return this.model.count({
_id: id,
"members.uid": uid
});
}
}, {
key: 'changeMemberRole',
value: function changeMemberRole(id, uid, role) {
return this.model.update({
_id: id,
"members.uid": uid
}, {
"$set": { "members.$.role": role }
});
}
}, {
key: 'search',
value: function search(keyword) {
return this.model.find({
name: new RegExp(keyword, 'ig')
}).limit(10);
}
}, {
key: 'download',
value: function download(id) {
console.log('models in download');
// return this.model.find({
// name: new RegExp(id, 'ig')
// })
// .limit(10);
}
}]);
return projectModel;
}(baseModel);
module.exports = projectModel;

View File

@ -1,140 +0,0 @@
'use strict';
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _createClass2 = require('babel-runtime/helpers/createClass');
var _createClass3 = _interopRequireDefault(_createClass2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var baseModel = require('./base.js');
var userModel = function (_baseModel) {
(0, _inherits3.default)(userModel, _baseModel);
function userModel() {
(0, _classCallCheck3.default)(this, userModel);
return (0, _possibleConstructorReturn3.default)(this, (userModel.__proto__ || (0, _getPrototypeOf2.default)(userModel)).apply(this, arguments));
}
(0, _createClass3.default)(userModel, [{
key: 'getName',
value: function getName() {
return 'user';
}
}, {
key: 'getSchema',
value: function getSchema() {
return {
username: {
type: String,
required: true
},
password: {
type: String,
required: true
},
email: {
type: String,
required: true
},
passsalt: String,
role: String,
add_time: Number,
up_time: Number,
type: { type: String, enum: ['site', 'third'], default: "site" //site用户是网站注册用户, third是第三方登录过来的用户
} };
}
}, {
key: 'save',
value: function save(data) {
var user = new this.model(data);
return user.save();
}
}, {
key: 'checkRepeat',
value: function checkRepeat(email) {
return this.model.count({
email: email
});
}
}, {
key: 'list',
value: function list() {
return this.model.find().select('_id username email role type add_time up_time').exec(); //显示id name email role
}
}, {
key: 'findByUids',
value: function findByUids(uids) {
return this.model.find({
_id: { $in: uids }
}).select('_id username email role type add_time up_time').exec();
}
}, {
key: 'listWithPaging',
value: function listWithPaging(page, limit) {
page = parseInt(page);
limit = parseInt(limit);
return this.model.find().sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).select('_id username email role type add_time up_time').exec();
}
}, {
key: 'listCount',
value: function listCount() {
return this.model.count();
}
}, {
key: 'findByEmail',
value: function findByEmail(email) {
return this.model.findOne({ email: email });
}
}, {
key: 'findById',
value: function findById(id) {
return this.model.findOne({
_id: id
});
}
}, {
key: 'del',
value: function del(id) {
return this.model.deleteOne({
_id: id
});
}
}, {
key: 'update',
value: function update(id, data) {
return this.model.update({
_id: id
}, data);
}
}, {
key: 'search',
value: function search(keyword) {
return this.model.find({
$or: [{ email: new RegExp(keyword, 'i') }, { username: new RegExp(keyword, 'i') }]
}, {
passsalt: 0,
password: 0
}).limit(10);
}
}]);
return userModel;
}(baseModel);
module.exports = userModel;

View File

@ -1,381 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var koaRouter = require('koa-router');
var interfaceController = require('./controllers/interface.js');
var groupController = require('./controllers/group.js');
var userController = require('./controllers/user.js');
var interfaceColController = require('./controllers/interfaceCol.js');
var yapi = require('./yapi.js');
var projectController = require('./controllers/project.js');
var logController = require('./controllers/log.js');
var followController = require('./controllers/follow.js');
var router = koaRouter();
var authLevel = {
admin: 0,
owner: 10,
dev: 20,
member: 30,
guest: 100
};
var INTERFACE_CONFIG = {
interface: {
prefix: '/interface/',
controller: interfaceController
},
user: {
prefix: '/user/',
controller: userController
},
group: {
prefix: '/group/',
controller: groupController
},
project: {
prefix: '/project/',
controller: projectController
},
log: {
prefix: '/log/',
controller: logController
},
follow: {
prefix: '/follow/',
controller: followController
},
col: {
prefix: '/col/',
controller: interfaceColController
}
};
var routerConfig = {
"group": [{
"action": "list",
"path": "list",
"method": "get"
}, {
"action": "add",
"path": "add",
"method": "post"
}, {
"action": "up",
"path": "up",
"method": "post"
}, {
"action": "del",
"path": "del",
"method": "post"
}, {
"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": "get_member_list",
"method": "get"
}, {
action: 'get',
path: 'get',
method: 'get'
}],
"user": [{
"action": "login",
"path": "login",
"method": "post"
}, {
"action": "reg",
"path": "reg",
"method": "post"
}, {
"action": "list",
"path": "list",
"method": "get"
}, {
"action": "findById",
"path": "find",
"method": "get"
}, {
"action": "update",
"path": "update",
"method": "post"
}, {
"action": "del",
"path": "del",
"method": "post"
}, {
"action": "getLoginStatus",
"path": "status",
"method": "get"
}, {
"action": "logout",
"path": "logout",
"method": "get"
}, {
"action": "loginByToken",
"path": "login_by_token",
"method": "post"
}, {
"action": "changePassword",
"path": "change_password",
"method": "post"
}, {
"action": "search",
"path": "search",
"method": "get"
}, {
"action": "project",
"path": "project",
"method": "get"
}, {
"action": "avatar",
"path": "avatar",
"method": "get"
}, {
action: "uploadAvatar",
path: "upload_avatar",
method: "post"
}],
"project": [{
"action": "upSet",
"path": "upset",
"method": "post"
}, {
"action": "add",
"path": "add",
"method": "post"
}, {
"action": "list",
"path": "list",
"method": "get"
}, {
"action": "get",
"path": "get",
"method": "get"
}, {
"action": "up",
"path": "up",
"method": "post"
}, {
"action": "del",
"path": "del",
"method": "post"
}, {
"action": "addMember",
"path": "add_member",
"method": "post"
}, {
"action": "delMember",
"path": "del_member",
"method": "post"
}, {
"action": "changeMemberRole",
"path": "change_member_role",
"method": "post"
}, {
"action": "getMemberList",
"path": "get_member_list",
"method": "get"
}, {
"action": "search",
"path": "search",
"method": "get"
}, {
"action": "download",
"path": "download",
"method": "get"
}],
"interface": [{
"action": "add",
"path": "add",
"method": "post"
}, {
"action": "getCatMenu",
"path": "getCatMenu",
"method": "get"
}, {
"action": "list",
"path": "list",
"method": "get"
}, {
"action": "get",
"path": "get",
"method": "get"
}, {
"action": "up",
"path": "up",
"method": "post"
}, {
"action": "del",
"path": "del",
"method": "post"
}, {
"action": "interUpload",
"path": "interUpload",
"method": "post"
}, {
action: 'listByCat',
path: 'list_cat',
method: 'get'
}, {
action: 'listByMenu',
path: 'list_menu',
method: 'get'
}, {
action: 'addCat',
path: 'add_cat',
method: 'post'
}, {
action: 'upCat',
path: 'up_cat',
method: 'post'
}, {
action: 'delCat',
path: 'del_cat',
method: 'post'
}],
"log": [{
"action": "list",
"path": "list",
"method": "get"
}],
"follow": [{
"action": "list",
"path": "list",
"method": "get"
}, {
"action": "add",
"path": "add",
"method": "post"
}, {
"action": "del",
"path": "del",
"method": "post"
}],
"col": [{
action: "addCol",
path: "add_col",
method: "post"
}, {
action: "list",
path: "list",
method: "get"
}, {
action: "getCaseList",
path: "case_list",
method: "get"
}, {
action: "addCase",
path: "add_case",
method: "post"
}, {
action: "upCase",
path: "up_case",
method: "post"
}, {
action: "getCase",
path: "case",
method: "get"
}, {
action: "upCol",
path: "up_col",
method: "post"
}, {
action: "upCaseIndex",
path: "up_col_index",
method: "post"
}, {
action: "delCol",
path: "del_col",
method: "get"
}, {
action: "delCase",
path: "del_case",
method: "get"
}]
};
var _loop = function _loop(ctrl) {
var actions = routerConfig[ctrl];
actions.forEach(function (item) {
createAction(ctrl, item.action, item.path, item.method);
});
};
for (var ctrl in routerConfig) {
_loop(ctrl);
}
/**
*
* @param {*} controller controller_name
* @param {*} path request_path
* @param {*} method request_method , post get put delete ...
* @param {*} action controller_action_name
*/
function createAction(controller, action, path, method) {
var _this = this;
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var inst;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
inst = new INTERFACE_CONFIG[controller].controller(ctx);
_context.next = 3;
return inst.init(ctx);
case 3:
if (!(inst.$auth === true)) {
_context.next = 8;
break;
}
_context.next = 6;
return inst[action].call(inst, ctx);
case 6:
_context.next = 9;
break;
case 8:
ctx.body = yapi.commons.resReturn(null, 40011, '请登录...');
case 9:
case 'end':
return _context.stop();
}
}
}, _callee, _this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
}
module.exports = router;

View File

@ -1,258 +0,0 @@
'use strict';
var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify2 = _interopRequireDefault(_stringify);
var _typeof2 = require('babel-runtime/helpers/typeof');
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var fs = require('fs-extra');
var path = require('path');
var yapi = require('../yapi.js');
var sha1 = require('sha1');
var logModel = require('../models/log.js');
var json5 = require('json5');
exports.resReturn = function (data, num, errmsg) {
num = num || 0;
return {
errcode: num,
errmsg: errmsg || '成功!',
data: data
};
};
exports.log = function (msg, type) {
if (!msg) {
return;
}
type = type || 'log';
var f = void 0;
switch (type) {
case 'log':
f = console.log; // eslint-disable-line
break;
case 'warn':
f = console.warn; // eslint-disable-line
break;
case 'error':
f = console.error; // eslint-disable-line
break;
default:
f = console.log; // eslint-disable-line
break;
}
f(type + ':', msg);
var date = new Date();
var year = date.getFullYear();
var month = date.getMonth();
var logfile = path.join(yapi.WEBROOT_LOG, year + '-' + month + '.log');
if ((typeof msg === 'undefined' ? 'undefined' : (0, _typeof3.default)(msg)) === 'object') {
if (msg instanceof Error) msg = msg.message;else msg = (0, _stringify2.default)(msg);
}
var data = new Date().toLocaleTimeString() + '\t|\t' + type + '\t|\t' + msg;
fs.writeFileSync(logfile, data, {
flag: 'w+'
});
};
exports.fileExist = function (filePath) {
try {
return fs.statSync(filePath).isFile();
} catch (err) {
return false;
}
};
exports.time = function () {
return Date.parse(new Date()) / 1000;
};
exports.fieldSelect = function (data, field) {
if (!data || !field || !Array.isArray(field)) {
return null;
}
var arr = {};
field.forEach(function (f) {
data[f] && (arr[f] = data[f]);
});
return arr;
};
exports.rand = function (min, max) {
return Math.floor(Math.random() * (max - min) + min);
};
exports.json_parse = function (json) {
try {
return json5.parse(json);
} catch (e) {
return json;
}
};
exports.randStr = function () {
return Math.random().toString(36).substr(2);
};
exports.generatePassword = function (password, passsalt) {
return sha1(password + sha1(passsalt));
};
exports.expireDate = function (day) {
var date = new Date();
date.setTime(date.getTime() + day * 86400000);
return date;
};
exports.sendMail = function (options, cb) {
if (!yapi.mail) return false;
options.subject = options.subject ? options.subject + '-yapi平台' : 'ypai平台';
cb = cb || function (err) {
if (err) {
yapi.commons.log('send mail ' + options.to + ' error,' + err.message, 'error');
} else {
yapi.commons.log('send mail ' + options.to + ' success');
}
};
try {
yapi.mail.sendMail({
from: yapi.WEBCONFIG.mail.from,
to: options.to,
subject: options.subject,
html: options.contents
}, cb);
} catch (e) {
yapi.commons.log(e.message, 'error');
console.error(e.message); // eslint-disable-line
}
};
exports.validateSearchKeyword = function (keyword) {
if (/^\*|\?|\+|\$|\^|\\|\.$/.test(keyword)) {
return false;
}
return true;
};
exports.filterRes = function (list, rules) {
return list.map(function (item) {
var filteredRes = {};
rules.forEach(function (rule) {
if (typeof rule == 'string') {
filteredRes[rule] = item[rule];
} else if ((typeof rule === 'undefined' ? 'undefined' : (0, _typeof3.default)(rule)) == 'object') {
filteredRes[rule.alias] = item[rule.key];
}
});
return filteredRes;
});
};
exports.verifyPath = function (path) {
if (/^\/[a-zA-Z0-9\-\/_:\.]+$/.test(path)) {
if (path[path.length - 1] === '/') {
return false;
} else {
return true;
}
} else {
return false;
}
};
function trim(str) {
if (!str) {
return str;
}
str = str + '';
return str.replace(/(^\s*)|(\s*$)/g, '');
}
function ltrim(str) {
if (!str) {
return str;
}
str = str + '';
return str.replace(/(^\s*)/g, '');
}
function rtrim(str) {
if (!str) {
return str;
}
str = str + '';
return str.replace(/(\s*$)/g, '');
}
exports.trim = trim;
exports.ltrim = ltrim;
exports.rtrim = rtrim;
exports.handleParams = function (params, keys) {
if (!params || (typeof params === 'undefined' ? 'undefined' : (0, _typeof3.default)(params)) !== 'object' || !keys || (typeof keys === 'undefined' ? 'undefined' : (0, _typeof3.default)(keys)) !== 'object') {
return false;
}
for (var key in keys) {
var filter = keys[key];
if (params[key]) {
switch (filter) {
case 'string':
params[key] = trim(params[key] + '');
break;
case 'number':
params[key] = parseInt(params[key], 10);
break;
default:
params[key] = trim(params + '');
}
}
}
return params;
};
exports.saveLog = function (logData) {
try {
var logInst = yapi.getInst(logModel);
var data = {
content: logData.content,
type: logData.type,
uid: logData.uid,
username: logData.username,
typeid: logData.typeid
};
logInst.save(data).then();
} catch (e) {
yapi.commons.log(e, 'error'); // eslint-disable-line
}
};

View File

@ -1,48 +0,0 @@
'use strict';
var mongoose = require('mongoose');
var yapi = require('../yapi.js');
var autoIncrement = require('mongoose-auto-increment');
function model(model, schema) {
if (schema instanceof mongoose.Schema === false) {
schema = new mongoose.Schema(schema);
}
schema.set('autoIndex', false);
return yapi.connect.model(model, schema, model);
}
function connect(callback) {
mongoose.Promise = global.Promise;
var config = yapi.WEBCONFIG;
var options = {};
if (config.db.user) {
options.user = config.db.user;
options.pass = config.db.pass;
}
var db = mongoose.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE, options);
db.then(function () {
yapi.commons.log('mongodb load success...');
if (typeof callback === 'function') {
callback.call(db);
}
}, function (err) {
yapi.commons.log(err, 'Mongo connect error');
});
autoIncrement.initialize(db);
return db;
}
yapi.db = model;
module.exports = {
model: model,
connect: connect
};

View File

@ -1,18 +0,0 @@
'use strict';
var _stringify = require('babel-runtime/core-js/json/stringify');
var _stringify2 = _interopRequireDefault(_stringify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var path = require('path');
var fs = require('fs-extra');
var config = require('../config.js');
var runtimePath = config.runtime_path;
fs.ensureDirSync(runtimePath);
fs.ensureDirSync(path.join(runtimePath, 'log'));
var configPath = path.join(runtimePath, 'config.json');
fs.writeFileSync(configPath, (0, _stringify2.default)(config, null, '\t'), { encoding: 'utf8' });

View File

@ -1,66 +0,0 @@
'use strict';
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var koaRouter = require('koa-router');
var interfaceController = require('./controllers/interface.js');
var router = koaRouter();
function websocket(app) {
console.log('load websocket...');
app.ws.use(function (ctx, next) {
return next(ctx);
});
router.get('/api/interface/solve_conflict', function () {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
var inst;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
inst = new interfaceController(ctx);
_context.next = 3;
return inst.init(ctx);
case 3:
if (!(inst.$auth === true)) {
_context.next = 8;
break;
}
_context.next = 6;
return inst.solveConflict.call(inst, ctx);
case 6:
_context.next = 9;
break;
case 8:
ctx.ws.send('请登录...');
case 9:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
return function (_x) {
return _ref.apply(this, arguments);
};
}());
app.ws.use(router.routes());
app.ws.use(router.allowedMethods());
}
module.exports = websocket;

View File

@ -1,67 +0,0 @@
'use strict';
var _map = require('babel-runtime/core-js/map');
var _map2 = _interopRequireDefault(_map);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var path = require('path');
var fs = require('fs-extra');
var nodemailer = require('nodemailer');
var config = require('../../config.json');
var insts = new _map2.default();
var mail = void 0;
var WEBROOT = path.resolve(__dirname, '..'); //路径
var WEBROOT_SERVER = __dirname;
var WEBROOT_RUNTIME = path.resolve(__dirname, '../..');
var WEBROOT_LOG = path.join(WEBROOT_RUNTIME, 'log');
var WEBCONFIG = config;
fs.ensureDirSync(WEBROOT_LOG);
if (WEBCONFIG.mail) {
mail = nodemailer.createTransport(WEBCONFIG.mail);
}
/**
* 获取一个model实例如果不存在则创建一个新的返回
* @param {*} m class
* @example
* yapi.getInst(groupModel, arg1, arg2)
*/
function getInst(m) {
if (!insts.get(m)) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
insts.set(m, new m(args));
}
return insts.get(m);
}
function delInst(m) {
try {
insts.delete(m);
} catch (err) {
console.error(err); // eslint-disable-line
}
}
var r = {
fs: fs,
path: path,
WEBROOT: WEBROOT,
WEBROOT_SERVER: WEBROOT_SERVER,
WEBROOT_RUNTIME: WEBROOT_RUNTIME,
WEBROOT_LOG: WEBROOT_LOG,
WEBCONFIG: WEBCONFIG,
getInst: getInst,
delInst: delInst,
getInsts: insts
};
if (mail) r.mail = mail;
module.exports = r;

View File

@ -97,13 +97,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li class="active" class="active" > -->
@ -141,18 +135,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>

View File

@ -97,13 +97,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li > -->
@ -127,21 +121,9 @@
<li >
<a href="#使用说明">使用说明</a>
</li>
</ul>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</ul>
</nav>
</div>

View File

@ -105,13 +105,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li > -->
@ -125,18 +119,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>

View File

@ -1,218 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 使用手册</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="styles/theme.css" />
</head>
<body>
<div class="ydoc">
<header class="ydoc-header">
<div class="ydoc-header-area">
<a href="http://ued.qunar.com/ymfe/" class="navbar-brand">YMFE</a>
<button class="ydocIcon navbar-toggle">&#xf020;</button>
<nav class="ydoc-nav">
<ul class="navbar-left">
<li class="">
<a href="index.html">首页</a>
</li>
<li class="active">
<a href="usage.html">使用手册</a>
</li>
<li class="">
<a href="manage.html">管理学院</a>
</li>
<li class="">
<a href="api.html"></a>
</li>
</ul>
</nav>
</div>
</header>
<!-- <header style="height:20px"></header> -->
<!-- Docs page layout -->
<div class="ydoc-banner-bg">
<div class="ydoc-banner ">
<div class="ydoc-banner-area">
<h1 >YApi</h1>
<p class="desc ">高效、易用、功能强大的api管理平台旨在为开发、产品、测试人员提供更优雅的接口管理服务。</p>
</div>
</div>
<div class="ydoc-container">
<div class="ydoc-container-content ">
<div class="content-left staticsidenav" role="complementary">
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
<ul class="nav docs-sidenav">
<!-- <li > -->
<li >
<a href="usage-认识 YApi.html">认识 YApi</a>
</li>
<!-- <li > -->
<li >
<a href="usage-创建第一个API.html">创建第一个API</a>
</li>
<!-- <li > -->
<li >
<a href="usage-项目管理.html">项目管理</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
</li>
<!-- <li > -->
<li >
<a href="usage-使用mock功能.html">使用mock功能</a>
</li>
<!-- <li > -->
<li >
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li class="active" class="active" > -->
<li class="active" >
<a href="usage-成为组长.html">成为组长</a>
</li>
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#什么是组长">什么是组长</a>
</li>
<li >
<a href="#组长职责">组长职责</a>
</li>
</ul>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>
</div>
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="什么是组长">什么是组长 <a class="hashlink" href="#什么是组长">#</a></h2><h2 class="subject" id="组长职责">组长职责 <a class="hashlink" href="#组长职责">#</a></h2>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="copyright">
&copy; 2016 <a href="http://ued.qunar.com/ymfe/">YMFE</a> Team. Build by <a href="http://ued.qunar.com/ydoc/">ydoc</a>.
</div>
</footer>
</div>
<div class="open-panel"></div>
<div class="mask"></div>
<script src="source/main.js"></script>
<script src="source/app.js"></script>
<script>
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
// 折叠code
$('.markdown-body pre').css({
"line-height": lineHeight + "px"
});
$('.markdown-body pre').map(function(i, item) {
var $item = $(item);
var foldnumber = $item.data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
if ($item.height() > EXAMPLE_MAX_HEIGHT) {
$item.css({
"padding-bottom": 30
});
$item.find('code').height(EXAMPLE_MAX_HEIGHT);
$item.append('<span class="extend">展开更多……</span>');
};
});
$('.ydoc-example').delegate('.extend', 'click', function() {
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
var foldnumber = $this.parent().data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}
$(document).ready(fold);
</script>
</body>
</html>

View File

@ -1,222 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 使用手册</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="styles/theme.css" />
</head>
<body>
<div class="ydoc">
<header class="ydoc-header">
<div class="ydoc-header-area">
<a href="http://ued.qunar.com/ymfe/" class="navbar-brand">YMFE</a>
<button class="ydocIcon navbar-toggle">&#xf020;</button>
<nav class="ydoc-nav">
<ul class="navbar-left">
<li class="">
<a href="index.html">首页</a>
</li>
<li class="active">
<a href="usage.html">使用手册</a>
</li>
<li class="">
<a href="manage.html">管理学院</a>
</li>
<li class="">
<a href="api.html"></a>
</li>
</ul>
</nav>
</div>
</header>
<!-- <header style="height:20px"></header> -->
<!-- Docs page layout -->
<div class="ydoc-banner-bg">
<div class="ydoc-banner ">
<div class="ydoc-banner-area">
<h1 >YApi</h1>
<p class="desc ">高效、易用、功能强大的api管理平台旨在为开发、产品、测试人员提供更优雅的接口管理服务。</p>
</div>
</div>
<div class="ydoc-container">
<div class="ydoc-container-content ">
<div class="content-left staticsidenav" role="complementary">
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
<ul class="nav docs-sidenav">
<!-- <li > -->
<li >
<a href="usage-认识 YApi.html">认识 YApi</a>
</li>
<!-- <li > -->
<li >
<a href="usage-创建第一个API.html">创建第一个API</a>
</li>
<!-- <li > -->
<li >
<a href="usage-项目管理.html">项目管理</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li class="active" class="active" > -->
<li class="active" >
<a href="usage-接口调试.html">接口调试</a>
</li>
<ul class="nav docs-sidenav-extend" >
<li >
<a href="#介绍">介绍</a>
</li>
<li >
<a href="#安装_crossRequest_chrome_插件">安装 crossRequest chrome 插件</a>
</li>
<li >
<a href="#使用说明">使用说明</a>
</li>
</ul>
<!-- <li > -->
<li >
<a href="usage-使用mock功能.html">使用mock功能</a>
</li>
<!-- <li > -->
<li >
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>
</div>
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="介绍">介绍 <a class="hashlink" href="#介绍">#</a></h2><h2 class="subject" id="安装_crossRequest_chrome_插件">安装 crossRequest chrome 插件 <a class="hashlink" href="#安装_crossRequest_chrome_插件">#</a></h2><h2 class="subject" id="使用说明">使用说明 <a class="hashlink" href="#使用说明">#</a></h2>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="copyright">
&copy; 2016 <a href="http://ued.qunar.com/ymfe/">YMFE</a> Team. Build by <a href="http://ued.qunar.com/ydoc/">ydoc</a>.
</div>
</footer>
</div>
<div class="open-panel"></div>
<div class="mask"></div>
<script src="source/main.js"></script>
<script src="source/app.js"></script>
<script>
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
// 折叠code
$('.markdown-body pre').css({
"line-height": lineHeight + "px"
});
$('.markdown-body pre').map(function(i, item) {
var $item = $(item);
var foldnumber = $item.data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
if ($item.height() > EXAMPLE_MAX_HEIGHT) {
$item.css({
"padding-bottom": 30
});
$item.find('code').height(EXAMPLE_MAX_HEIGHT);
$item.append('<span class="extend">展开更多……</span>');
};
});
$('.ydoc-example').delegate('.extend', 'click', function() {
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
var foldnumber = $this.parent().data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}
$(document).ready(fold);
</script>
</body>
</html>

View File

@ -97,7 +97,7 @@
<!-- <li class="active" class="active" > -->
<li class="active" >
<a href="usage-接口配置.html">接口配置</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<ul class="nav docs-sidenav-extend" >
@ -107,17 +107,15 @@
</li>
<li >
<a href="#配置说明">配置说明</a>
<a href="#接口配置">接口配置</a>
</li>
<li >
<a href="#接口调试">接口调试</a>
</li>
</ul>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
</li>
<!-- <li > -->
<li >
@ -129,18 +127,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>
@ -148,7 +134,7 @@
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="介绍">介绍 <a class="hashlink" href="#介绍">#</a></h2><h2 class="subject" id="配置说明">配置说明 <a class="hashlink" href="#配置说明">#</a></h2>
<h2 class="subject" id="介绍">介绍 <a class="hashlink" href="#介绍">#</a></h2><h2 class="subject" id="接口配置">接口配置 <a class="hashlink" href="#接口配置">#</a></h2><h2 class="subject" id="接口调试">接口调试 <a class="hashlink" href="#接口调试">#</a></h2>
</div>
</div>

View File

@ -1,206 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta name="format-detection" content="telephone=no,email=no" />
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<meta name="description" content="description of your site">
<meta name="author" content="author of the site">
<title>YApi 使用手册</title>
<link rel="stylesheet" href="source/main.css" />
<link rel="stylesheet" href="styles/theme.css" />
</head>
<body>
<div class="ydoc">
<header class="ydoc-header">
<div class="ydoc-header-area">
<a href="http://ued.qunar.com/ymfe/" class="navbar-brand">YMFE</a>
<button class="ydocIcon navbar-toggle">&#xf020;</button>
<nav class="ydoc-nav">
<ul class="navbar-left">
<li class="">
<a href="index.html">首页</a>
</li>
<li class="active">
<a href="usage.html">使用手册</a>
</li>
<li class="">
<a href="manage.html">管理学院</a>
</li>
<li class="">
<a href="api.html"></a>
</li>
</ul>
</nav>
</div>
</header>
<!-- <header style="height:20px"></header> -->
<!-- Docs page layout -->
<div class="ydoc-banner-bg">
<div class="ydoc-banner ">
<div class="ydoc-banner-area">
<h1 >YApi</h1>
<p class="desc ">高效、易用、功能强大的api管理平台旨在为开发、产品、测试人员提供更优雅的接口管理服务。</p>
</div>
</div>
<div class="ydoc-container">
<div class="ydoc-container-content ">
<div class="content-left staticsidenav" role="complementary">
<nav class="docs-sidebar hidden-print hidden-xs hidden-sm">
<ul class="nav docs-sidenav">
<!-- <li > -->
<li >
<a href="usage-认识 YApi.html">认识 YApi</a>
</li>
<!-- <li > -->
<li >
<a href="usage-创建第一个API.html">创建第一个API</a>
</li>
<!-- <li > -->
<li >
<a href="usage-项目管理.html">项目管理</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
</li>
<!-- <li > -->
<li >
<a href="usage-使用mock功能.html">使用mock功能</a>
</li>
<!-- <li > -->
<li >
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li class="active" class="active" > -->
<li class="active" >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>
</div>
<div class="content-right markdown-body use-sidebar" role="main">
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="copyright">
&copy; 2016 <a href="http://ued.qunar.com/ymfe/">YMFE</a> Team. Build by <a href="http://ued.qunar.com/ydoc/">ydoc</a>.
</div>
</footer>
</div>
<div class="open-panel"></div>
<div class="mask"></div>
<script src="source/main.js"></script>
<script src="source/app.js"></script>
<script>
var lineHeight = 18;
var EXAMPLE_MAX_HEIGHT;
function fold() {
// 折叠code
$('.markdown-body pre').css({
"line-height": lineHeight + "px"
});
$('.markdown-body pre').map(function(i, item) {
var $item = $(item);
var foldnumber = $item.data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
if ($item.height() > EXAMPLE_MAX_HEIGHT) {
$item.css({
"padding-bottom": 30
});
$item.find('code').height(EXAMPLE_MAX_HEIGHT);
$item.append('<span class="extend">展开更多……</span>');
};
});
$('.ydoc-example').delegate('.extend', 'click', function() {
var $this = $(this);
$this.removeClass('extend').addClass('fold');
$this.html('折叠代码');
$this.parent().children('.js-code').height('auto');
$this.parent().height('auto');
});
$('.ydoc-example').delegate('.fold', 'click', function() {
var $this = $(this);
var foldnumber = $this.parent().data('foldnumber');
EXAMPLE_MAX_HEIGHT = lineHeight * (foldnumber || 6);
$this.removeClass('fold').addClass('extend');
$this.parent().height(EXAMPLE_MAX_HEIGHT); // pre
$this.parent().children('.js-code').height(EXAMPLE_MAX_HEIGHT); // code
$this.html("展开更多……");
});
}
$(document).ready(fold);
</script>
</body>
</html>

View File

@ -117,13 +117,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li > -->
@ -137,18 +131,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>

View File

@ -100,12 +100,16 @@
<a href="#介绍">介绍</a>
</li>
<li >
<a href="#组长职责">组长职责</a>
</li>
<li >
<a href="#安装_crossRequest_chrome_插件">安装 crossRequest chrome 插件</a>
</li>
<li >
<a href="#使用说明">使用说明</a>
<a href="#权限列表">权限列表</a>
</li>
</ul>
@ -113,13 +117,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li > -->
@ -133,18 +131,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>
@ -152,7 +138,7 @@
<div class="content-right markdown-body use-sidebar" role="main">
<h2 class="subject" id="介绍">介绍 <a class="hashlink" href="#介绍">#</a></h2><h2 class="subject" id="安装_crossRequest_chrome_插件">安装 crossRequest chrome 插件 <a class="hashlink" href="#安装_crossRequest_chrome_插件">#</a></h2><h2 class="subject" id="使用说明">使用说明 <a class="hashlink" href="#使用说明">#</a></h2>
<h2 class="subject" id="介绍">介绍 <a class="hashlink" href="#介绍">#</a></h2><h2 class="subject" id="组长职责">组长职责 <a class="hashlink" href="#组长职责">#</a></h2><h2 class="subject" id="安装_crossRequest_chrome_插件">安装 crossRequest chrome 插件 <a class="hashlink" href="#安装_crossRequest_chrome_插件">#</a></h2><h2 class="subject" id="权限列表">权限列表 <a class="hashlink" href="#权限列表">#</a></h2>
</div>
</div>

View File

@ -97,13 +97,7 @@
<!-- <li > -->
<li >
<a href="usage-接口配置.html">接口配置</a>
</li>
<!-- <li > -->
<li >
<a href="usage-接口调试.html">接口调试</a>
<a href="usage-接口配置与调试.html">接口配置与调试</a>
</li>
<!-- <li > -->
@ -117,18 +111,6 @@
<a href="usage-使用测试集.html">使用测试集</a>
</li>
<!-- <li > -->
<li >
<a href="usage-成为组长.html">成为组长</a>
</li>
<!-- <li > -->
<li >
<a href="usage-权限列表.html">权限列表</a>
</li>
</ul>
</nav>

View File

@ -67,37 +67,25 @@
"content": {
"sidebar": true,
"multi": true,
"index": "./doc/usage/getfamiliar.md",
"index": "./doc/page/usage/getfamiliar.md",
"pages": [{
"name": "认识 YApi",
"content": "./doc/usage/getfamiliar.md"
}, {
"content": "./doc/page/usage/getfamiliar.md"
},{
"name": "创建第一个API",
"content": "./doc/usage/quickstart.md"
"content": "./doc/page/usage/quickstart.md"
},{
"name": "项目管理",
"content": "./doc/usage/project.md"
}
, {
"name": "接口配置",
"content": "./doc/usage/interface.md"
"content": "./doc/page/usage/project.md"
},{
"name": "接口配置与调试",
"content": "./doc/page/usage/api.md"
},{
"name": "接口调试",
"content": "./doc/usage/run.md"
}
, {
"name": "使用mock功能",
"content": "./doc/usage/mock.md"
}
, {
"content": "./doc/page/usage/mock.md"
},{
"name": "使用测试集",
"content": "./doc/usage/case.md"
}, {
"name": "成为组长",
"content": "./doc/usage/leader.md"
}, {
"name": "权限列表",
"content": "./doc/usage/authority.md"
"content": "./doc/page/usage/case.md"
}
]
}
@ -112,19 +100,19 @@
"content": {
"sidebar": true,
"multi": true,
"index": "./doc/manage/intro.md",
"index": "./doc/page/manage/intro.md",
"pages": [{
"name": "介绍",
"content": "./doc/manage/intro.md"
"content": "./doc/page/manage/intro.md"
}, {
"name": "部署",
"content": "./doc/manage/build.md"
"content": "./doc/page/manage/build.md"
}, {
"name": "超管职责",
"content": "./doc/manage/admin.md"
"content": "./doc/page/manage/admin.md"
}, {
"name": "版本升级",
"content": "./doc/manage/update.md"
"content": "./doc/page/manage/update.md"
}]
}
},