修改获取物品列表的接口, 可获取特定物品的数量
This commit is contained in:
parent
03d70ab365
commit
9a8812a9e9
@ -330,6 +330,7 @@
|
|||||||
| 字段 | 说明 |
|
| 字段 | 说明 |
|
||||||
| -------- | -------------------------------------- |
|
| -------- | -------------------------------------- |
|
||||||
| type |物品类型, 不传的话就获取背包中所有物品 |
|
| type |物品类型, 不传的话就获取背包中所有物品 |
|
||||||
|
| items |特定物品id数组 |
|
||||||
|
|
||||||
3. Response: JSON
|
3. Response: JSON
|
||||||
|
|
||||||
|
@ -10,13 +10,16 @@ import { error } from '../common/Debug'
|
|||||||
export default class ItemController extends BaseController {
|
export default class ItemController extends BaseController {
|
||||||
@router('post /api/:accountid/items')
|
@router('post /api/:accountid/items')
|
||||||
async itemList(req: any) {
|
async itemList(req: any) {
|
||||||
let { accountid, type } = req.params
|
let { accountid, type, items } = req.params
|
||||||
let queryData: any = { accountid }
|
let queryData: any = { accountid }
|
||||||
if (type != undefined) {
|
if (type != undefined) {
|
||||||
queryData.itemtype = type << 0
|
queryData.itemtype = type << 0
|
||||||
}
|
}
|
||||||
let items = await BagItem.find(queryData)
|
if (items && items.length > 0) {
|
||||||
return items.map(o => o.toJson())
|
queryData.itemid = {$in: items}
|
||||||
|
}
|
||||||
|
let results = await BagItem.find(queryData)
|
||||||
|
return results.map(o => o.toJson())
|
||||||
}
|
}
|
||||||
|
|
||||||
@router('post /svr/:accountid/useitem')
|
@router('post /svr/:accountid/useitem')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user