feat(gvgBattle): getCity返回正确的结构

This commit is contained in:
liangtongchuan
2023-02-11 21:48:59 +08:00
committed by luying
parent b9b030e693
commit b1cf6b7637
2 changed files with 27 additions and 4 deletions

View File

@@ -9,6 +9,7 @@ import { DicGVGAreaPoint } from "../pubUtils/dictionary/DicGVGAreaPoint";
@index({ roleId: 1, teamId: 1 })
@index({ teamCode: 1 })
@index({ cityId: 1, leagueId: 1 })
export default class GVGTeam extends BaseModel {
@prop({ required: true })
@@ -106,11 +107,21 @@ export default class GVGTeam extends BaseModel {
}
// 查找角色队伍数
public static async getTeamCnt(roleId: string) {
public static async getTeamCntByRole(roleId: string) {
const teams: GVGTeamType[] = await GVGTeamModel.find({ roleId }).select('teamCode').lean();
return teams.length;
}
// 通过城池ID获取队伍数
public static async getTeamCntByCity(cityId: number, leagueCode?: string) {
const query = { cityId };
if (leagueCode) {
query['leagueCode'] = leagueCode;
}
const teams: GVGTeamType[] = await GVGTeamModel.find(query).select('').lean();
return teams.length;
}
// 玩家切换城池更新队伍信息
public static async enterCity(roleId: string, cityId: number, areaId: number, groupId: number, serverType: number) {
const res = await GVGTeamModel.updateMany({ roleId }, { cityId, areaId, pointId: 0, groupId, serverType }).lean();