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