武将重生:完成接口
This commit is contained in:
+8
-3
@@ -248,11 +248,16 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async createHero(heroInfo: HeroUpdate, lean = true) {
|
||||
public static getInitInfo(heroInfo: HeroUpdate = {}): HeroUpdate {
|
||||
const doc = new HeroModel();
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
|
||||
const update = Object.assign(doc.toJSON(), heroInfo, { seqId });
|
||||
const update = { ...doc.toJSON(), ...heroInfo};
|
||||
delete update._id;
|
||||
return update
|
||||
}
|
||||
|
||||
public static async createHero(heroInfo: HeroUpdate, lean = true) {
|
||||
const seqId = await CounterModel.getNewCounter(COUNTER.HID) || -1;
|
||||
const update = this.getInitInfo({ ...heroInfo, seqId });
|
||||
const hero: HeroType = await HeroModel.findOneAndUpdate({ roleId: heroInfo.roleId, hid: heroInfo.hid }, update, { upsert: true, new: true }).lean(lean);
|
||||
return hero;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user