diff --git a/app/Controllers/CLI/Cloudflare/API/Account.php b/app/Controllers/CLI/Cloudflare/API/Account.php index 200da8f..a77611e 100644 --- a/app/Controllers/CLI/Cloudflare/API/Account.php +++ b/app/Controllers/CLI/Cloudflare/API/Account.php @@ -2,21 +2,19 @@ namespace App\Controllers\CLI\Cloudflare\API; -use App\Entities\Cloudflare\API\AccountEntity; use App\Libraries\Log\Log; class Account extends API { - private function getAccounts(int $account_uid): array + private function getAccounts(int $account_uid = 0): array { - $this->getAccountModel()->where(['status' => 'active']); + $wheres = ['status' => 'use']; if ($account_uid) { - $this->getAccountModel()->where(['account_uid' => $account_uid]); - } else { - $this->getAccountModel()->where(['status' => 'use']); + $wheres = ['account_uid' => $account_uid]; } + $entitys = $this->getAccountModel()->getEntitys($wheres); Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getAccountModel()->getLastQuery()); - return $this->getAccountModel()->asObject(AccountEntity::class)->findAll(); + return $entitys; } final public function execute($auth_uid = 0, $page_limit = 0) { diff --git a/app/Controllers/CLI/Cloudflare/API/Auth.php b/app/Controllers/CLI/Cloudflare/API/Auth.php index ecfec56..02c3c90 100644 --- a/app/Controllers/CLI/Cloudflare/API/Auth.php +++ b/app/Controllers/CLI/Cloudflare/API/Auth.php @@ -12,8 +12,8 @@ class Auth extends API //transation처리 // $this->getAuthModel()->db->transBegin(); try { - $entitys = $this->getAuthModel()->asObject(AuthEntity::class)->where(['status' => 'use'])->findAll(); - foreach ($entitys as $entity) { + Log::add("error", __METHOD__ . "에서 Account Reload 시작"); + foreach ($this->getAuthModel()->getEntitys(['status' => 'use']) as $entity) { $api = new \App\Libraries\Cloudflare\API\Account($entity); $api->reload(); } diff --git a/app/Controllers/CLI/Cloudflare/API/Zone.php b/app/Controllers/CLI/Cloudflare/API/Zone.php index 40c6670..f9bafb8 100644 --- a/app/Controllers/CLI/Cloudflare/API/Zone.php +++ b/app/Controllers/CLI/Cloudflare/API/Zone.php @@ -2,20 +2,21 @@ namespace App\Controllers\CLI\Cloudflare\API; -use App\Entities\Cloudflare\API\ZoneEntity; use App\Libraries\Log\Log; class Zone extends API { - private function getZones(string $account_uid): array + private function getZones(string $account_uid = ''): array { + $wheres = ['status' => 'active']; if ($account_uid) { - $this->getZoneModel()->where(['account_uid' => $account_uid]); - } else { - $this->getZoneModel()->where(['status' => 'active']); + $wheres = ['account_uid' => $account_uid]; } + $entitys = $this->getZoneModel()->getEntitys($wheres); + // dd($this->getZoneModel()->getLastQuery()); Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getZoneModel()->getLastQuery()); - return $this->getZoneModel()->asObject(ZoneEntity::class)->findAll(); + // dd($entitys); + return $entitys; } final public function record($account_uid = '', $page_limit = 0,) { diff --git a/app/Models/Cloudflare/API/AccountModel.php b/app/Models/Cloudflare/API/AccountModel.php index 9c4c8d9..9fdfff4 100644 --- a/app/Models/Cloudflare/API/AccountModel.php +++ b/app/Models/Cloudflare/API/AccountModel.php @@ -50,7 +50,7 @@ class AccountModel extends Model protected $beforeDelete = []; protected $afterDelete = []; - public function getEntity(string $uid): null|AccountEntity + public function getEntity(string $uid): AccountEntity { $entity = $this->asObject(AccountEntity::class)->where('uid', $uid)->first(); if (is_null($entity)) { @@ -58,6 +58,10 @@ class AccountModel extends Model } return $entity; } + public function getEntitys(array $wheres) + { + return $this->asObject(AccountEntity::class)->where($wheres)->findAll(); + } //Account Status public function setStatusByAuth(int $auth_uid, $status) diff --git a/app/Models/Cloudflare/API/AuthModel.php b/app/Models/Cloudflare/API/AuthModel.php index 3dbb589..2d502ba 100644 --- a/app/Models/Cloudflare/API/AuthModel.php +++ b/app/Models/Cloudflare/API/AuthModel.php @@ -49,7 +49,7 @@ class AuthModel extends Model protected $beforeDelete = []; protected $afterDelete = []; - public function getEntity(string $uid): null|AuthEntity + public function getEntity(string $uid): AuthEntity { $entity = $this->asObject(AuthEntity::class)->where('uid', $uid)->first(); if (is_null($entity)) { @@ -57,6 +57,10 @@ class AuthModel extends Model } return $entity; } + public function getEntitys(array $wheres) + { + return $this->asObject(AuthEntity::class)->where($wheres)->findAll(); + } //Index 검색용 public function setIndexWordFilter(string $word) diff --git a/app/Models/Cloudflare/API/FirewallModel.php b/app/Models/Cloudflare/API/FirewallModel.php index 6a5353f..fb6d614 100644 --- a/app/Models/Cloudflare/API/FirewallModel.php +++ b/app/Models/Cloudflare/API/FirewallModel.php @@ -59,7 +59,7 @@ class FirewallModel extends Model return $this->table; } - public function getEntity(string $uid): null|FirewallEntity + public function getEntity(string $uid): FirewallEntity { $entity = $this->asObject(FirewallEntity::class)->where("uid", $uid)->first(); if (is_null($entity)) { diff --git a/app/Models/Cloudflare/API/RecordModel.php b/app/Models/Cloudflare/API/RecordModel.php index 492faad..041afa4 100644 --- a/app/Models/Cloudflare/API/RecordModel.php +++ b/app/Models/Cloudflare/API/RecordModel.php @@ -62,7 +62,7 @@ class RecordModel extends Model return $this->table; } - public function getEntity(string $uid): null|RecordEntity + public function getEntity(string $uid): RecordEntity { $entity = $this->asObject(RecordEntity::class)->where('uid', $uid)->first(); if (is_null($entity)) { diff --git a/app/Models/Cloudflare/API/ZoneModel.php b/app/Models/Cloudflare/API/ZoneModel.php index c4c2db2..ae5fc0a 100644 --- a/app/Models/Cloudflare/API/ZoneModel.php +++ b/app/Models/Cloudflare/API/ZoneModel.php @@ -61,7 +61,7 @@ class ZoneModel extends Model return $this->table; } - public function getEntity(string $uid): null|ZoneEntity + public function getEntity(string $uid): ZoneEntity { $entity = $this->asObject(ZoneEntity::class)->where('uid', $uid)->first(); if (is_null($entity)) { @@ -69,6 +69,10 @@ class ZoneModel extends Model } return $entity; } + public function getEntitys(array $wheres) + { + return $this->asObject(ZoneEntity::class)->where($wheres)->findAll(); + } //Index 검색용 public function setIndexWordFilter(string $word)