From ddb7ee1ec2328e0c91a88bc19869fc827bb1ff61 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 25 Apr 2022 02:04:31 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B5=AD=EA=B0=80=20=EB=B2=A0=ED=8C=85?= =?UTF-8?q?=EC=9E=A5=EC=97=90=EC=84=9C=20'=ED=86=A0=EB=84=88=EB=A8=BC?= =?UTF-8?q?=ED=8A=B8'=EB=8A=94=20=EB=B3=B4=EC=97=AC=EC=A3=BC=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EA=B8=B0=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Betting/GetBettingList.php | 13 ++++++++++++- hwe/ts/PageNationBetting.vue | 4 +++- hwe/ts/SammoAPI.ts | 4 +++- hwe/ts/defs/API/Betting.ts | 2 +- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/hwe/sammo/API/Betting/GetBettingList.php b/hwe/sammo/API/Betting/GetBettingList.php index 57a25fbf..aecd111f 100644 --- a/hwe/sammo/API/Betting/GetBettingList.php +++ b/hwe/sammo/API/Betting/GetBettingList.php @@ -7,6 +7,7 @@ use DateTimeInterface; use sammo\DB; use sammo\DTO\BettingInfo; use sammo\KVStorage; +use sammo\Validator; use function sammo\checkLimit; use function sammo\increaseRefresh; @@ -15,6 +16,11 @@ class GetBettingList extends \sammo\BaseAPI { public function validateArgs(): ?string { + $v = new Validator($this->args); + $v->rule('in', 'req', ['bettingNation', 'tournament']); + if (!$v->validate()) { + return $v->errorStr(); + } return null; } @@ -27,6 +33,8 @@ class GetBettingList extends \sammo\BaseAPI { $db = DB::db(); + $reqType = $this->args['req'] ?? null; + increaseRefresh("베팅장", 1); $gameStor = KVStorage::getStorage($db, 'game_env'); @@ -42,6 +50,9 @@ class GetBettingList extends \sammo\BaseAPI $bettingList = []; foreach ($bettingStor->getAll() as $_key => $rawItem) { $item = new BettingInfo($rawItem); + if ($reqType !== null && $item->type != $reqType) { + continue; + } unset($rawItem['candidates']); $bettingList[$item->id] = $rawItem; $bettingList[$item->id]['totalAmount'] = 0; @@ -49,7 +60,7 @@ class GetBettingList extends \sammo\BaseAPI [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); - if(!$bettingList){ + if (!$bettingList) { return [ 'result' => true, 'bettingList' => $bettingList, diff --git a/hwe/ts/PageNationBetting.vue b/hwe/ts/PageNationBetting.vue index 7f0b28bd..b0e82f20 100644 --- a/hwe/ts/PageNationBetting.vue +++ b/hwe/ts/PageNationBetting.vue @@ -55,7 +55,9 @@ function addToast(msg: ToastType) { console.log("시작!"); onMounted(async () => { try { - const result = await SammoAPI.Betting.GetBettingList(); + const result = await SammoAPI.Betting.GetBettingList({ + req: 'bettingNation' + }); year.value = result.year; month.value = result.month; yearMonth.value = joinYearMonth(result.year, result.month); diff --git a/hwe/ts/SammoAPI.ts b/hwe/ts/SammoAPI.ts index 2984cf5c..578d6c31 100644 --- a/hwe/ts/SammoAPI.ts +++ b/hwe/ts/SammoAPI.ts @@ -25,7 +25,9 @@ const apiRealPath = { GetBettingDetail: NumVar('betting_id', GET as APICallT ), - GetBettingList: GET as APICallT, + GetBettingList: GET as APICallT<{ + req?: 'bettingNation' | 'tournament' + }, BettingListResponse>, }, Command: { GetReservedCommand: GET as APICallT, diff --git a/hwe/ts/defs/API/Betting.ts b/hwe/ts/defs/API/Betting.ts index 03a6fb67..7170067f 100644 --- a/hwe/ts/defs/API/Betting.ts +++ b/hwe/ts/defs/API/Betting.ts @@ -26,7 +26,7 @@ export type BettingInfo = { reqInheritancePoint: boolean; openYearMonth: number; closeYearMonth: number; - candidates: Record; + candidates: Record; winner?: number[]; }