diff --git a/src/api/controllers/puzzle.controller.ts b/src/api/controllers/puzzle.controller.ts index c62f82f..5e1985f 100644 --- a/src/api/controllers/puzzle.controller.ts +++ b/src/api/controllers/puzzle.controller.ts @@ -30,6 +30,7 @@ import { import { Shop, validShopId } from '../../models/shop/Shop' import { ShopActivity } from '../../models/shop/ShopActivity' import { GameUser } from '../../models/GameUser' +import { isObjectId } from '../../utils/string.util' class PuzzleController extends BaseController { @@ -337,6 +338,13 @@ class PuzzleController extends BaseController { let {shop, level, accountId, mode, skip, limit} = req.params skip = +skip || 0 limit = +limit || 10 + if (!isObjectId(shop)) { + let record = await Shop.fetchByID(shop) + if (!record) { + throw new ZError(12, 'shop not found') + } + shop = record.id + } let {rankList, userRank, rankTotal} = await getRank({shop, level, accountId, mode, skip, limit}) return {rankList, userRank, rankTotal} }