From c5a27e30a25db1a3a94cd3d589d339bb3965719b Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 17 May 2021 13:38:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=91=E6=88=98=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api.md | 1 + src/api/controllers/exam.controller.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/doc/api.md b/doc/api.md index 79f8c3d..d6044f5 100644 --- a/doc/api.md +++ b/doc/api.md @@ -215,6 +215,7 @@ | 字段 | 说明 | | -------- | -------------------------------------- | | shop | 店铺id, 比如 607ff59d4a4e16687a3b7079 | +| eid | 测验id, 比如 609e13eeccc78154ac683583 | 3. Response: JSON diff --git a/src/api/controllers/exam.controller.ts b/src/api/controllers/exam.controller.ts index ec71a37..3aedca6 100644 --- a/src/api/controllers/exam.controller.ts +++ b/src/api/controllers/exam.controller.ts @@ -18,14 +18,17 @@ class ExamController extends BaseController { @role('anon') @router('post /api/:accountid/exam/list') async list(req, res) { - let { shop, accountid } = req.params + let { shop, accountid, eid } = req.params if (!shop || !isObjectId(shop)) { throw new ZError(10, '没有店铺id或者店铺id格式不正确, 测试使用: 607ff59d4a4e16687a3b7079') } const now = Date.now() - let record = await ShopExam.findOne({shop, beginTime: {$lte: now}, endTime: {$gte: now}, active: true, deleted: false}) + if (!eid) { + throw new ZError(12, '需要指定挑战的id') + } + let record = await ShopExam.findById(eid) if (!record) { - throw new ZError(11, '暂时没有可参加的测试') + throw new ZError(11, '暂时没有可参加的挑战') } let params = {} if (record.qtypes && record.qtypes.length > 0) {