dbms_primeidc_init...1

This commit is contained in:
최준흠 2025-04-03 11:29:24 +09:00
parent 178f94882d
commit d0d78151fe
24 changed files with 145 additions and 207 deletions

View File

@ -11,10 +11,11 @@ abstract class BaseController extends CommonController
public function __construct()
{
parent::__construct();
//View의 추가디렉토리
$this->getView()->setPath('dbms');
} //
final public function getService(): ServiceService
final public function getServiceervice(): ServiceService
{
if ($this->_service === null) {
$this->_service = new ServiceService();

View File

@ -69,11 +69,11 @@ class DashboardController extends BaseController
//예외,service_line = "test","substitution"
$excepts = ["test", "substitution"];
$this->day = intval($_ENV['SITE_DASHBOARD_DAY'] ?? $_SERVER['SITE_DASHBOARD_DAY'] ?? 7);
$this->newServers = $this->getService()->getNewServerCount($this->day, $excepts);
$this->newServers = $this->getServiceervice()->getNewServerCount($this->day, $excepts);
// 금일기준 미납서버수
//예외,service_line = "test","substitution",C012:게임윙,C116:WinIDC,C219:IDC-JP
$excepts = ["test", "substitution", 'C116', 'C012', 'C219'];
$this->unPayments = $this->getService()->getUnPaymentCount($excepts);
$this->unPayments = $this->getServiceervice()->getUnPaymentCount($excepts);
return $this->render(__FUNCTION__);
}
@ -90,7 +90,7 @@ class DashboardController extends BaseController
}
//사이트 정보 가져오기
$this->siteInfo = DBMS_SITEINFOS[$sitekey];
$this->totalcount = $this->getService()->getTotalCount($this->siteInfo);
$this->totalcount = $this->getServiceervice()->getTotalCount($this->siteInfo);
$summary = array();
foreach ($this->siteInfo['totalcount_types'] as $type) {
$summary[$type] = array("Tokyo" => 0, "Chiba" => 0);
@ -120,8 +120,8 @@ class DashboardController extends BaseController
{
//신규서버정보
$this->limit = intval($limit);
$this->entitys = $this->getService()->getNews($this->limit);
// echo $this->getService()->getModel()->getLastQuery();
$this->entitys = $this->getServiceervice()->getNews($this->limit);
// echo $this->getServiceervice()->getModel()->getLastQuery();
// 배열 초기화를 명시적으로 수행
$users = [];
$clients = [];
@ -133,7 +133,7 @@ class DashboardController extends BaseController
//관리자정보(등록자)
$users[$serviceCode] = $entity->getMemberCode() ? $this->getMemberService()->getEntitById($entity->getMemberCode()) : "";
//고객정보
$clients[$serviceCode] = $this->getClientService()->getEntitByCode($entity->getClientCode());
$clients[$serviceCode] = $this->getClientService()->getEntityByCode($entity->getClientCode());
//VPC정보
$vpcs[$serviceCode] = $this->getVPCService()->getCountByServiceCode($serviceCode);
//KCS정보
@ -161,10 +161,10 @@ class DashboardController extends BaseController
foreach ($this->entitys as $entity) {
$pk = $entity->getPK();
//서비스정보가져오기
$service = $this->getService()->getServiceByServiceCode($entity->getServiceCode());
$service = $this->getServiceervice()->getEntityByCode($entity->getServiceCode());
if ($service) {
//고객정보
$clients[$pk] = $this->getClientService()->getEntitByCode($service->getClientCode());
$clients[$pk] = $this->getClientService()->getEntityByCode($service->getClientCode());
//서비스정보
$services[$pk] = $service;
}

View File

@ -3,6 +3,7 @@
namespace lib\Controllers\DBMS;
use lib\Services\ClientService;
use lib\Helpers\ServiceHelper;
class NavigatorController extends BaseController
{
@ -12,6 +13,7 @@ class NavigatorController extends BaseController
{
parent::__construct();
$this->getView()->setPath('navigator');
$this->helper = new ServiceHelper();
} //
public function getClientService(): ClientService
{
@ -24,12 +26,14 @@ class NavigatorController extends BaseController
//부가서비스 : 닷디펜더,딥파인더 등, deepfinder_list.php,dotdefender_list.php
//CLI 접속방법 : php index.php SiteController/extraservice/client_code/코드번호
//WEB 접속방법 : http://localhost/SiteController/extraservice/sitekey/dbms.prime-idc.jp/client_code/코드번호
public function ipsearch(mixed $ip = null): string
public function ipsearch(): string
{
$clients = [];
$services = $this->getService()->getServicesByIP($ip);
$ip = $this->getRequest('ip');
//IP형식이 ipv4인지 확인 후 값가져오기
$services = $ip && $this->helper->isIPAddress($ip) ? $this->getServiceervice()->getEntitysByIP($ip) : $this->getServiceervice()->getEntitys();
foreach ($services as $service) {
$clients[$service->getPK()] = $this->getClientService()->getEntitByCode($service->getClientCode());
$clients[$service->getPK()] = $this->getClientService()->getEntityByCode($service->getClientCode());
}
$this->services = $services;
$this->clients = $clients;

View File

@ -43,7 +43,7 @@ class PaymentController extends BaseController
if (!$this->siteInfo) {
throw new \Exception("[{$sitekey}] 값에 해당하는 사이트정보가 존재하지 않습니다.");
}
$this->client = $this->getClientService()->getEntitByCode($client_code);
$this->client = $this->getClientService()->getEntityByCode($client_code);
if (!$this->client) {
throw new \Exception("[{$client_code}] 값에 해당하는 고객정보가 존재하지 않습니다.");
}

View File

@ -42,16 +42,22 @@ class ServiceController extends BaseController
throw new \Exception("adddb_code 값이 정의되지 않았습니다.");
}
}
//해당 부가서비스의 services_code 목록 가져오기
//segment의 값이 한글인경우 urldecode가 필요
$adddb_code = urldecode($adddb_code);
$service_codes = $this->getAddDbService()->getServiceCodesByCode($adddb_code);
$service_codes = [];
$entitys = $this->getAddDbService()->getEntitysByCode(urldecode($adddb_code));
var_dump($entitys);
exit;
foreach ($entity as $entity) {
$service_codes[] = $entity->getServiceCode();
}
if (!count($service_codes)) {
throw new \Exception("[{$adddb_code}] 값에 해당하는 부가서비스정보가 존재하지 않습니다.");
}
$clients = [];
$services = $this->getService()->geServicesBytExtras($service_codes);
$services = $this->getServiceervice()->getEntitysByCodes($service_codes);
foreach ($services as $service) {
$clients[$service->getPK()] = $this->getClientService()->getEntitByCode($service->getClientCode());
$clients[$service->getPK()] = $this->getClientService()->getEntityByCode($service->getClientCode());
}
$this->services = $services;
$this->clients = $clients;

View File

@ -8,6 +8,7 @@ use lib\Configs\View;
abstract class Controller
{
private $_request = null;
private ?View $_view = null;
private $_segments = [];
protected function __construct()
@ -37,6 +38,16 @@ abstract class Controller
}
return array_key_exists($key, $this->_segments) ? $this->_segments[$key] : null;
}
final public function getRequest(mixed $key = null, string $method = "GET"): mixed
{
$requestDatas = $method === "POST" ? $_POST : $_GET;
$result = null;
if (!$key)
$result = $requestDatas;
else
$result = array_key_exists($key, $requestDatas) ? $requestDatas[$key] : null;
return $result;
}
public function render(string $path)
{
return $this->getView()->render($path);

View File

@ -160,13 +160,13 @@ abstract class Model
}
//Result
protected function getResult($mode = PDO::FETCH_ASSOC): mixed
public function getResult($mode = PDO::FETCH_ASSOC): mixed
{
$query = "{$this->_querys['SELECT']} FROM {$this->getTable()} {$this->_querys['JOIN']} {$this->getWhere()} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}";
$stmt = $this->execute($query);
return $stmt->fetch($mode);
}
protected function getResults($mode = PDO::FETCH_ASSOC): mixed
public function getResults($mode = PDO::FETCH_ASSOC): mixed
{
$query = "{$this->_querys["SELECT"]} FROM {$this->getTable()} {$this->_querys['JOIN']} {$this->getWhere()} {$this->_querys['ORDERBY']} {$this->_querys['LIMIT']}";
$stmt = $this->execute($query);

View File

@ -66,7 +66,7 @@ abstract class CommonHelper extends Core
return preg_match($pattern_validation, $domain);
}
final public function isIPAddress(string $ip, $type = false): bool
final public function isIPAddress(string $ip, $type = 'ipv4'): bool
{
switch ($type) {
case 'ipv4':

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\AddDbEntity as Entity;
use lib\Models\CommonModel as Model;
class AddDbModel extends Model
@ -14,8 +13,4 @@ class AddDbModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\ClientEntity as Entity;
use lib\Models\CommonModel as Model;
class ClientModel extends Model
@ -14,8 +13,4 @@ class ClientModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -10,8 +10,6 @@ abstract class CommonModel extends Core
{
parent::__construct();
} //
abstract public function getEntityClass(): string;
// self:: → 컴파일 타임에 결정되므로 BaseModel의 상수를 참조하게 됨.
// static:: → 실행 타임에 결정되므로 상속받은 클래스의 상수를 참조함.
final public function getTable(): string
@ -26,23 +24,4 @@ abstract class CommonModel extends Core
{
return constant("static::TitleField");
}
public function getEntity(mixed $result = null): mixed
{
if (!$result) {
$result = $this->getResult();
if (!$result) { //결과값이 없으면 null
return $result;
}
}
$entityClass = $this->getEntityClass();
return new $entityClass($result);
}
public function getEntitys(): array
{
$entitys = [];
foreach ($this->getResults() as $result) {
$entitys[] = $this->getEntity($result);
}
return $entitys;
} //
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\HistoryEntity as Entity;
use lib\Models\CommonModel as Model;
class HistoryModel extends Model
@ -14,8 +13,4 @@ class HistoryModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\KCSEntity as Entity;
use lib\Models\CommonModel as Model;
class KCSModel extends Model
@ -14,8 +13,4 @@ class KCSModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\MemberEntity as Entity;
use lib\Models\CommonModel as Model;
class MemberModel extends Model
@ -14,8 +13,4 @@ class MemberModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\ServiceEntity as Entity;
use lib\Models\CommonModel as Model;
class ServiceModel extends Model
@ -14,8 +13,4 @@ class ServiceModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -2,7 +2,6 @@
namespace lib\Models;
use lib\Entities\VPCEntity as Entity;
use lib\Models\CommonModel as Model;
class VPCModel extends Model
@ -14,8 +13,4 @@ class VPCModel extends Model
{
parent::__construct();
} //
public function getEntityClass(): string
{
return Entity::class;
}
} //Class

View File

@ -7,7 +7,6 @@ use lib\Models\AddDbModel as Model;
class AddDbService extends CommonService
{
private ?Model $_model = null;
public function __construct()
{
parent::__construct();
@ -20,24 +19,19 @@ class AddDbService extends CommonService
{
return $this->getClassName();
}
protected function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getServiceCodesByCode(string $adddb_code): array
public function getEntityClass(): string
{
return Entity::class;
}
public function getEntitysByCode(string $value): array
{
//AddDBService에서 해당코드의(닷디펜더,딥파인더 등) Service_Code를 가져와서 배열에 저장
$this->getModel()->select('DISTINCT(service_code) AS service_code');
$this->getModel()->where('AddDB_code', $adddb_code);
$service_codes = [];
foreach ($this->getModel()->getEntitys() as $entity) {
$service_codes[] = $entity->getServiceCode();
}
return $service_codes;
$this->getModel()->where('AddDB_code', $value);
return $this->getEntitys();
}
}

View File

@ -7,7 +7,6 @@ use lib\Models\ClientModel as Model;
class ClientService extends CommonService
{
private ?Model $_model = null;
public function __construct()
{
parent::__construct();
@ -20,17 +19,17 @@ class ClientService extends CommonService
{
return $this->getClassName();
}
protected function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getEntitByCode(string $code): Entity|null|false
public function getEntityClass(): string
{
$this->getModel()->where("Client_Code", $code);
return $this->getModel()->getEntity();
return Entity::class;
}
public function getEntityByCode(string $value): mixed
{
$this->getModel()->where("Client_Code", $value);
return $this->getEntity();
}
}

View File

@ -3,13 +3,47 @@
namespace lib\Services;
use lib\Core\Service as Core;
use lib\Core\Model as Model;
abstract class CommonService extends Core
{
private $_model = null;
public function __construct()
{
parent::__construct();
} //
abstract protected function getModel(): Model;
abstract public function getModelClass(): string;
abstract public function getEntityClass(): string;
final public function getModel(): mixed
{
if ($this->_model === null) {
$modelClass = $this->getModelClass();
$this->_model = new $modelClass();
// $this->_model->setDebug(true);
}
return $this->_model;
}
final public function getEntity(): mixed
{
$result = $this->getModel()->getResult();
if (!$result) { //결과값이 없으면 null
return $result;
}
$entityClass = $this->getEntityClass();
return new $entityClass($result);
}
final public function getEntitys(): array
{
$entitys = [];
foreach ($this->getModel()->getResults() as $result) {
$entityClass = $this->getEntityClass();
$entitys[] = new $entityClass($result);
}
return $entitys;
} //
final public function getCount(): int
{
$count = $this->getModel()->countAllResults();
// echo "<BR>" . $this->getModel()->getLastQuery();
return $count;
}
} //Class

View File

@ -7,7 +7,6 @@ use lib\Models\HistoryModel as Model;
class HistoryService extends CommonService
{
private ?Model $_model = null;
public function __construct()
{
parent::__construct();
@ -20,19 +19,18 @@ class HistoryService extends CommonService
{
return $this->getClassName();
}
protected function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getEntityClass(): string
{
return Entity::class;
}
public function getNews(int $limit = 5): array
{
$this->getModel()->orderBy($this->getModel()->getPKField(), 'DESC');
$this->getModel()->limit($limit);
return $this->getModel()->getEntitys();
return $this->getEntitys();
}
}

View File

@ -7,7 +7,6 @@ use lib\Models\KCSModel as Model;
class KCSService extends CommonService
{
private ?Model $_model = null;
public function __construct()
{
parent::__construct();
@ -20,20 +19,17 @@ class KCSService extends CommonService
{
return $this->getClassName();
}
protected function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getEntityClass(): string
{
return Entity::class;
}
public function getCountByServiceCode(string $service_code): int
{
$this->getModel()->where("service_code", $service_code);
$count = $this->getModel()->countAllResults();
// echo "<BR>" . $this->getModel()->getLastQuery();
return $count;
return $this->getCount();
}
}

View File

@ -7,7 +7,6 @@ use lib\Models\MemberModel as Model;
class MemberService extends CommonService
{
private ?Model $_model = null;
public function __construct()
{
parent::__construct();
@ -20,17 +19,17 @@ class MemberService extends CommonService
{
return $this->getClassName();
}
public function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getEntityClass(): string
{
return Entity::class;
}
public function getEntitById(string $id): Entity
{
$this->getModel()->where($this->getModel()->getPKField(), $id);
return $this->getModel()->getEntity();
return $this->getEntity();
}
}

View File

@ -3,15 +3,10 @@
namespace lib\Services;
use lib\Entities\ServiceEntity as Entity;
use lib\Models\AdddbModel;
use lib\Models\ClientModel;
use lib\Models\ServiceModel as Model;
class ServiceService extends CommonService
{
private ?ClientModel $_clientModel = null;
private ?Model $_model = null;
private ?AdddbModel $_adddbModel = null;
public function __construct()
{
parent::__construct();
@ -24,27 +19,28 @@ class ServiceService extends CommonService
{
return $this->getClassName();
}
public function getModel(): Model
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new Model();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
final public function getClientModel(): ClientModel
public function getEntityClass(): string
{
if ($this->_clientModel === null) {
$this->_clientModel = new ClientModel();
}
return $this->_clientModel;
return Entity::class;
}
public function getAdddbModel(): AdddbModel
public function getEntityByCode(string $value): mixed
{
if ($this->_adddbModel === null) {
$this->_adddbModel = new AdddbModel();
}
return $this->_adddbModel;
$this->getModel()->where("service_code", $value);
return $this->getEntity();
}
public function getEntitysByIP(string $value): mixed
{
$this->getModel()->where("service_ip", $value);
return $this->getEntity();
}
public function getEntitysByCodes(array $values): array
{
$this->getModel()->whereIn('service_code', $values);
return $this->getEntitys();
}
public function getNewServerCount(int $day, array $excepts): int|string
@ -88,51 +84,11 @@ class ServiceService extends CommonService
} //foreach
return $temps;
}
final public function geServicesBytExtras(array $service_codes): mixed
{
// 공백 값 제거
$service_codes = array_filter($service_codes, function ($value) {
return !empty(trim($value)); // 공백 제거 후 비어있지 않은 값만 필터링
});
// 배열 키를 다시 정렬 (선택 사항)
$service_codes = array_values($service_codes);
// echo "<BR>" . $this->getAdddbModel()->getLastQuery();
// dd($service_codes);
if (!count($service_codes)) {
// echo $this->getAdddbModel()->getLastQuery();
return [];
}
// $this->getModel()->select("clientdb.Client_Name,{$this->getModel()->getTable()}.server_code,{$this->getModel()->getTable()}.service_ip,{$this->getModel()->getTable()}.service_os,{$this->getModel()->getTable()}.service_sw");
// $this->getModel()->join('clientdb', "{$this->getModel()->getTable()}.client_code=clientdb.Client_Code");
// $this->getModel()->whereIn('service_code', $service_codes);
// // $sql = sprintf("SELECT C.Client_Name,S.server_code,S.service_ip,S.service_os,S.service_sw
// FROM servicedb AS S JOIN clientdb AS C ON S.client_code = C.Client_Code
// WHERE S.service_code IN (SELECT service_code FROM adddb WHERE addDB_code ='%s')", $code);
// return $this->getRows($sql);
$this->getModel()->whereIn('service_code', $service_codes);
return $this->getModel()->getEntitys();
}
final public function getServicesByIP(string $ip): mixed
{
// 공백 값 제거
$ip = trim($ip);
// $this->getModel()->select("clientdb.*,{$this->getModel()->getTable()}.*");
// $this->getModel()->join('clientdb', "{$this->getModel()->getTable()}.client_code=clientdb.Client_Code");
$this->getModel()->where('service_ip', $ip);
return $this->getModel()->getEntitys();
}
public function getNews(int $limit): array
{
$this->getModel()->orderBy($this->getModel()->getPKField(), 'DESC');
$this->getModel()->limit($limit);
return $this->getModel()->getEntitys();
}
public function getServiceByServiceCode(string $service_code): Entity|null
{
$this->getModel()->where("service_code", $service_code);
return $this->getModel()->getEntity();
return $this->getEntitys();
}
}

View File

@ -2,12 +2,11 @@
namespace lib\Services;
use lib\Entities\VPCEntity;
use lib\Models\VPCModel;
use lib\Entities\VPCEntity as Entity;
use lib\Models\VPCModel as Model;
class VPCService extends CommonService
{
private ?VPCModel $_model = null;
public function __construct()
{
parent::__construct();
@ -20,20 +19,17 @@ class VPCService extends CommonService
{
return $this->getClassName();
}
public function getModel(): VPCModel
public function getModelClass(): string
{
if ($this->_model === null) {
$this->_model = new VPCModel();
// $this->_model->setDebug(true);
}
return $this->_model;
return Model::class;
}
public function getEntityClass(): string
{
return Entity::class;
}
public function getCountByServiceCode(string $service_code): int
{
$this->getModel()->where("service_code", $service_code);
$count = $this->getModel()->countAllResults();
// echo "<BR>" . $this->getModel()->getLastQuery();
return $count;
return $this->getCount();
}
}