change CLITools...1

This commit is contained in:
최준흠 2024-05-15 11:06:17 +09:00
parent 8eb87ebf43
commit 95f5246c7b
8 changed files with 31 additions and 20 deletions

View File

@ -2,21 +2,19 @@
namespace App\Controllers\CLI\Cloudflare\API; namespace App\Controllers\CLI\Cloudflare\API;
use App\Entities\Cloudflare\API\AccountEntity;
use App\Libraries\Log\Log; use App\Libraries\Log\Log;
class Account extends API 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) { if ($account_uid) {
$this->getAccountModel()->where(['account_uid' => $account_uid]); $wheres = ['account_uid' => $account_uid];
} else {
$this->getAccountModel()->where(['status' => 'use']);
} }
$entitys = $this->getAccountModel()->getEntitys($wheres);
Log::add("error", __FUNCTION__ . "에서 호출:" . $this->getAccountModel()->getLastQuery()); 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) final public function execute($auth_uid = 0, $page_limit = 0)
{ {

View File

@ -12,8 +12,8 @@ class Auth extends API
//transation처리 //transation처리
// $this->getAuthModel()->db->transBegin(); // $this->getAuthModel()->db->transBegin();
try { try {
$entitys = $this->getAuthModel()->asObject(AuthEntity::class)->where(['status' => 'use'])->findAll(); Log::add("error", __METHOD__ . "에서 Account Reload 시작");
foreach ($entitys as $entity) { foreach ($this->getAuthModel()->getEntitys(['status' => 'use']) as $entity) {
$api = new \App\Libraries\Cloudflare\API\Account($entity); $api = new \App\Libraries\Cloudflare\API\Account($entity);
$api->reload(); $api->reload();
} }

View File

@ -2,20 +2,21 @@
namespace App\Controllers\CLI\Cloudflare\API; namespace App\Controllers\CLI\Cloudflare\API;
use App\Entities\Cloudflare\API\ZoneEntity;
use App\Libraries\Log\Log; use App\Libraries\Log\Log;
class Zone extends API class Zone extends API
{ {
private function getZones(string $account_uid): array private function getZones(string $account_uid = ''): array
{ {
$wheres = ['status' => 'active'];
if ($account_uid) { if ($account_uid) {
$this->getZoneModel()->where(['account_uid' => $account_uid]); $wheres = ['account_uid' => $account_uid];
} else {
$this->getZoneModel()->where(['status' => 'active']);
} }
$entitys = $this->getZoneModel()->getEntitys($wheres);
// dd($this->getZoneModel()->getLastQuery());
Log::add("error", __FUNCTION__ . "에서 호출:" . $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,) final public function record($account_uid = '', $page_limit = 0,)
{ {

View File

@ -50,7 +50,7 @@ class AccountModel extends Model
protected $beforeDelete = []; protected $beforeDelete = [];
protected $afterDelete = []; protected $afterDelete = [];
public function getEntity(string $uid): null|AccountEntity public function getEntity(string $uid): AccountEntity
{ {
$entity = $this->asObject(AccountEntity::class)->where('uid', $uid)->first(); $entity = $this->asObject(AccountEntity::class)->where('uid', $uid)->first();
if (is_null($entity)) { if (is_null($entity)) {
@ -58,6 +58,10 @@ class AccountModel extends Model
} }
return $entity; return $entity;
} }
public function getEntitys(array $wheres)
{
return $this->asObject(AccountEntity::class)->where($wheres)->findAll();
}
//Account Status //Account Status
public function setStatusByAuth(int $auth_uid, $status) public function setStatusByAuth(int $auth_uid, $status)

View File

@ -49,7 +49,7 @@ class AuthModel extends Model
protected $beforeDelete = []; protected $beforeDelete = [];
protected $afterDelete = []; protected $afterDelete = [];
public function getEntity(string $uid): null|AuthEntity public function getEntity(string $uid): AuthEntity
{ {
$entity = $this->asObject(AuthEntity::class)->where('uid', $uid)->first(); $entity = $this->asObject(AuthEntity::class)->where('uid', $uid)->first();
if (is_null($entity)) { if (is_null($entity)) {
@ -57,6 +57,10 @@ class AuthModel extends Model
} }
return $entity; return $entity;
} }
public function getEntitys(array $wheres)
{
return $this->asObject(AuthEntity::class)->where($wheres)->findAll();
}
//Index 검색용 //Index 검색용
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)

View File

@ -59,7 +59,7 @@ class FirewallModel extends Model
return $this->table; 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(); $entity = $this->asObject(FirewallEntity::class)->where("uid", $uid)->first();
if (is_null($entity)) { if (is_null($entity)) {

View File

@ -62,7 +62,7 @@ class RecordModel extends Model
return $this->table; 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(); $entity = $this->asObject(RecordEntity::class)->where('uid', $uid)->first();
if (is_null($entity)) { if (is_null($entity)) {

View File

@ -61,7 +61,7 @@ class ZoneModel extends Model
return $this->table; 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(); $entity = $this->asObject(ZoneEntity::class)->where('uid', $uid)->first();
if (is_null($entity)) { if (is_null($entity)) {
@ -69,6 +69,10 @@ class ZoneModel extends Model
} }
return $entity; return $entity;
} }
public function getEntitys(array $wheres)
{
return $this->asObject(ZoneEntity::class)->where($wheres)->findAll();
}
//Index 검색용 //Index 검색용
public function setIndexWordFilter(string $word) public function setIndexWordFilter(string $word)