Authored by Targaryen

page

... ... @@ -149,14 +149,16 @@ class FileApi {
/**
* 获取上传记录
*/
async getAllLogs() {
let fileModel = new FileModel();
let result = await fileModel.findAll();
let finalResult = _.sortBy(result, o => {
return -new Date(o.date);
});
return finalResult;
async getAllLogs(params) {
let page = _.parseInt(params.page);
let limit = 10;
let skip = page > 0? limit * (page - 1) : 0;
let result = await new FileModel().cfind({}).sort({
date: -1
}).skip(skip).limit(limit).exec();
return result;
}
}
... ...
... ... @@ -44,7 +44,9 @@ const file = {
*/
listLogs: async(ctx) => {
let fileApi = new FileApi();
let result = await fileApi.getAllLogs();
let result = await fileApi.getAllLogs({
page: ctx.query.page
});
ctx.body = {
code: 200,
... ...