From cffb66c9d192ea6265495075f7dee1c623823600 Mon Sep 17 00:00:00 2001 From: zhl Date: Fri, 30 Apr 2021 17:57:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/models/content/Puzzle.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/models/content/Puzzle.ts b/src/models/content/Puzzle.ts index ba7b89d..05cf055 100644 --- a/src/models/content/Puzzle.ts +++ b/src/models/content/Puzzle.ts @@ -55,7 +55,7 @@ class PuzzleClass extends BaseModule { public createtime: Date public static parseQueryParam(params) { - let {key, timeBegin, timeEnd, tag, sub_tag, groups, dp, quality } = params + let {key, timeBegin, timeEnd, tag, sub_tag, groups, dp, quality, sort } = params let opt: any = {deleted: 0, is_hide: 0} if (key) { opt.question = {$regex: key, $options: 'i'} @@ -86,9 +86,12 @@ class PuzzleClass extends BaseModule { } else if (!timeBegin && timeEnd) { opt.createtime = {$lte: timeEnd}; } + let sortObj = {_id: 1} + if (sort) { + sortObj = sort + } - let sort = {_id: 1} - return { opt, sort } + return { opt, sort: sortObj } } public static async nextQuestion(this: ReturnModelType, id: string) {