From 29273d7a8b25a491d4d86c8d795d8f695a7c6ac3 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Sun, 30 Jul 2023 13:17:53 +0000 Subject: [PATCH] =?UTF-8?q?refac,wip:=20GeneralQueryMode=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20-=20GeneralQueryMode=20-=20General=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EC=9A=A9=20-=20GeneralLiteQueryMode=20-=20GeneralLite?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1=EC=9A=A9=20-=20=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?=ED=86=B5=ED=95=B4=20=ED=99=95=EC=8B=A4=ED=95=9C=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20=EB=A9=94=EC=8B=9C=EC=A7=80=EB=A5=BC=20=EB=82=B4?= =?UTF-8?q?=EC=A4=84=20=EA=B2=83=EC=9C=BC=EB=A1=9C..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/b_betting.php | 2 +- hwe/sammo/Enums/GeneralLiteQueryMode.php | 14 ++++++++++++++ hwe/sammo/Enums/GeneralQueryMode.php | 6 ------ hwe/sammo/General.php | 8 -------- hwe/sammo/GeneralBase.php | 15 ++++++++------- hwe/sammo/GeneralLite.php | 14 +++++--------- 6 files changed, 28 insertions(+), 31 deletions(-) create mode 100644 hwe/sammo/Enums/GeneralLiteQueryMode.php diff --git a/hwe/b_betting.php b/hwe/b_betting.php index 35b4fae8..a024be23 100644 --- a/hwe/b_betting.php +++ b/hwe/b_betting.php @@ -569,7 +569,7 @@ if ($str3) { [$prizeColumn->value, $gameColumn->value, $winColumn->value, $drawColumn->value, $loseColumn->value, 'leadership', 'strength', 'intel', 'no', 'npc', 'name'], GeneralQueryMode::Core ); - usort($tournamentRankerList, function (General $lhs, General $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) { + usort($tournamentRankerList, function (GeneralLite $lhs, GeneralLite $rhs) use ($gameColumn, $winColumn, $drawColumn, $loseColumn) { $result = - ($lhs->getRankVar($gameColumn) <=> $rhs->getRankVar($gameColumn)); if ($result !== 0) return $result; $result = - ( diff --git a/hwe/sammo/Enums/GeneralLiteQueryMode.php b/hwe/sammo/Enums/GeneralLiteQueryMode.php new file mode 100644 index 00000000..e449cc34 --- /dev/null +++ b/hwe/sammo/Enums/GeneralLiteQueryMode.php @@ -0,0 +1,14 @@ +name); - } - $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); @@ -1013,10 +1009,6 @@ class General extends GeneralBase implements iAction static public function createGeneralObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): self { - if($queryMode < GeneralQueryMode::Full){ - throw new \InvalidArgumentException('충분하지 않은 queryMode:' . $queryMode->name); - } - $db = DB::db(); $gameStor = KVStorage::getStorage($db, 'game_env'); [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); diff --git a/hwe/sammo/GeneralBase.php b/hwe/sammo/GeneralBase.php index 865e10f2..9b9c6757 100644 --- a/hwe/sammo/GeneralBase.php +++ b/hwe/sammo/GeneralBase.php @@ -4,6 +4,7 @@ namespace sammo; use Ds\Map; use sammo\Enums\GeneralAccessLogColumn; +use sammo\Enums\GeneralLiteQueryMode; use sammo\Enums\GeneralQueryMode; use sammo\Enums\RankColumn; @@ -145,7 +146,7 @@ abstract class GeneralBase abstract function applyDB($db): bool; - static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode $queryMode = GeneralQueryMode::Full): array + static public function mergeQueryColumn(?array $reqColumns = null, GeneralQueryMode|GeneralLiteQueryMode $queryMode = GeneralQueryMode::Full): array { $minimumColumn = ['no', 'name', 'owner', 'npc', 'city', 'nation', 'officer_level', 'officer_city']; $defaultEventColumn = [ @@ -170,11 +171,11 @@ abstract class GeneralBase if ($reqColumns === null) { switch ($queryMode) { - case GeneralQueryMode::Core: + case GeneralLiteQueryMode::Core: return [$minimumColumn, [], []]; - case GeneralQueryMode::Lite: + case GeneralLiteQueryMode::Lite: return [$defaultEventColumn, [], []]; - case GeneralQueryMode::FullWithoutIAction: + case GeneralLiteQueryMode::Full: case GeneralQueryMode::Full: return [$fullColumn, RankColumn::cases(), []]; case GeneralQueryMode::FullWithAccessLog: @@ -211,11 +212,11 @@ abstract class GeneralBase } switch ($queryMode) { - case GeneralQueryMode::Core: + case GeneralLiteQueryMode::Core: return [array_unique(array_merge($minimumColumn, $subColumn)), $rankColumn, $accessLogColumn]; - case GeneralQueryMode::Lite: + case GeneralLiteQueryMode::Lite: return [array_unique(array_merge($defaultEventColumn, $subColumn)), $rankColumn, $accessLogColumn]; - case GeneralQueryMode::FullWithoutIAction: + case GeneralLiteQueryMode::Full: case GeneralQueryMode::Full: return [array_unique(array_merge($fullColumn, $subColumn)), $rankColumn, $accessLogColumn]; case GeneralQueryMode::FullWithAccessLog: diff --git a/hwe/sammo/GeneralLite.php b/hwe/sammo/GeneralLite.php index 0a310d70..93b664b8 100644 --- a/hwe/sammo/GeneralLite.php +++ b/hwe/sammo/GeneralLite.php @@ -3,7 +3,7 @@ namespace sammo; use Ds\Map; -use sammo\Enums\GeneralQueryMode; +use sammo\Enums\GeneralLiteQueryMode; use sammo\Enums\RankColumn; class GeneralLite extends GeneralBase @@ -64,17 +64,17 @@ class GeneralLite extends GeneralBase /** * @param ?int[] $generalIDList * @param null|array $column - * @param GeneralQueryMode $queryMode + * @param GeneralLiteQueryMode $queryMode * @return \sammo\GeneralLite[] * @throws MustNotBeReachedException */ - static public function createGeneralLiteObjListFromDB(?array $generalIDList, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::FullWithoutIAction): array + static public function createGeneralLiteObjListFromDB(?array $generalIDList, ?array $column = null, GeneralLiteQueryMode $queryMode = GeneralLiteQueryMode::Full): array { if ($generalIDList === []) { return []; } - if($queryMode > GeneralQueryMode::FullWithoutIAction){ + if($queryMode > GeneralLiteQueryMode::Full){ throw new \InvalidArgumentException('지원하지 않는 queryMode:' . $queryMode->name); } @@ -136,12 +136,8 @@ class GeneralLite extends GeneralBase return $result; } - static public function createGeneralLiteObjFromDB(int $generalID, ?array $column = null, GeneralQueryMode $queryMode = GeneralQueryMode::FullWithoutIAction): self + static public function createGeneralLiteObjFromDB(int $generalID, ?array $column = null, GeneralLiteQueryMode $queryMode = GeneralLiteQueryMode::Full): self { - if($queryMode > GeneralQueryMode::FullWithoutIAction){ - throw new \InvalidArgumentException('지원하지 않는 queryMode:' . $queryMode->name); - } - $db = DB::db(); if ($queryMode->value > 0) { $gameStor = KVStorage::getStorage($db, 'game_env');