装备查询
This commit is contained in:
@@ -31,6 +31,7 @@ interface equipUpdate {
|
||||
_id?:number;
|
||||
holes?:Array<Holes>;
|
||||
randSe?: Array<RandSe>;
|
||||
ePlaceId?:number;
|
||||
}
|
||||
|
||||
@index({ roleId: 1, hid: 1, id: 1 })
|
||||
|
||||
+15
-6
@@ -1,7 +1,7 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { CeAttr } from './generalField';
|
||||
import { index, getModelForClass, prop, Ref, mongoose, DocumentType } from '@typegoose/typegoose';
|
||||
import Equip from './Equip';
|
||||
import Equip, { EquipType } from './Equip';
|
||||
import { CounterModel } from './Counter';
|
||||
import { COUNTER, EQUIP_TYPE } from '../consts';
|
||||
|
||||
@@ -67,6 +67,7 @@ interface heroUpdate {
|
||||
favourLv?:number;
|
||||
skins?: Skin[];
|
||||
connections?: Connect[];
|
||||
ePlace?:EPlace[];
|
||||
_id?:number;
|
||||
}
|
||||
|
||||
@@ -146,10 +147,10 @@ export default class Hero extends BaseModel {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public static async addEquip(roleId: string, hid: number, equipId: string, lean = true) {
|
||||
public static async addEquip(roleId: string, hid: number, ePlaceId: number, equipId: string, lean = true) {
|
||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||
{ roleId, hid, 'ePlace.id': 1 },
|
||||
{$set: {'ePlace.$.equip': equipId}},
|
||||
{ roleId, hid, 'ePlace.id': ePlaceId },
|
||||
{$set: {'ePlace.$.equip': equipId, 'ePlace.$.hid':hid, 'ePlace.$.ePlaceId':ePlaceId}},
|
||||
{new: true}).lean(lean);
|
||||
if (hero) {
|
||||
await Equip.putOn(hero.hid, equipId);
|
||||
@@ -207,10 +208,18 @@ export default class Hero extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getHeroAndEquip(roleId: string, hid:number, lean = true) {
|
||||
let result: HeroType = await HeroModel.findOne({roleId, hid}).select('ePlact').lean(lean);
|
||||
public static async getHeroEquip(roleId: string, hid: number, lean = true) {
|
||||
let result: EquipType = await HeroModel.findOne({ roleId, hid }).populate('ePlace.equip').select('ePlace.equip').lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async unloadHeroAndEquip(roleId: string, hid: number, id: number, lean = true) {
|
||||
const hero: HeroType = await HeroModel.findOneAndUpdate(
|
||||
{ roleId, hid, 'ePlace.id': id },
|
||||
{$set: {'ePlace.$.equip': null}},
|
||||
{new: true}).lean(lean);
|
||||
return hero;
|
||||
}
|
||||
}
|
||||
|
||||
export const HeroModel = getModelForClass(Hero);
|
||||
|
||||
Reference in New Issue
Block a user