dbms_primeidc_init...1

This commit is contained in:
최준흠 2025-04-11 15:14:58 +09:00
parent 65fa05cb4f
commit 5b30849abe
4 changed files with 50 additions and 44 deletions

View File

@ -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__);

View File

@ -2,7 +2,6 @@
namespace lib\Controllers\DBMS;
use lib\Entities\ServerEntity;
use lib\Services\ServerService;
class ServerController extends DBMSController

View File

@ -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();
}
}

View File

@ -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();
}
}