🐞 fix(gvg): 修复战区问题,不跨服服务器应单列

This commit is contained in:
luying
2023-02-20 20:46:20 +08:00
parent 015b4293fb
commit 5b3747a78e
27 changed files with 324 additions and 390 deletions
+9 -12
View File
@@ -2,17 +2,14 @@ import BaseModel from "./BaseModel";
import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { GVGTeamType } from "./GVGTeam";
@index({ configId: 1, pontId: 1, groupId: 1, serverType: 1 })
@index({ configId: 1, pontId: 1, groupKey: 1 })
// GVGCityAreaPoint 类,继承自 BaseModel
export default class GVGCityAreaPoint extends BaseModel {
@prop({ required: true, default: 1 })
configId: number; // config唯一id
@prop({ required: true, default: 1 })
groupId: number; // 战区
@prop({ required: true, default: 1 })
serverType: number; // 1-单服 2-跨服
groupKey: string; // 战区
@prop({ required: true })
cityId: number; // 城池id
@@ -39,22 +36,22 @@ export default class GVGCityAreaPoint extends BaseModel {
teamCode: string; // 玩家的编队
public static async settlePoint(cityId: number, areaId: number, pointId: number, team: GVGTeamType) {
let { configId, groupId, serverType, leagueCode, leagueName, roleId, roleName, teamCode } = team;
await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupId, serverType, pointId }, { $setOnInsert: { teamCode: '' }}, { upsert: true });
let { configId, groupKey, leagueCode, leagueName, roleId, roleName, teamCode } = team;
await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupKey, pointId }, { $setOnInsert: { teamCode: '' }}, { upsert: true });
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate(
{ configId, groupId, serverType, pointId },
{ configId, groupKey, pointId },
{ $set: { cityId, areaId, leagueCode, leagueName, roleId, roleName, teamCode } },
{ new: true }).lean();
return result;
}
public static async leavePoint(configId: number, groupId: number, serverType: number, pointId: number) {
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupId, serverType, pointId }, { $set: { teamCode: '' }}, { new: true }).lean();
public static async leavePoint(configId: number, groupKey: string, pointId: number) {
let result: GVGCityAreaPointType = await GVGCityAreaPointModel.findOneAndUpdate({ configId, groupKey, pointId }, { $set: { teamCode: '' }}, { new: true }).lean();
return result;
}
public static async findByConfig(configId: number, groupId: number, serverType: number) {
let result: GVGCityAreaPointType[] = await GVGCityAreaPointModel.find({ configId, groupId, serverType }).lean();
public static async findByConfig(configId: number, groupKey: string) {
let result: GVGCityAreaPointType[] = await GVGCityAreaPointModel.find({ configId, groupKey }).lean();
return result
}
}