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) {