feat(gvgBattle): 添加部分保存阵容、进出城池等接口的逻辑

This commit is contained in:
liangtongchuan
2023-02-17 10:58:46 +08:00
committed by luying
parent 3fc6b91a51
commit 596e6e18cf
8 changed files with 197 additions and 29 deletions
+12 -3
View File
@@ -34,8 +34,14 @@ export default class GVGCity extends BaseModel {
}
// 通过 cityId 获取城市
public static async getCityByCityId(cityId: number) {
const city: GVGCityType | null = await GVGCityModel.findOne({ cityId }).lean();
public static async getCityByCityId(configId: number, cityId: number) {
const city: GVGCityType | null = await GVGCityModel.findOne({ configId, cityId }).lean();
return city;
}
// 更新城市字段
public static async updateCityUser(configId: number, cityId: number, userInc: number, teamInc: number) {
const city: GVGCityType | null = await GVGCityModel.findOneAndUpdate({ configId, cityId}, { $inc: {userCnt: userInc, teamCnt: teamInc} }, { new: true }).lean();
return city;
}
}
@@ -45,4 +51,7 @@ export const GVGCityModel = getModelForClass(GVGCity);
export interface GVGCityType extends Pick<DocumentType<GVGCity>, keyof GVGCity> {
id: number;
};
};
export type GVGCityUpdate = Partial<GVGCityType>; // 将所有字段变成可选项