✨ feat(gvgBattle): 填充接口,通过部分激战期用例测试
This commit is contained in:
+15
-1
@@ -10,7 +10,7 @@ export default class GVGCity extends BaseModel {
|
||||
@prop({ required: true })
|
||||
cityId: number; // 城池id
|
||||
|
||||
@prop({ required: true })
|
||||
@prop({ required: true, default: [] })
|
||||
leagueCodes: string[]; // 联军
|
||||
|
||||
@prop({ required: false })
|
||||
@@ -24,6 +24,20 @@ export default class GVGCity extends BaseModel {
|
||||
|
||||
@prop({ required: true, default: 0 })
|
||||
teamCnt: number; // 城池队伍数
|
||||
|
||||
// 创建城市
|
||||
public static async createCity(configId: number, cityId: number) {
|
||||
let doc = new GVGCityModel();
|
||||
let update = Object.assign(doc.toJSON(), { configId, cityId});
|
||||
const city: GVGCityType | null = await GVGCityModel.findOneAndUpdate({ configId, cityId }, { $setOnInsert: update }, { upsert: true, new: true }).lean();
|
||||
return city;
|
||||
}
|
||||
|
||||
// 通过 cityId 获取城市
|
||||
public static async getCityByCityId(cityId: number) {
|
||||
const city: GVGCityType | null = await GVGCityModel.findOne({ cityId }).lean();
|
||||
return city;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user