From 07d1de08593b1df5dbaa4ebd14c5e489f69f1bfd Mon Sep 17 00:00:00 2001 From: zhl Date: Mon, 17 May 2021 11:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=91=E6=88=98=E8=BF=94=E5=9B=9E=E5=A4=9A?= =?UTF-8?q?=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/api.md | 7 ++++--- src/admin/controllers/shop_exam.controller.ts | 0 src/api/controllers/shop.controller.ts | 10 +++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 src/admin/controllers/shop_exam.controller.ts diff --git a/doc/api.md b/doc/api.md index 8a8697b..79f8c3d 100644 --- a/doc/api.md +++ b/doc/api.md @@ -310,10 +310,11 @@ "name": "一品漫城", // 店铺名 "area": "上海市-上海市-闵行区", // 区域 "logo": "https://resource.kingsome.cn/game607fd53cb40504740fdccb13.png", // 店铺logo - "exam": { // 店铺测验信息 + "exams": [{ // 店铺测验信息 "id": "609e13eeccc78154ac683583", //id - "name": "第一期测试" // 测验 - }, + "name": "第一期测试", // 测验 + "desc": "简介" + }], "activity": { // 活动信息 "id": "608bdf61cecfcc2f45247663", // 活动id "name": "第一个活动", // 活动名 diff --git a/src/admin/controllers/shop_exam.controller.ts b/src/admin/controllers/shop_exam.controller.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/api/controllers/shop.controller.ts b/src/api/controllers/shop.controller.ts index 2a2cb35..44c9546 100644 --- a/src/api/controllers/shop.controller.ts +++ b/src/api/controllers/shop.controller.ts @@ -105,9 +105,13 @@ class ShopController extends BaseController { rspData.area = shop.areaStr rspData.logo = shop.logo const now = Date.now() - let exam = await ShopExam.findOne({shop: sid, beginTime: {$lte: now}, endTime: {$gte: now}, active: true, deleted: false}) - if (exam) { - rspData.exam = {id : exam.id, name: exam.name, desc: exam.desc} + let exams = await ShopExam.find({shop: sid, beginTime: {$lte: now}, endTime: {$gte: now}, active: true, deleted: false}) + if (exams && exams.length > 0) { + let datas: any = [] + for (let exam of exams) { + datas.push({ id: exam.id, name: exam.name, desc: exam.desc }) + } + rspData.exams = datas } let activity = await ShopActivity.getActivityOne(sid) rspData.activity = activity