From d51a7119af7f72eb82b3bc1faeedbafd013ed392 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 20 Nov 2020 19:30:28 +0800 Subject: [PATCH] =?UTF-8?q?fix=20web-server=20tsc=E4=B8=8D=E9=80=9A?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/db/ComBattleTeam.ts | 3 ++- shared/db/Role.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/db/ComBattleTeam.ts b/shared/db/ComBattleTeam.ts index e946f67d5..4958a1d46 100644 --- a/shared/db/ComBattleTeam.ts +++ b/shared/db/ComBattleTeam.ts @@ -84,8 +84,9 @@ export default class ComBattleTeam extends BaseModel { return team; } - public static async updateResult(teamCode: string, roleId: string, isSuccess: boolean, lean = true) { + public static async updateResult(teamCode: string, roleId: string, isSuccess: boolean, _lean = true) { let team = await ComBattleTeamModel.findOne({teamCode}).select('status roleStatus'); + if(!team) return; if (isSuccess === true) { team.status = 2; team.roleStatus.forEach(st => { diff --git a/shared/db/Role.ts b/shared/db/Role.ts index 4025838d7..c985ef8af 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -387,7 +387,7 @@ export default class Role extends BaseModel { public static async saveDungeonHero(roleId: string, battleId: number, heroes: Array, isSuccess: boolean) { if(isSuccess) { const role = await Role.findByRoleId(roleId); - let {dungeonHeroes} = role; + let dungeonHeroes = role && role.dungeonHeroes; let hasHero = dungeonHeroes&&dungeonHeroes.find(cur => cur.battleId == battleId); if(!dungeonHeroes || !hasHero) { await RoleModel.findOneAndUpdate({roleId}, {$push:{dungeonHeroes: {battleId, heroes}}})