mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
72 lines
2.3 KiB
JavaScript
72 lines
2.3 KiB
JavaScript
|
'use strict';
|
||
|
|
||
|
var _regenerator = require('babel-runtime/regenerator');
|
||
|
|
||
|
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||
|
|
||
|
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
|
||
|
|
||
|
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
|
||
|
|
||
|
var _commons = require('../utils/commons');
|
||
|
|
||
|
var _interface = require('../models/interface.js');
|
||
|
|
||
|
var _interface2 = _interopRequireDefault(_interface);
|
||
|
|
||
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||
|
|
||
|
module.exports = {
|
||
|
add: function add(ctx) {
|
||
|
var _this = this;
|
||
|
|
||
|
return (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
|
||
|
var data, result;
|
||
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
||
|
while (1) {
|
||
|
switch (_context.prev = _context.next) {
|
||
|
case 0:
|
||
|
data = {
|
||
|
title: 'yapi',
|
||
|
content: 'content',
|
||
|
uid: 'abc'
|
||
|
};
|
||
|
_context.next = 3;
|
||
|
return _interface2.default.save(data);
|
||
|
|
||
|
case 3:
|
||
|
result = _context.sent;
|
||
|
|
||
|
(0, _commons.log)('interface err...', 'error');
|
||
|
ctx.body = (0, _commons.resReturn)(result);
|
||
|
|
||
|
case 6:
|
||
|
case 'end':
|
||
|
return _context.stop();
|
||
|
}
|
||
|
}
|
||
|
}, _callee, _this);
|
||
|
}))();
|
||
|
},
|
||
|
list: function list(ctx) {
|
||
|
var _this2 = this;
|
||
|
|
||
|
return (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2() {
|
||
|
var data;
|
||
|
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||
|
while (1) {
|
||
|
switch (_context2.prev = _context2.next) {
|
||
|
case 0:
|
||
|
data = _interface2.default.find();
|
||
|
|
||
|
ctx.body = 1;
|
||
|
|
||
|
case 2:
|
||
|
case 'end':
|
||
|
return _context2.stop();
|
||
|
}
|
||
|
}
|
||
|
}, _callee2, _this2);
|
||
|
}))();
|
||
|
}
|
||
|
};
|