dbms_init...1

This commit is contained in:
최준흠 2025-05-21 19:32:53 +09:00
parent 5389a60e1a
commit a724b4c79f
22 changed files with 405 additions and 117 deletions

View File

@ -9,13 +9,15 @@ use Psr\Log\LoggerInterface;
use App\Helpers\Equipment\ServerHelper;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\PartService;
use App\Services\Equipment\ServerPartService;
use App\Services\Equipment\Part\CpuService;
use App\Services\Equipment\Part\RamService;
use App\Services\Equipment\Part\DiskService;
class ServerController extends EquipmentController
{
private ?PartService $_partService = null;
private ?ServerPartService $_serverPartService = null;
private ?CpuService $_cpuService = null;
private ?RamService $_ramService = null;
private ?DiskService $_diskService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -41,31 +43,28 @@ class ServerController extends EquipmentController
}
return $this->_helper;
}
final public function getPartService(): PartService
final public function getCpuService(): CpuService
{
if (!$this->_partService) {
$this->_partService = new PartService($this->request);
if (!$this->_cpuService) {
$this->_cpuService = new CpuService($this->request);
}
return $this->_partService;
return $this->_cpuService;
}
final public function getServerPartService(): ServerPartService
final public function getRamService(): RamService
{
if (!$this->_serverPartService) {
$this->_serverPartService = new ServerPartService($this->request);
if (!$this->_ramService) {
$this->_ramService = new RamService($this->request);
}
return $this->_serverPartService;
return $this->_ramService;
}
final public function getDiskService(): DiskService
{
if (!$this->_diskService) {
$this->_diskService = new DiskService($this->request);
}
return $this->_diskService;
}
//Index,FieldForm관련
private function setPartEntity(ServerEntity $entity): ServerEntity
{
foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) {
$partEntity = $this->getPartService()->getEntity($serverPartEntity->getPartInfoUID());
if ($partEntity) {
$entity->addPartEntity($partEntity->getType(), $partEntity);
}
}
return $entity;
}
protected function index_process(): array
{
$fields = [
@ -75,7 +74,10 @@ class ServerController extends EquipmentController
$this->modal_type = 'modal_iframe';
$entities = [];
foreach (parent::index_process() as $entity) {
$entities[] = $this->setPartEntity($entity);
$entity->setPartEntities("CPU", $this->getCpuService()->getPartEntities($entity));
$entity->setPartEntities("RAM", $this->getRamService()->getPartEntities($entity));
$entity->setPartEntities("DISK", $this->getDiskService()->getPartEntities($entity));
$entities[] = $entity;
}
return $entities;
}

View File

@ -4,9 +4,9 @@
"settings": {
"width": 4000,
"height": 4000,
"scrollTop": -2704.6009,
"scrollLeft": -1890.4788,
"zoomLevel": 0.79,
"scrollTop": -2409.9338,
"scrollLeft": -1962.0885,
"zoomLevel": 0.94,
"show": 511,
"database": 4,
"databaseName": "",
@ -98,7 +98,7 @@
"tableEntities": {
"Jq5Qkun2FzQhCGKANIVOZ": {
"id": "Jq5Qkun2FzQhCGKANIVOZ",
"name": "userinfo",
"name": "user",
"comment": "관리자정보",
"columnIds": [
"mfHtgzc_Aeocr6xkgwYWh",
@ -133,7 +133,7 @@
"color": ""
},
"meta": {
"updateAt": 1747808064456,
"updateAt": 1747816360177,
"createAt": 1745819764136
}
},
@ -769,6 +769,7 @@
"columnIds": [
"Jh6e_-9QYe1Tqve0PE3kT",
"DC7TvFFpBT7vY0UKKHt-W",
"qcYZvSlfu93cigmIRzU_C",
"3nwgqrQd_qDGdg6Fe3kEp",
"mwVYv9PaJFpoxYvTRJ223"
],
@ -784,6 +785,7 @@
"dr0UoY8ebsS-TjcPyP4is",
"GnoGvT4HaG9kp-BvwZ4FQ",
"wx8zTFviA4I8YQnn-MFpW",
"qcYZvSlfu93cigmIRzU_C",
"3nwgqrQd_qDGdg6Fe3kEp",
"mwVYv9PaJFpoxYvTRJ223"
],
@ -796,7 +798,7 @@
"color": ""
},
"meta": {
"updateAt": 1747809657264,
"updateAt": 1747816625765,
"createAt": 1746783410914
}
},
@ -889,6 +891,7 @@
"zBz4vBOZSIA8vKmfqXckO",
"YqInlreLnga0pOXtaP8GF",
"ixoWg1kPLrUYL069d75Kq",
"BvHyGw9Xf_gz7bEkZhLbk",
"0STHSEXiceoCa6a7jGXV5",
"j2hkudsfMKexNL6P7SM8R",
"mDU5e29uBK_pIGHPmO6Nv",
@ -900,6 +903,7 @@
"YqInlreLnga0pOXtaP8GF",
"VYbvSvXIEQPQtx6GL-tdv",
"ixoWg1kPLrUYL069d75Kq",
"BvHyGw9Xf_gz7bEkZhLbk",
"0STHSEXiceoCa6a7jGXV5",
"j2hkudsfMKexNL6P7SM8R",
"lf3Q5NccF2HWpq4GlYVta",
@ -908,15 +912,15 @@
"pzEFysMFfI2J8uB8YHXxA"
],
"ui": {
"x": 2210.4386,
"y": 2830.124,
"x": 2204.1096,
"y": 2852.9084,
"zIndex": 796,
"widthName": 64,
"widthComment": 60,
"color": ""
},
"meta": {
"updateAt": 1747809667091,
"updateAt": 1747817209215,
"createAt": 1747374666215
}
},
@ -1024,26 +1028,28 @@
"columnIds": [
"203b3hUKUQ_Gu5wKShBgZ",
"kohhWoNuei3x97SzgQUF4",
"SzD5tmOIoZodU1wBH56I4",
"EEerVyCwkEAuiRc-gon8s",
"uki_QcviBOFJ57v1IbbPX"
],
"seqColumnIds": [
"203b3hUKUQ_Gu5wKShBgZ",
"kohhWoNuei3x97SzgQUF4",
"SzD5tmOIoZodU1wBH56I4",
"EEerVyCwkEAuiRc-gon8s",
"uki_QcviBOFJ57v1IbbPX",
"5EZEDNUFxzmElbK6goZPK"
],
"ui": {
"x": 2199.8478,
"y": 2473.3563,
"y": 2482.2169,
"zIndex": 1036,
"widthName": 60,
"widthComment": 60,
"color": ""
},
"meta": {
"updateAt": 1747809661233,
"updateAt": 1747816633128,
"createAt": 1747808112554
}
},
@ -1164,25 +1170,27 @@
"columnIds": [
"WaCB3uNZYFReAPiBqQ97v",
"tn-GhYT445kEh1tzf8Lf1",
"FOr_RCEoaL3a0M7smSYRC",
"cMe_lKgwfS-LNTHhHIYrk",
"ixmBlLhmVt4et6tZEwLPC"
],
"seqColumnIds": [
"WaCB3uNZYFReAPiBqQ97v",
"tn-GhYT445kEh1tzf8Lf1",
"FOr_RCEoaL3a0M7smSYRC",
"cMe_lKgwfS-LNTHhHIYrk",
"ixmBlLhmVt4et6tZEwLPC"
],
"ui": {
"x": 2198.6283,
"y": 2646.5269,
"x": 2199.8941,
"y": 2665.5139,
"zIndex": 1118,
"widthName": 60,
"widthComment": 60,
"color": ""
},
"meta": {
"updateAt": 1747809663796,
"updateAt": 1747816638083,
"createAt": 1747808548333
}
},
@ -3490,20 +3498,20 @@
"DGl10GI58QwOHwpTu4Z1Y": {
"id": "DGl10GI58QwOHwpTu4Z1Y",
"tableId": "gsa0XtQZQgrJ8ZXy8VQVg",
"name": "userinfo_uid",
"name": "user_uid",
"comment": "",
"dataType": "INT",
"default": "",
"options": 8,
"ui": {
"keys": 2,
"widthName": 67,
"widthName": 60,
"widthComment": 60,
"widthDataType": 60,
"widthDefault": 60
},
"meta": {
"updateAt": 1745819764142,
"updateAt": 1747816382451,
"createAt": 1745819764142
}
},
@ -5983,7 +5991,7 @@
"widthDefault": 60
},
"meta": {
"updateAt": 1747374993341,
"updateAt": 1747817155134,
"createAt": 1747374853724
}
},
@ -7706,6 +7714,86 @@
"updateAt": 1747810040937,
"createAt": 1747810029959
}
},
"qcYZvSlfu93cigmIRzU_C": {
"id": "qcYZvSlfu93cigmIRzU_C",
"tableId": "RMhrLs7bOaopKmKt9YKHQ",
"name": "status",
"comment": "",
"dataType": "VARCHAR(20)",
"default": "'use'",
"options": 8,
"ui": {
"keys": 0,
"widthName": 60,
"widthComment": 60,
"widthDataType": 75,
"widthDefault": 60
},
"meta": {
"updateAt": 1747816623992,
"createAt": 1747816623991
}
},
"SzD5tmOIoZodU1wBH56I4": {
"id": "SzD5tmOIoZodU1wBH56I4",
"tableId": "lwd2DR7f1FW8fXtJ0lX-r",
"name": "status",
"comment": "",
"dataType": "VARCHAR(20)",
"default": "'use'",
"options": 8,
"ui": {
"keys": 0,
"widthName": 60,
"widthComment": 60,
"widthDataType": 75,
"widthDefault": 60
},
"meta": {
"updateAt": 1747816631728,
"createAt": 1747816631727
}
},
"FOr_RCEoaL3a0M7smSYRC": {
"id": "FOr_RCEoaL3a0M7smSYRC",
"tableId": "dnFyz1CSdGeS6mCbfCMO0",
"name": "status",
"comment": "",
"dataType": "VARCHAR(20)",
"default": "'use'",
"options": 8,
"ui": {
"keys": 0,
"widthName": 60,
"widthComment": 60,
"widthDataType": 75,
"widthDefault": 60
},
"meta": {
"updateAt": 1747816636766,
"createAt": 1747816636766
}
},
"BvHyGw9Xf_gz7bEkZhLbk": {
"id": "BvHyGw9Xf_gz7bEkZhLbk",
"tableId": "RTq5rHQupiXXJPXqpN8K5",
"name": "accountid",
"comment": "",
"dataType": "VARCHAR(50)",
"default": "",
"options": 0,
"ui": {
"keys": 0,
"widthName": 60,
"widthComment": 60,
"widthDataType": 75,
"widthDefault": 60
},
"meta": {
"updateAt": 1747817197659,
"createAt": 1747817172798
}
}
},
"relationshipEntities": {
@ -8054,7 +8142,7 @@
"Jh6e_-9QYe1Tqve0PE3kT"
],
"x": 2196.9786,
"y": 2370.1577,
"y": 2382.1577,
"direction": 1
},
"end": {
@ -8109,8 +8197,8 @@
"columnIds": [
"zBz4vBOZSIA8vKmfqXckO"
],
"x": 2210.4386,
"y": 2954.124,
"x": 2204.1096,
"y": 2988.9084,
"direction": 1
},
"end": {
@ -8390,7 +8478,7 @@
"Jh6e_-9QYe1Tqve0PE3kT"
],
"x": 2693.9786,
"y": 2370.1577,
"y": 2382.1577,
"direction": 2
},
"end": {
@ -8558,7 +8646,7 @@
"203b3hUKUQ_Gu5wKShBgZ"
],
"x": 2199.8478,
"y": 2549.3563,
"y": 2570.2169,
"direction": 1
},
"end": {
@ -8586,7 +8674,7 @@
"203b3hUKUQ_Gu5wKShBgZ"
],
"x": 2696.8478,
"y": 2549.3563,
"y": 2570.2169,
"direction": 2
},
"end": {
@ -8641,8 +8729,8 @@
"columnIds": [
"WaCB3uNZYFReAPiBqQ97v"
],
"x": 2695.6283,
"y": 2722.5269,
"x": 2696.8941,
"y": 2753.5139,
"direction": 2
},
"end": {
@ -8697,8 +8785,8 @@
"columnIds": [
"WaCB3uNZYFReAPiBqQ97v"
],
"x": 2198.6283,
"y": 2722.5269,
"x": 2199.8941,
"y": 2753.5139,
"direction": 1
},
"end": {

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment\Link;
use App\Models\Equipment\Link\CpuModel;
class CpuEntity extends LinkEntity
{
const PK = CpuModel::PK;
const TITLE = CpuModel::TITLE;
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment\Link;
use App\Models\Equipment\Link\DiskModel;
class DiskEntity extends LinkEntity
{
const PK = DiskModel::PK;
const TITLE = DiskModel::TITLE;
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Entities\Equipment\Link;
use App\Entities\Equipment\EquipmentEntity;
abstract class LinkEntity extends EquipmentEntity
{
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
public function getServerInfoUID(): string
{
return $this->attributes['serverinfo_uid'];
}
public function getPartInfoUID(): string
{
return $this->attributes['cpuinfo_uid'];
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment\Link;
use App\Models\Equipment\Link\RamModel;
class RamEntity extends LinkEntity
{
const PK = RamModel::PK;
const TITLE = RamModel::TITLE;
}

View File

@ -17,12 +17,12 @@ class ServerEntity extends EquipmentEntity
return $this->attributes[$type] ?? [];
}
public function addPartEntity(string $type, PartEntity $partEntity): void
public function setPartEntities(string $type, array $partEntities): void
{
if (!isset($this->attributes[$type])) {
$this->attributes[$type] = [];
}
$this->attributes[$type][] = $partEntity;
$this->attributes[$type] = $partEntities;
// $this->attributes[$type] = array_unique($this->attributes[$type], SORT_REGULAR);
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Models\Equipment\Link;
class CpuModel extends LinkModel
{
const TABLE = "serverinfos_cpuinfos";
const PK = "uid";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
public function __construct()
{
parent::__construct();
}
}

View File

@ -0,0 +1,17 @@
<?php
namespace App\Models\Equipment\Link;
class DiskModel extends LinkModel
{
const TABLE = "serverinfos_diskinfos";
const PK = "uid";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
public function __construct()
{
parent::__construct();
}
}

View File

@ -1,23 +1,17 @@
<?php
namespace App\Models\Equipment;
namespace App\Models\Equipment\Link;
use App\Entities\Equipment\ServerPartEntity;
use App\Models\Equipment\EquipmentModel;
class ServerPartModel extends EquipmentModel
abstract class LinkModel extends EquipmentModel
{
const TABLE = "serverinfos_partinfos";
const PK = "uid";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServerPartEntity::class;
// protected $returnType = CpuEntity::class;
protected $allowedFields = [
"type",
"serverinfo_uid",
"partinfo_uid",
"cpuinfo_uid",
];
public function __construct()
protected function __construct()
{
parent::__construct();
}
@ -28,10 +22,7 @@ class ServerPartModel extends EquipmentModel
}
switch ($field) {
case "serverinfo_uid":
case "partinfo_uid":
$rule = "required|numeric";
break;
case "type":
case "cpuinfo_uid":
$rule = "required|trim|string";
break;
default:

View File

@ -0,0 +1,17 @@
<?php
namespace App\Models\Equipment\Link;
class RamModel extends LinkModel
{
const TABLE = "serverinfos_raminfos";
const PK = "uid";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
public function __construct()
{
parent::__construct();
}
}

View File

@ -6,7 +6,7 @@ use App\Entities\Equipment\Part\DiskEntity;
class DiskModel extends PartModel
{
const TABLE = "cpuinfo";
const TABLE = "raminfo";
const PK = "uid";
const TITLE = "model";
protected $table = self::TABLE;

View File

@ -6,7 +6,7 @@ use App\Entities\Equipment\Part\RamEntity;
class RamModel extends PartModel
{
const TABLE = "cpuinfo";
const TABLE = "diskinfo";
const PK = "uid";
const TITLE = "model";
protected $table = self::TABLE;

View File

@ -0,0 +1,28 @@
<?php
namespace App\Services\Equipment\Link;
use App\Entities\Equipment\Link\CpuEntity;
use App\Models\Equipment\Link\CpuModel;
use CodeIgniter\HTTP\IncomingRequest;
class CpuService extends LinkService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Cpu";
}
public function getModelClass(): CpuModel
{
return new CpuModel();
}
public function getEntityClass(): CpuEntity
{
return new CpuEntity();
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Services\Equipment\Link;
use App\Entities\Equipment\Link\DiskEntity;
use App\Models\Equipment\Link\DiskModel;
use CodeIgniter\HTTP\IncomingRequest;
class DiskService extends LinkService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Disk";
}
public function getModelClass(): DiskModel
{
return new DiskModel();
}
public function getEntityClass(): DiskEntity
{
return new DiskEntity();
}
}

View File

@ -0,0 +1,36 @@
<?php
namespace App\Services\Equipment\Link;
use App\Entities\Equipment\ServerEntity;
use App\Services\Equipment\EquipmentService;
use CodeIgniter\HTTP\IncomingRequest;
abstract class LinkService extends EquipmentService
{
protected function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Link";
}
public function getFields(): array
{
return [
"serverinfo_uid",
"cpuinfo_uid",
];
}
public function getFilterFields(): array
{
return [];
}
public function getBatchJobFields(): array
{
return [];
}
}

View File

@ -0,0 +1,28 @@
<?php
namespace App\Services\Equipment\Link;
use App\Entities\Equipment\Link\RamEntity;
use App\Models\Equipment\Link\RamModel;
use CodeIgniter\HTTP\IncomingRequest;
class RamService extends LinkService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Ram";
}
public function getModelClass(): RamModel
{
return new RamModel();
}
public function getEntityClass(): RamEntity
{
return new RamEntity();
}
}

View File

@ -5,6 +5,7 @@ namespace App\Services\Equipment\Part;
use App\Entities\Equipment\Part\CpuEntity;
use App\Models\Equipment\Part\CpuModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\Link\CpuService as LinkService;
class CpuService extends PartService
{
@ -25,4 +26,8 @@ class CpuService extends PartService
{
return new CpuEntity();
}
protected function getLinkService(): LinkService
{
return new LinkService($this->request);
}
}

View File

@ -5,6 +5,7 @@ namespace App\Services\Equipment\Part;
use App\Entities\Equipment\Part\DiskEntity;
use App\Models\Equipment\Part\DiskModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\Link\DiskService as LinkService;
class DiskService extends PartService
{
@ -25,4 +26,8 @@ class DiskService extends PartService
{
return new DiskEntity();
}
protected function getLinkService(): LinkService
{
return new LinkService($this->request);
}
}

View File

@ -3,6 +3,7 @@
namespace App\Services\Equipment\Part;
use App\Entities\Equipment\ServerEntity;
use App\Services\Equipment\EquipmentService;
use CodeIgniter\HTTP\IncomingRequest;
@ -12,6 +13,8 @@ abstract class PartService extends EquipmentService
{
parent::__construct($request);
}
abstract protected function getLinkService(): mixed;
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "Part";
@ -32,4 +35,13 @@ abstract class PartService extends EquipmentService
{
return ['status'];
}
final public function getPartEntities(ServerEntity $entity): array
{
$entities = [];
foreach ($this->getLinkService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $linkEntity) {
$entities[] = $this->getEntity($linkEntity->getPartInfoUID());
}
return $entities;
}
}

View File

@ -5,6 +5,7 @@ namespace App\Services\Equipment\Part;
use App\Entities\Equipment\Part\RamEntity;
use App\Models\Equipment\Part\RamModel;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\Link\RamService as LinkService;
class RamService extends PartService
{
@ -25,4 +26,8 @@ class RamService extends PartService
{
return new RamEntity();
}
protected function getLinkService(): LinkService
{
return new LinkService($this->request);
}
}

View File

@ -1,46 +0,0 @@
<?php
namespace App\Services\Equipment;
use CodeIgniter\HTTP\IncomingRequest;
use App\Services\Equipment\EquipmentService;
use App\Entities\Equipment\ServerPartEntity;
use App\Models\Equipment\ServerPartModel;
class ServerPartService extends EquipmentService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "ServerPart";
}
public function getModelClass(): ServerPartModel
{
return new ServerPartModel();
}
public function getEntityClass(): ServerPartEntity
{
return new ServerPartEntity();
}
public function getFields(): array
{
return [
"type",
"serverinfo_uid",
"partinfo_uid",
];
}
public function getFilterFields(): array
{
return ["serverinfo_uid", "type", "partinfo_uid"];
}
public function getBatchJobFields(): array
{
return ["type", "partinfo_uid"];
}
}