用户信息增加返回rank
This commit is contained in:
parent
483af1973c
commit
41ca21e2ca
@ -4,7 +4,12 @@ import { Card } from '../models/subdoc/Card'
|
||||
import { BaseConst } from '../constants/BaseConst'
|
||||
import { BagItem, ItemType } from '../models/BagItem'
|
||||
import { RedisClient } from '../redis/RedisClient'
|
||||
import { checkGameing, setGameing, usersByScore } from '../service/rank'
|
||||
import {
|
||||
checkGameing,
|
||||
getRankScore,
|
||||
setGameing,
|
||||
usersByScore
|
||||
} from '../service/rank'
|
||||
import { fetchAccount } from '../dao/AccountDao'
|
||||
import { generateId } from '../utils/security.util'
|
||||
import { getRandom } from '../utils/number.util'
|
||||
@ -32,6 +37,12 @@ export default class AccountController extends BaseController {
|
||||
result.season_score = account.season_score
|
||||
result.season_data = account.season_data
|
||||
result.match_score = account.getMatchScore()
|
||||
let rank = await getRankScore(accountid)
|
||||
if (typeof rank === 'string') {
|
||||
result.rank = parseInt(rank)
|
||||
} else {
|
||||
result.rank = rank
|
||||
}
|
||||
return result
|
||||
}
|
||||
@router('get /svr/:accountid/uinfo')
|
||||
|
@ -170,6 +170,15 @@ export class RedisClient {
|
||||
});
|
||||
}
|
||||
|
||||
public async zrevrank(key: string, member: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.pub.zrevrank(key, member, (err, data) => {
|
||||
if (err) { return reject(err); }
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public async hset(key: string, field: string, value: string) {
|
||||
return new Promise((resolve) => {
|
||||
this.pub.hset(key, field, value, resolve);
|
||||
|
@ -20,3 +20,9 @@ export async function checkGameing(accountid: string) {
|
||||
return await new RedisClient().get('gameing_' + accountid)
|
||||
}
|
||||
|
||||
export async function getRankScore(accountid: string) {
|
||||
return await new RedisClient().zrevrank(BaseConst.RANK_SCORE, accountid)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user