From 110fe5dca6c7b434ce7f3cbc97b36537bf34ead0 Mon Sep 17 00:00:00 2001 From: hanshino Date: Sat, 7 Sep 2024 05:42:13 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3WorldBossController?= =?UTF-8?q?=E4=B8=AD=E7=9A=84lodash=E5=BC=95=E5=85=A5=E5=95=8F=E9=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修正WorldBossController中的lodash引入問題,將get函式改為isNull函式來處理totalCost的判斷,避免出現undefined的情況。 --- app/src/controller/application/WorldBossController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/controller/application/WorldBossController.js b/app/src/controller/application/WorldBossController.js index 9a75421..b37d692 100644 --- a/app/src/controller/application/WorldBossController.js +++ b/app/src/controller/application/WorldBossController.js @@ -639,7 +639,7 @@ async function isUserCanAttack(userId) { // 取得今日紀錄 const result = await worldBossEventLogService.getTodayCost(userId); - const totalCost = parseInt(get(result, "totalCost", 0)); + const totalCost = isNull(result.totalCost) ? 0 : parseInt(result.totalCost); // 如果完全沒有紀錄,代表可以攻擊 if (totalCost === 0) { await redis.set(key, 1, {