From b50c87cbb9740caf96750c5497d21cd14654757b Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 19 May 2021 14:40:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E5=BA=97=E9=93=BA=E6=B8=B8?= =?UTF-8?q?=E6=88=8F=E5=B0=8F=E6=B8=B8=E6=88=8F=E7=A0=81=E6=97=B6,=20?= =?UTF-8?q?=E5=BC=BA=E5=88=B6=E4=BD=BF=E7=94=A8=E7=9F=ADid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/controllers/shop.controller.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/admin/controllers/shop.controller.ts b/src/admin/controllers/shop.controller.ts index 2dd3c9f..093b816 100644 --- a/src/admin/controllers/shop.controller.ts +++ b/src/admin/controllers/shop.controller.ts @@ -4,6 +4,7 @@ import { Shop } from '../../models/shop/Shop' import { ZError } from '../../common/ZError' import { Game } from '../../models/content/Game' import { generateQrFile } from '../../services/File' +import { isObjectId } from '../../utils/string.util' class ShopController extends BaseController { @@ -155,6 +156,13 @@ class ShopController extends BaseController { @router('post /shop/gameqr') async getGameQr(req: any) { let { shop, gameId, version } = req.params + if (isObjectId(shop)) { + let record = await Shop.findById(shop) + if (!record) { + throw new ZError(12, 'shop not found') + } + shop = record.sid + } const { url } = await generateQrFile({gameId, version, shop}) return { url } }