排行榜增加返回总人数
This commit is contained in:
parent
b50c87cbb9
commit
665a69ff39
@ -180,7 +180,7 @@
|
|||||||
| -------- | -------------------------------------- |
|
| -------- | -------------------------------------- |
|
||||||
| shop | 店铺id |
|
| shop | 店铺id |
|
||||||
| level | 关卡id |
|
| level | 关卡id |
|
||||||
| mode | 游戏类型, 0: 单人, 1: 多人 |
|
| mode | 游戏类型, 0: 单人, 1: 多人, 2: 挑战 |
|
||||||
| skip | 数据开始的偏移值, 从0开始, 默认0 |
|
| skip | 数据开始的偏移值, 从0开始, 默认0 |
|
||||||
| limit | 每次返回的数量条数, 默认10 |
|
| limit | 每次返回的数量条数, 默认10 |
|
||||||
|
|
||||||
@ -196,7 +196,8 @@
|
|||||||
'nickname', 昵称(暂无)
|
'nickname', 昵称(暂无)
|
||||||
'avatar' 头像
|
'avatar' 头像
|
||||||
]
|
]
|
||||||
]
|
],
|
||||||
|
rankTotal: 99 排行榜总人数
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -132,14 +132,15 @@ class ExamController extends BaseController {
|
|||||||
level: history.activityId,
|
level: history.activityId,
|
||||||
accountId: accountid,
|
accountId: accountid,
|
||||||
score: statMap.score,
|
score: statMap.score,
|
||||||
mode: 0,
|
mode: 2,
|
||||||
session: history.id
|
session: history.id
|
||||||
}
|
}
|
||||||
await history.save()
|
await history.save()
|
||||||
await updateExamRank(rankObj)
|
await updateExamRank(rankObj)
|
||||||
let {rankList, userRank } = await getRank({shop: history.shop, level: history.activityId, accountId: accountid, mode: 0, skip: 0, limit: 20})
|
let {rankList, userRank, rankTotal } = await getRank({shop: history.shop, level: history.activityId, accountId: accountid, mode: 2, skip: 0, limit: 20})
|
||||||
rspData.rankList = rankList
|
rspData.rankList = rankList
|
||||||
rspData.userRank = userRank
|
rspData.userRank = userRank
|
||||||
|
rspData.rankTotal = rankTotal
|
||||||
}
|
}
|
||||||
rspData.gameResult = gameResult
|
rspData.gameResult = gameResult
|
||||||
return rspData
|
return rspData
|
||||||
|
@ -291,11 +291,11 @@ class PuzzleController extends BaseController {
|
|||||||
|
|
||||||
@role('anon')
|
@role('anon')
|
||||||
@router('post /api/:accounid/puzzle/rank')
|
@router('post /api/:accounid/puzzle/rank')
|
||||||
async singleRank(req, res) {
|
async singleRank(req) {
|
||||||
let {shop, level, accountid, mode, skip, limit} = req.params
|
let {shop, level, accountid, mode, skip, limit} = req.params
|
||||||
skip = skip || 0
|
skip = skip || 0
|
||||||
limit = limit || 10
|
limit = limit || 10
|
||||||
let {rankList, userRank } = await getRank({shop, level, accountId: accountid, mode, skip, limit})
|
let {rankList, userRank, rankTotal} = await getRank({shop, level, accountId: accountid, mode, skip, limit})
|
||||||
return {rankList, userRank}
|
return {rankList, userRank, rankTotal}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import { GameEnv } from '../config/GameEnv'
|
|||||||
import { Shop } from '../models/shop/Shop'
|
import { Shop } from '../models/shop/Shop'
|
||||||
import { mission_vo } from '../config/parsers/mission_vo'
|
import { mission_vo } from '../config/parsers/mission_vo'
|
||||||
import { ShopActivity } from '../models/shop/ShopActivity'
|
import { ShopActivity } from '../models/shop/ShopActivity'
|
||||||
import { getAccountRank, getRankList, updateRank } from './Rank'
|
import { getAccountRank, getRankCount, getRankList, updateRank } from './Rank'
|
||||||
import { PuzzleRank } from '../models/match/PuzzleRank'
|
import { PuzzleRank } from '../models/match/PuzzleRank'
|
||||||
|
|
||||||
|
|
||||||
@ -185,7 +185,9 @@ export async function getRank({shop, level, accountId, mode, skip, limit }
|
|||||||
rankList.push([datas[i], datas[i + 1] << 0])
|
rankList.push([datas[i], datas[i + 1] << 0])
|
||||||
}
|
}
|
||||||
let userRank = (await getAccountRank(accountId, key)) || 999
|
let userRank = (await getAccountRank(accountId, key)) || 999
|
||||||
return {rankList, userRank}
|
|
||||||
|
let rankTotal = (await getRankCount(key))
|
||||||
|
return {rankList, userRank, rankTotal}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,6 +72,10 @@ export async function getRankList(start: number, end: number, subKey?: string) {
|
|||||||
return await new RedisClient().zrevrange(generateRankKey(subKey), start, end)
|
return await new RedisClient().zrevrange(generateRankKey(subKey), start, end)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getRankCount(subKey?: string) {
|
||||||
|
return await new RedisClient().zcard(generateRankKey(subKey))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取帐号附近的几个记录
|
* 获取帐号附近的几个记录
|
||||||
* @param {string} accountId
|
* @param {string} accountId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user