dbms_primeidc/extdbms/lib/Controllers/DBMS/GearlistController.php
2025-04-11 14:25:56 +09:00

56 lines
2.1 KiB
PHP

<?php
namespace lib\Controllers\DBMS;
use lib\Entities\GearlistEntity;
use lib\Services\GearlistService;
class GearlistController extends DBMSController
{
private ?GearlistService $_serverService = null;
public function __construct()
{
parent::__construct();
$this->getView()->setPath('gearlist');
} //
public function getGearlistService(): GearlistService
{
if ($this->_serverService === null) {
$this->_serverService = new GearlistService();
}
return $this->_serverService;
}
//가용장비 현황 server_use.php
//CLI 접속방법 : php index.php site/server/use
//WEB 접속방법 : http://localhost site/server/use
private function setMode(GearlistEntity $entity): GearlistEntity
{
$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);
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));
}
$this->entities = $entities;
return $this->render(__FUNCTION__);
}
} //Class