武将:抽象武将创建接口
This commit is contained in:
+11
-2
@@ -156,6 +156,15 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async findMapByHidRange(hids: Array<number>, roleId: string, select?: string, getters = false) {
|
||||
const hero = await HeroModel.findByHidRange(hids, roleId, select, getters);
|
||||
let map = new Map<number, HeroType>();
|
||||
for(let h of hero) {
|
||||
map.set(h.hid, h);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public static async findBySeqIdAndRole(seqId: number, roleId: string, lean = true) {
|
||||
const hero: HeroType = await HeroModel.findOne({ seqId, roleId }).lean(lean);
|
||||
return hero;
|
||||
@@ -241,9 +250,9 @@ export default class Hero extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateHeroInfo(roleId: string, hid:number, heroUpdate:HeroUpdate, select?: string, lean = true) {
|
||||
public static async updateHeroInfo(roleId: string, hid:number, heroUpdate:HeroUpdate, select?: string, getters = false) {
|
||||
delete heroUpdate._id;
|
||||
let result: HeroType = await HeroModel.findOneAndUpdate({roleId, hid}, {$set:heroUpdate}, {new: true}).select(select).lean(lean);
|
||||
let result: HeroType = await HeroModel.findOneAndUpdate({roleId, hid}, {$set:heroUpdate}, {new: true}).select(select).lean({ getters });
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user