添加后台连接用的后端

This commit is contained in:
luying
2020-09-22 11:09:15 +08:00
parent 6e891ec756
commit bcbed5959f
48 changed files with 14845 additions and 2076 deletions

View File

@@ -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);