From 9a8812a9e926d10f74c281cfa3f31794d6b6c549 Mon Sep 17 00:00:00 2001 From: zhl Date: Tue, 26 Jan 2021 19:14:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E7=89=A9?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8=E7=9A=84=E6=8E=A5=E5=8F=A3,=20?= =?UTF-8?q?=E5=8F=AF=E8=8E=B7=E5=8F=96=E7=89=B9=E5=AE=9A=E7=89=A9=E5=93=81?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/api.md | 1 + src/controllers/ItemController.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/api.md b/docs/api.md index 249d6ab..33f5df7 100644 --- a/docs/api.md +++ b/docs/api.md @@ -330,6 +330,7 @@ | 字段 | 说明 | | -------- | -------------------------------------- | | type |物品类型, 不传的话就获取背包中所有物品 | +| items |特定物品id数组 | 3. Response: JSON diff --git a/src/controllers/ItemController.ts b/src/controllers/ItemController.ts index 8e798b7..ed931ee 100644 --- a/src/controllers/ItemController.ts +++ b/src/controllers/ItemController.ts @@ -10,13 +10,16 @@ import { error } from '../common/Debug' export default class ItemController extends BaseController { @router('post /api/:accountid/items') async itemList(req: any) { - let { accountid, type } = req.params + let { accountid, type, items } = req.params let queryData: any = { accountid } if (type != undefined) { queryData.itemtype = type << 0 } - let items = await BagItem.find(queryData) - return items.map(o => o.toJson()) + if (items && items.length > 0) { + queryData.itemid = {$in: items} + } + let results = await BagItem.find(queryData) + return results.map(o => o.toJson()) } @router('post /svr/:accountid/useitem')