redis 排行榜分区
This commit is contained in:
@@ -55,6 +55,15 @@ export default class Game extends BaseModel {
|
||||
@prop({ required: true })
|
||||
versionCode: number;
|
||||
|
||||
public static async getAllServerList() {
|
||||
let game = await GameModel.findOne().lean();
|
||||
if(game) {
|
||||
return game.serverList;
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
public static async getServerListByType(serverType: string) {
|
||||
let game = await GameModel.findOne().lean();
|
||||
if (!game) {
|
||||
|
||||
+2
-2
@@ -339,13 +339,13 @@ export default class Role extends BaseModel {
|
||||
}
|
||||
|
||||
// 获取排行榜
|
||||
public static async getRank(type: string, fields: Array<string>, page = 1, limit = 100, lean = true) {
|
||||
public static async getRank(type: string, serverId: number, fields: Array<string>, page = 1, limit = 100, lean = true) {
|
||||
let sortBy = {};
|
||||
if(type == 'tower') {
|
||||
sortBy['towerLv'] = -1;
|
||||
sortBy['towerUpTime'] = 1;
|
||||
}
|
||||
const ranks = await RoleModel.find().select(fields.join(' ')).sort(sortBy).limit(limit).skip((page - 1) * limit).lean(lean);
|
||||
const ranks = await RoleModel.find({serverId}).select(fields.join(' ')).sort(sortBy).limit(limit).skip((page - 1) * limit).lean(lean);
|
||||
return ranks;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user