cfmgrv4 init...10

This commit is contained in:
최준흠 2025-03-13 13:08:35 +09:00
parent 083568a3b6
commit 866d3f4555
11 changed files with 91 additions and 38 deletions

View File

@ -95,4 +95,9 @@ class AccountModel extends CommonModel
{
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
}
}

View File

@ -86,9 +86,9 @@ class AuditLogModel extends CommonModel
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word, $field = null): void
public function setList_WordFilter(string $word): void
{
parent::setList_WordFilter($word, $field);
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.zone_name', $word, 'both');
$this->orLike(self::TABLE . '.meta', $word, 'both');
$this->orLike(self::TABLE . '.resource', $word, 'both');

View File

@ -86,4 +86,10 @@ class AuthModel extends CommonModel
{
return $this->modify_process($entity, $formDatas);
}
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.authkey', $word, 'both');
$this->orLike(self::TABLE . '.oldkey', $word, 'both');
}
}

View File

@ -105,9 +105,9 @@ class FirewallModel extends CommonModel
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word, $field = null): void
public function setList_WordFilter(string $word): void
{
parent::setList_WordFilter($word, $field);
$this->orLike(self::TABLE . '.' . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.expression', $word, 'both');
}
}

View File

@ -128,9 +128,13 @@ class RecordModel extends CommonModel
}
}
//List 검색용
public function setList_WordFilter(string $word, $field = null): void
public function setList_WordFilter(string $word): void
{
parent::setList_WordFilter($word, $field);
$this->orLike(self::TABLE . '.content', $word, 'both');
if ($this->isIPAddress($word, 'ipv4')) {
$this->where(self::TABLE . '.content', $word);
} else {
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.content', $word, 'both');
}
}
}

View File

@ -130,30 +130,30 @@ class ZoneModel extends CommonModel
return is_null($this->first()) ? true : false;
}
//List 검색용
public function setList_WordFilter(string $word, $field = null): void
public function setList_WordFilter(string $word): void
{
//Record의 content(IP검색)을 하기위함
//Join 방식사용
// $this->join(RecordModel::TABLE, sprintf(
// "%s.%s=%s.%s",
// self::TABLE,
// self::PK,
// RecordModel::TABLE,
// RecordModel::PARENT
// ));
// parent::setList_WordFilter($word, $field);
// $this->orLike(RecordModel::TABLE . '.content', $word, 'both');
//Subquery 방식사용
$recordModel = new RecordModel();
$recordModel->like(RecordModel::TABLE . '.content', $word, 'both');
$recordModel->orlike(RecordModel::TABLE . '.' . RecordModel::TITLE, $word, 'both');
$recorde_entitys = $recordModel->select(RecordModel::PARENT)->findAll();
$zone_uids = array_column($recorde_entitys, RecordModel::PARENT);
parent::setList_WordFilter($word, $field);
if (count($zone_uids)) {
if ($this->isIPAddress($word, 'ipv4')) {
//Record의 content(IP검색)을 하기위함
//Join 방식사용
// $this->join(RecordModel::TABLE, sprintf(
// "%s.%s=%s.%s",
// self::TABLE,
// self::PK,
// RecordModel::TABLE,
// RecordModel::PARENT
// ));
// parent::setList_WordFilter($word, $field);
// $this->orLike(RecordModel::TABLE . '.content', $word, 'both');
//Subquery 방식사용
$recordModel = new RecordModel();
$recordModel->setList_WordFilter($word);
$recorde_entitys = $recordModel->select(RecordModel::PARENT)->findAll();
$zone_uids = array_column($recorde_entitys, RecordModel::PARENT);
$this->orWhereIn(self::TABLE . '.' . self::PK, array_values($zone_uids));
} else {
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.name_servers', $word, 'both');
$this->orLike(self::TABLE . '.original_name_servers', $word, 'both');
}
// var_dump($zone_uids);
// exit;
}
}

View File

@ -54,7 +54,7 @@ abstract class CommonModel extends Model
abstract public function getFields(): array;
abstract public function getFilterFields(): array;
abstract public function getBatchJobFields(): array;
abstract public function setList_WordFilter(string $word): void;
final public function getTable(): string
{
return $this->table;
@ -219,16 +219,29 @@ abstract class CommonModel extends Model
}
// List용
final public function isIPAddress(string $ip, $type = false): bool
{
switch ($type) {
case 'ipv4':
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
break;
case 'ipv6':
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
break;
case 'all':
$result = filter_var($ip, FILTER_VALIDATE_IP);
break;
default:
$result = filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE);
break;
}
return $result;
}
final public function setList_FieldFilter(string $field, int|string $value): void
{
$this->where($this->getTable() . '.' . $field, $value);
}
public function setList_WordFilter(string $word, string $field): void
{
$this->like($this->getTable() . '.' . $field, $word, 'both'); // before, after, both
}
final public function setList_DateFilter(string $start, string $end, $field = "created_at"): void
{
if ($start !== DEFAULTS['EMPTY']) {

View File

@ -73,4 +73,10 @@ class MapurlModel extends CommonModel
{
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.new_url', $word, 'both');
}
}

View File

@ -66,4 +66,10 @@ class MyLogModel extends CommonModel
{
return $this->create_process(new MyLogEntity(), $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.content', $word, 'both');
}
}

View File

@ -116,4 +116,11 @@ class UserModel extends CommonModel
{
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . '.id', $word, 'both');
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.email', $word, 'both');
}
}

View File

@ -95,10 +95,16 @@ class UserSNSModel extends CommonModel
{
return $this->create_process(new UserSNSEntity(), $formDatas);
}
//modify용
public function modify(UserSNSEntity $entity, array $formDatas): UserSNSEntity
{
return $this->modify_process($entity, $formDatas);
}
//List 검색용
public function setList_WordFilter(string $word): void
{
$this->orLike(self::TABLE . '.id', $word, 'both');
$this->orLike(self::TABLE . self::TITLE, $word, 'both');
$this->orLike(self::TABLE . '.email', $word, 'both');
}
}