升级建筑物
This commit is contained in:
@@ -145,6 +145,21 @@ export default class Guild extends BaseModel {
|
||||
const result = await GuildModel.findOneAndUpdate({ code }, { $set: update, $inc: incParam }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async upStructure(code: string, id: number, select?: string) {
|
||||
if (id == GUILD_STRUCTURE.ARMY_CENTER) {
|
||||
const result = await GuildModel.findOneAndUpdate({ code, 'structure.id': id }, { $inc: { 'structure.$.lv': 1, lv: 1 }, $set: { isMemberMax: false } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
} else {
|
||||
const result = await GuildModel.findOneAndUpdate({ code, 'structure.id': id }, { $inc: { 'structure.$.lv': 1 } }, { new: true }).select(select).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public static async costFund(code: string, cost: number) {
|
||||
const result = await GuildModel.findOneAndUpdate({ code, fund: {$gte: cost}}, { $inc: { fund: -1 * cost } }, {new: true}).lean();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
export const GuildModel = getModelForClass(Guild);
|
||||
|
||||
Reference in New Issue
Block a user