dbms_primeidc_init...1
This commit is contained in:
parent
65fa05cb4f
commit
5b30849abe
@ -4,23 +4,31 @@ namespace lib\Controllers\DBMS;
|
|||||||
|
|
||||||
use lib\Entities\GearlistEntity;
|
use lib\Entities\GearlistEntity;
|
||||||
use lib\Services\GearlistService;
|
use lib\Services\GearlistService;
|
||||||
|
use lib\Services\ServerService;
|
||||||
|
|
||||||
class GearlistController extends DBMSController
|
class GearlistController extends DBMSController
|
||||||
{
|
{
|
||||||
private ?GearlistService $_serverService = null;
|
private ?GearlistService $_gearlistServicerService = null;
|
||||||
|
private ?ServerService $_serverService = null;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->getView()->setPath('gearlist');
|
$this->getView()->setPath('gearlist');
|
||||||
} //
|
} //
|
||||||
public function getGearlistService(): GearlistService
|
public function getGearlistService(): GearlistService
|
||||||
|
{
|
||||||
|
if ($this->_gearlistServicerService === null) {
|
||||||
|
$this->_gearlistServicerService = new GearlistService();
|
||||||
|
}
|
||||||
|
return $this->_gearlistServicerService;
|
||||||
|
}
|
||||||
|
public function getServerService(): ServerService
|
||||||
{
|
{
|
||||||
if ($this->_serverService === null) {
|
if ($this->_serverService === null) {
|
||||||
$this->_serverService = new GearlistService();
|
$this->_serverService = new ServerService();
|
||||||
}
|
}
|
||||||
return $this->_serverService;
|
return $this->_serverService;
|
||||||
}
|
}
|
||||||
|
|
||||||
//가용장비 현황 server_use.php
|
//가용장비 현황 server_use.php
|
||||||
//CLI 접속방법 : php index.php site/server/use
|
//CLI 접속방법 : php index.php site/server/use
|
||||||
//WEB 접속방법 : http://localhost site/server/use
|
//WEB 접속방법 : http://localhost site/server/use
|
||||||
@ -29,25 +37,24 @@ class GearlistController extends DBMSController
|
|||||||
$lineup_explode = explode('.', $entity->getSpec());
|
$lineup_explode = explode('.', $entity->getSpec());
|
||||||
$spec = $lineup_explode[0];
|
$spec = $lineup_explode[0];
|
||||||
$cpu = $entity->getCPUName();
|
$cpu = $entity->getCPUName();
|
||||||
$entity->all = $this->getGearlistService()->getCountByMode("all", $cpu, $spec);
|
$entity->all = $this->getServerService()->getCountByMode("all", $cpu, $spec);
|
||||||
$entity->use = $this->getGearlistService()->getCountByMode("use", $cpu, $spec);
|
var_dump($entity->all);
|
||||||
$entity->empty = $this->getGearlistService()->getCountByMode("empty", $cpu, $spec);
|
exit;
|
||||||
$entity->format = $this->getGearlistService()->getCountByMode("format", $cpu, $spec);
|
$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;
|
return $entity;
|
||||||
}
|
}
|
||||||
public function index(array $params): string
|
public function index(array $params): string
|
||||||
{
|
{
|
||||||
$entities = $this->getGearlistService()->getEntitiesForLineUp();
|
$gearlistEntities = $this->getGearlistService()->getEntitiesForLineUp();
|
||||||
foreach ($entities as $idx => $entity) {
|
//DB에 넣지않는 이유가 뭘까? DB에 넣으면 관리가 힘들어서?
|
||||||
$entity = $this->setMode($entity);
|
$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"]);
|
||||||
$oldGearlists = [
|
$gearlistEntities[] = new GearlistEntity(['process' => "INTEL i7(4세대)", 'spec' => "i7-4.xx", "cpuname" => "i7-4", 'price' => "45"]);
|
||||||
['process' => "INTEL i5(구세대)", 'spec' => "i5-2.xx", "cpuname" => "i5-2", 'price' => "23"],
|
$entities = [];
|
||||||
['process' => "INTEL i7(구세대)", 'spec' => "i7-2.xx", "cpuname" => "i7-2", 'price' => "45"],
|
foreach ($gearlistEntities as $idx => $gearlistEntity) {
|
||||||
['process' => "INTEL i7(4세대)", 'spec' => "i7-4.xx", "cpuname" => "i7-4", 'price' => "45"],
|
$entities[] = $this->setMode($gearlistEntity);
|
||||||
];
|
|
||||||
foreach ($oldGearlists as $oldGearlist) {
|
|
||||||
$entities[] = $this->setMode(new GearlistEntity($oldGearlist));
|
|
||||||
}
|
}
|
||||||
$this->entities = $entities;
|
$this->entities = $entities;
|
||||||
return $this->render(__FUNCTION__);
|
return $this->render(__FUNCTION__);
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace lib\Controllers\DBMS;
|
namespace lib\Controllers\DBMS;
|
||||||
|
|
||||||
use lib\Entities\ServerEntity;
|
|
||||||
use lib\Services\ServerService;
|
use lib\Services\ServerService;
|
||||||
|
|
||||||
class ServerController extends DBMSController
|
class ServerController extends DBMSController
|
||||||
|
|||||||
@ -35,29 +35,4 @@ class GearlistService extends CommonService
|
|||||||
$this->getModel()->orderBy(["process" => "ASC", "price" => "ASC", "cpuname" => "asc"]);
|
$this->getModel()->orderBy(["process" => "ASC", "price" => "ASC", "cpuname" => "asc"]);
|
||||||
return $this->getEntities();
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,4 +32,29 @@ class ServerService extends CommonService
|
|||||||
$this->getModel()->where("service_code", $service_code);
|
$this->getModel()->where("service_code", $service_code);
|
||||||
return $this->getCount();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user