From 5b30849abe7459b57e063bc92a11ae3f27fb42b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Fri, 11 Apr 2025 15:14:58 +0900 Subject: [PATCH] dbms_primeidc_init...1 --- .../Controllers/DBMS/GearlistController.php | 43 +++++++++++-------- .../lib/Controllers/DBMS/ServerController.php | 1 - extdbms/lib/Services/GearlistService.php | 25 ----------- extdbms/lib/Services/ServerService.php | 25 +++++++++++ 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/extdbms/lib/Controllers/DBMS/GearlistController.php b/extdbms/lib/Controllers/DBMS/GearlistController.php index 5451a42..9ce3a5c 100644 --- a/extdbms/lib/Controllers/DBMS/GearlistController.php +++ b/extdbms/lib/Controllers/DBMS/GearlistController.php @@ -4,23 +4,31 @@ namespace lib\Controllers\DBMS; use lib\Entities\GearlistEntity; use lib\Services\GearlistService; +use lib\Services\ServerService; class GearlistController extends DBMSController { - private ?GearlistService $_serverService = null; + private ?GearlistService $_gearlistServicerService = null; + private ?ServerService $_serverService = null; public function __construct() { parent::__construct(); $this->getView()->setPath('gearlist'); } // public function getGearlistService(): GearlistService + { + if ($this->_gearlistServicerService === null) { + $this->_gearlistServicerService = new GearlistService(); + } + return $this->_gearlistServicerService; + } + public function getServerService(): ServerService { if ($this->_serverService === null) { - $this->_serverService = new GearlistService(); + $this->_serverService = new ServerService(); } return $this->_serverService; } - //가용장비 현황 server_use.php //CLI 접속방법 : php index.php site/server/use //WEB 접속방법 : http://localhost site/server/use @@ -29,25 +37,24 @@ class GearlistController extends DBMSController $lineup_explode = explode('.', $entity->getSpec()); $spec = $lineup_explode[0]; $cpu = $entity->getCPUName(); - $entity->all = $this->getGearlistService()->getCountByMode("all", $cpu, $spec); - $entity->use = $this->getGearlistService()->getCountByMode("use", $cpu, $spec); - $entity->empty = $this->getGearlistService()->getCountByMode("empty", $cpu, $spec); - $entity->format = $this->getGearlistService()->getCountByMode("format", $cpu, $spec); + $entity->all = $this->getServerService()->getCountByMode("all", $cpu, $spec); + var_dump($entity->all); + exit; + $entity->use = $this->getServerService()->getCountByMode("use", $cpu, $spec); + $entity->empty = $this->getServerService()->getCountByMode("empty", $cpu, $spec); + $entity->format = $this->getServerService()->getCountByMode("format", $cpu, $spec); return $entity; } public function index(array $params): string { - $entities = $this->getGearlistService()->getEntitiesForLineUp(); - foreach ($entities as $idx => $entity) { - $entity = $this->setMode($entity); - } - $oldGearlists = [ - ['process' => "INTEL i5(구세대)", 'spec' => "i5-2.xx", "cpuname" => "i5-2", 'price' => "23"], - ['process' => "INTEL i7(구세대)", 'spec' => "i7-2.xx", "cpuname" => "i7-2", 'price' => "45"], - ['process' => "INTEL i7(4세대)", 'spec' => "i7-4.xx", "cpuname" => "i7-4", 'price' => "45"], - ]; - foreach ($oldGearlists as $oldGearlist) { - $entities[] = $this->setMode(new GearlistEntity($oldGearlist)); + $gearlistEntities = $this->getGearlistService()->getEntitiesForLineUp(); + //DB에 넣지않는 이유가 뭘까? DB에 넣으면 관리가 힘들어서? + $gearlistEntities[] = new GearlistEntity(['process' => "INTEL i5(구세대)", 'spec' => "i5-2.xx", "cpuname" => "i5-2", 'price' => "23"]); + $gearlistEntities[] = new GearlistEntity(['process' => "INTEL i7(구세대)", 'spec' => "i7-2.xx", "cpuname" => "i7-2", 'price' => "45"]); + $gearlistEntities[] = new GearlistEntity(['process' => "INTEL i7(4세대)", 'spec' => "i7-4.xx", "cpuname" => "i7-4", 'price' => "45"]); + $entities = []; + foreach ($gearlistEntities as $idx => $gearlistEntity) { + $entities[] = $this->setMode($gearlistEntity); } $this->entities = $entities; return $this->render(__FUNCTION__); diff --git a/extdbms/lib/Controllers/DBMS/ServerController.php b/extdbms/lib/Controllers/DBMS/ServerController.php index 1252a18..f8577ba 100644 --- a/extdbms/lib/Controllers/DBMS/ServerController.php +++ b/extdbms/lib/Controllers/DBMS/ServerController.php @@ -2,7 +2,6 @@ namespace lib\Controllers\DBMS; -use lib\Entities\ServerEntity; use lib\Services\ServerService; class ServerController extends DBMSController diff --git a/extdbms/lib/Services/GearlistService.php b/extdbms/lib/Services/GearlistService.php index 8948013..84f5681 100644 --- a/extdbms/lib/Services/GearlistService.php +++ b/extdbms/lib/Services/GearlistService.php @@ -35,29 +35,4 @@ class GearlistService extends CommonService $this->getModel()->orderBy(["process" => "ASC", "price" => "ASC", "cpuname" => "asc"]); return $this->getEntities(); } - - public function getCountByMode(string $mode, string $cpu, ?string $spec = null): int - { - switch ($mode) { - case 'all': - $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); - break; - case 'use': - $this->getModel()->where("server_use_status", "n"); - $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); - break; - case 'empty': - $this->getModel()->where("server_use_status", "y"); - $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); - break; - case 'format': - $this->getModel()->where("server_use_status", "y"); - $this->getModel()->where("server_fomat_date !='NULL'"); - $this->getModel()->like(["server_cpuname" => "%$cpu%"]); - break; - default: - throw new \InvalidArgumentException("Invalid mode: $mode"); - } - return $this->getCount(); - } } diff --git a/extdbms/lib/Services/ServerService.php b/extdbms/lib/Services/ServerService.php index 363714e..582bc9c 100644 --- a/extdbms/lib/Services/ServerService.php +++ b/extdbms/lib/Services/ServerService.php @@ -32,4 +32,29 @@ class ServerService extends CommonService $this->getModel()->where("service_code", $service_code); return $this->getCount(); } + + public function getCountByMode(string $mode, string $cpu, ?string $spec = null): int + { + switch ($mode) { + case 'all': + $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); + break; + case 'use': + $this->getModel()->where("server_use_status", "n"); + $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); + break; + case 'empty': + $this->getModel()->where("server_use_status", "y"); + $this->getModel()->like(["server_cpuname" => "%$cpu%", "server_spec" => "%$spec%"]); + break; + case 'format': + $this->getModel()->where("server_use_status", "y"); + $this->getModel()->where("server_fomat_date !='NULL'"); + $this->getModel()->like(["server_cpuname" => "%$cpu%"]); + break; + default: + throw new \InvalidArgumentException("Invalid mode: $mode"); + } + return $this->getCount(); + } }