2017-07-20 20:30:24 +08:00
|
|
|
|
'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);
|
|
|
|
|
|
|
|
|
|
var _log = require('../models/log.js');
|
|
|
|
|
|
|
|
|
|
var _log2 = _interopRequireDefault(_log);
|
|
|
|
|
|
|
|
|
|
var _yapi = require('../yapi.js');
|
|
|
|
|
|
|
|
|
|
var _yapi2 = _interopRequireDefault(_yapi);
|
|
|
|
|
|
|
|
|
|
var _base = require('./base.js');
|
|
|
|
|
|
|
|
|
|
var _base2 = _interopRequireDefault(_base);
|
|
|
|
|
|
|
|
|
|
var _group = require('../models/group');
|
|
|
|
|
|
|
|
|
|
var _group2 = _interopRequireDefault(_group);
|
|
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
|
|
|
|
|
|
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 = _yapi2.default.getInst(_log2.default);
|
|
|
|
|
_this.groupModel = _yapi2.default.getInst(_group2.default);
|
|
|
|
|
return _this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2017-08-10 15:47:33 +08:00
|
|
|
|
* 获取动态列表
|
|
|
|
|
* @interface /log/list
|
2017-07-20 20:30:24 +08:00
|
|
|
|
* @method GET
|
2017-08-10 15:47:33 +08:00
|
|
|
|
* @category log
|
2017-07-20 20:30:24 +08:00
|
|
|
|
* @foldnumber 10
|
2017-08-11 17:49:47 +08:00
|
|
|
|
* @param {Number} typeid 动态类型id, 不能为空
|
2017-07-20 20:30:24 +08:00
|
|
|
|
* @param {Number} [page] 分页页码
|
|
|
|
|
* @param {Number} [limit] 分页大小
|
|
|
|
|
* @returns {Object}
|
2017-08-10 15:47:33 +08:00
|
|
|
|
* @example /log/list
|
2017-07-20 20:30:24 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(0, _createClass3.default)(logController, [{
|
|
|
|
|
key: 'list',
|
|
|
|
|
value: function () {
|
2017-08-28 20:29:51 +08:00
|
|
|
|
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
2017-08-11 17:49:47 +08:00
|
|
|
|
var typeid, page, limit, type, result, count;
|
2017-07-20 20:30:24 +08:00
|
|
|
|
return _regenerator2.default.wrap(function _callee$(_context) {
|
|
|
|
|
while (1) {
|
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
|
case 0:
|
2017-08-11 17:49:47 +08:00
|
|
|
|
typeid = ctx.request.query.typeid, page = ctx.request.query.page || 1, limit = ctx.request.query.limit || 10, type = ctx.request.query.type;
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
2017-08-09 18:00:45 +08:00
|
|
|
|
if (typeid) {
|
2017-07-20 20:30:24 +08:00
|
|
|
|
_context.next = 3;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-10 12:13:32 +08:00
|
|
|
|
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'typeid不能为空'));
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
|
|
|
|
case 3:
|
2017-08-11 17:49:47 +08:00
|
|
|
|
if (type) {
|
|
|
|
|
_context.next = 5;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'type不能为空'));
|
|
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
|
_context.prev = 5;
|
|
|
|
|
_context.next = 8;
|
|
|
|
|
return this.Model.listWithPaging(typeid, type, page, limit);
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
2017-08-11 17:49:47 +08:00
|
|
|
|
case 8:
|
2017-07-20 20:30:24 +08:00
|
|
|
|
result = _context.sent;
|
2017-08-11 17:49:47 +08:00
|
|
|
|
_context.next = 11;
|
|
|
|
|
return this.Model.listCount(typeid, type);
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
2017-08-11 17:49:47 +08:00
|
|
|
|
case 11:
|
2017-07-20 20:30:24 +08:00
|
|
|
|
count = _context.sent;
|
|
|
|
|
|
2017-07-27 19:49:26 +08:00
|
|
|
|
|
2017-07-20 20:30:24 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn({
|
|
|
|
|
total: Math.ceil(count / limit),
|
|
|
|
|
list: result
|
|
|
|
|
});
|
2017-08-11 17:49:47 +08:00
|
|
|
|
_context.next = 18;
|
2017-07-20 20:30:24 +08:00
|
|
|
|
break;
|
|
|
|
|
|
2017-08-11 17:49:47 +08:00
|
|
|
|
case 15:
|
|
|
|
|
_context.prev = 15;
|
|
|
|
|
_context.t0 = _context['catch'](5);
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
2017-07-27 19:49:26 +08:00
|
|
|
|
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
2017-07-20 20:30:24 +08:00
|
|
|
|
|
2017-08-11 17:49:47 +08:00
|
|
|
|
case 18:
|
2017-07-20 20:30:24 +08:00
|
|
|
|
case 'end':
|
|
|
|
|
return _context.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-11 17:49:47 +08:00
|
|
|
|
}, _callee, this, [[5, 15]]);
|
2017-07-20 20:30:24 +08:00
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
function list(_x) {
|
|
|
|
|
return _ref.apply(this, arguments);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return list;
|
|
|
|
|
}()
|
|
|
|
|
}]);
|
|
|
|
|
return logController;
|
|
|
|
|
}(_base2.default);
|
|
|
|
|
|
|
|
|
|
module.exports = logController;
|