添加后台连接用的后端
This commit is contained in:
@@ -55,6 +55,11 @@ export default class Hero extends BaseModel {
|
||||
return heros || [];
|
||||
}
|
||||
|
||||
public static async findByHidAndRole(hid: number, roleId: string, lean = true) {
|
||||
const hero = await HeroModel.findOne({ hid, roleId }).lean(lean);
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async addEquip(roleId: string, hid: number, equipId: string, lean = true) {
|
||||
const hero = await HeroModel.findOneAndUpdate({ roleId, hid }, {$push: {equips: equipId}}, {new: true}).lean(lean);
|
||||
if (hero) {
|
||||
@@ -63,7 +68,7 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async createHero(heroInfo: {roleId: string, roleName: string, hid: number, hName: string, seqId: number}, lean = true) {
|
||||
public static async createHero(heroInfo: {roleId: string, roleName: string, hid: number, hName: string, seqId: number, lv?:number}, lean = true) {
|
||||
const doc = new HeroModel();
|
||||
const update = Object.assign(heroInfo, doc.toJSON());
|
||||
const hero = await HeroModel.findOneAndUpdate({roleId: heroInfo.roleId, hid: heroInfo.hid}, update, {upsert: true, new: true}).lean(lean);
|
||||
|
||||
Reference in New Issue
Block a user