From 993d64627a2ff9fb5b36bf419f6f6102f3147f23 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Fri, 5 Sep 2025 17:33:23 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Database/dbmsv2_test1.sql | 11 +++--- app/Entities/Customer/CustomerEntity.php | 15 ++++++-- app/Entities/Customer/ServiceEntity.php | 8 ----- app/Entities/Equipment/EquipmentEntity.php | 16 +++++++++ app/Entities/Equipment/ServerEntity.php | 8 ----- app/Entities/Equipment/ServerPartEntity.php | 8 ----- app/Helpers/Customer/ServiceHelper.php | 6 ++-- app/Helpers/Equipment/ServerHelper.php | 6 ++-- app/Helpers/Equipment/ServerPartHelper.php | 10 +++--- app/Services/Customer/ServiceService.php | 37 ++++---------------- app/Services/Equipment/ServerPartService.php | 16 ++++++++- app/Services/Equipment/ServerService.php | 9 +++-- 12 files changed, 71 insertions(+), 79 deletions(-) diff --git a/app/Database/dbmsv2_test1.sql b/app/Database/dbmsv2_test1.sql index 2a37be8..41be450 100644 --- a/app/Database/dbmsv2_test1.sql +++ b/app/Database/dbmsv2_test1.sql @@ -385,7 +385,7 @@ CREATE TABLE `serverinfo` ( KEY `FK_clientinfo_TO_serverinfo` (`clientinfo_uid`), CONSTRAINT `FK_clientinfo_TO_serverinfo` FOREIGN KEY (`clientinfo_uid`) REFERENCES `clientinfo` (`uid`), CONSTRAINT `FK_serviceinfo_TO_serverinfo` FOREIGN KEY (`serviceinfo_uid`) REFERENCES `serviceinfo` (`uid`) -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COMMENT='서버정보'; +) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='서버정보'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -394,7 +394,7 @@ CREATE TABLE `serverinfo` ( LOCK TABLES `serverinfo` WRITE; /*!40000 ALTER TABLE `serverinfo` DISABLE KEYS */; -INSERT INTO `serverinfo` VALUES (3,564,2,'250904-M1','hp','HP DL360 Gen6',400000,300000,'2025-08-31 15:00:00','2025-09-29 15:00:00','occupied','2025-09-05 01:27:05','2025-09-04 08:09:50',NULL),(4,NULL,NULL,'250905-M4','hp','Hitach HA3000',400000,200000,'2025-09-02 15:00:00','2025-09-28 15:00:00','available',NULL,'2025-09-05 00:04:09',NULL),(5,NULL,NULL,'250905-M5','del','HP DL360 Gen9',100000,100000,'2025-09-03 15:00:00','2025-09-26 15:00:00','available',NULL,'2025-09-05 00:05:26',NULL); +INSERT INTO `serverinfo` VALUES (3,564,2,'250904-M1','hp','HP DL360 Gen6',400000,300000,'2025-08-31 15:00:00','2025-09-29 15:00:00','occupied','2025-09-05 01:27:05','2025-09-04 08:09:50',NULL),(4,NULL,NULL,'250905-M4','hp','Hitach HA3000',400000,200000,'2025-09-02 15:00:00','2025-09-28 15:00:00','available',NULL,'2025-09-05 00:04:09',NULL),(5,NULL,NULL,'250905-M5','del','HP DL360 Gen9',100000,100000,'2025-09-03 15:00:00','2025-09-26 15:00:00','available',NULL,'2025-09-05 00:05:26',NULL),(6,NULL,NULL,'250905-M6','etc','HP DL360 Gen10',400000,300000,'2025-09-03 15:00:00','2025-09-27 15:00:00','available',NULL,'2025-09-05 07:36:21',NULL); /*!40000 ALTER TABLE `serverinfo` ENABLE KEYS */; UNLOCK TABLES; @@ -407,6 +407,7 @@ DROP TABLE IF EXISTS `serverpartinfo`; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `serverpartinfo` ( `uid` int(11) NOT NULL AUTO_INCREMENT, + `clientinfo_uid` int(11) DEFAULT NULL COMMENT '고객정보', `part_uid` int(11) NOT NULL COMMENT 'PART_UID', `serverinfo_uid` int(11) NOT NULL COMMENT '서버정보', `serviceinfo_uid` int(11) DEFAULT NULL COMMENT '서비스정보', @@ -422,7 +423,7 @@ CREATE TABLE `serverpartinfo` ( KEY `FK_serviceinfo_TO_serverpartinfo` (`serviceinfo_uid`), CONSTRAINT `FK_serverinfo_TO_serverpartinfo` FOREIGN KEY (`serverinfo_uid`) REFERENCES `serverinfo` (`uid`), CONSTRAINT `FK_serviceinfo_TO_serverpartinfo` FOREIGN KEY (`serviceinfo_uid`) REFERENCES `serviceinfo` (`uid`) -) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='서버파트정보'; +) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8 COMMENT='서버파트정보'; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -431,7 +432,7 @@ CREATE TABLE `serverpartinfo` ( LOCK TABLES `serverpartinfo` WRITE; /*!40000 ALTER TABLE `serverpartinfo` DISABLE KEYS */; -INSERT INTO `serverpartinfo` VALUES (1,1,3,2,'CPU','',0,2,NULL,'2025-09-05 01:27:05','2025-09-04 08:09:50'),(2,7,3,2,'RAM','',0,2,NULL,'2025-09-05 01:27:05','2025-09-04 08:09:50'),(3,14,3,2,'DISK','',0,2,'RAID1','2025-09-05 01:27:05','2025-09-04 08:09:50'),(4,6,4,NULL,'CPU','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(5,10,4,NULL,'RAM','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(6,22,4,NULL,'DISK','',0,2,NULL,NULL,'2025-09-05 00:04:09'),(7,3,5,NULL,'CPU','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(8,9,5,NULL,'RAM','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(9,14,5,NULL,'DISK','',0,3,'RAID5',NULL,'2025-09-05 00:05:26'); +INSERT INTO `serverpartinfo` VALUES (1,NULL,1,3,2,'CPU','',0,2,NULL,'2025-09-05 01:27:05','2025-09-04 08:09:50'),(2,NULL,7,3,2,'RAM','',0,2,NULL,'2025-09-05 01:27:05','2025-09-04 08:09:50'),(3,NULL,14,3,2,'DISK','',0,2,'RAID1','2025-09-05 01:27:05','2025-09-04 08:09:50'),(4,NULL,6,4,NULL,'CPU','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(5,NULL,10,4,NULL,'RAM','',0,4,NULL,NULL,'2025-09-05 00:04:09'),(6,NULL,22,4,NULL,'DISK','',0,2,NULL,NULL,'2025-09-05 00:04:09'),(7,NULL,3,5,NULL,'CPU','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(8,NULL,9,5,NULL,'RAM','',0,3,NULL,NULL,'2025-09-05 00:05:26'),(9,NULL,14,5,NULL,'DISK','',0,3,'RAID5',NULL,'2025-09-05 00:05:26'),(10,NULL,29,3,NULL,'OS','onetime',0,1,NULL,NULL,'2025-09-05 03:38:30'),(11,NULL,8,3,NULL,'RAM','onetime',100000,1,'','2025-09-05 03:39:36','2025-09-05 03:39:09'),(13,NULL,5,6,NULL,'CPU','',0,10,NULL,'2025-09-05 07:37:42','2025-09-05 07:36:21'),(14,NULL,9,6,NULL,'RAM','',0,10,NULL,NULL,'2025-09-05 07:36:21'),(15,NULL,26,6,NULL,'DISK','',0,10,'RAID10',NULL,'2025-09-05 07:36:21'),(16,NULL,10,6,NULL,'RAM','onetime',100000,2,NULL,NULL,'2025-09-05 07:38:22'),(17,NULL,14,6,NULL,'DISK','month',10000,2,'RAID1',NULL,'2025-09-05 07:39:26'); /*!40000 ALTER TABLE `serverpartinfo` ENABLE KEYS */; UNLOCK TABLES; @@ -591,4 +592,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2025-09-05 12:38:01 +-- Dump completed on 2025-09-05 16:39:52 diff --git a/app/Entities/Customer/CustomerEntity.php b/app/Entities/Customer/CustomerEntity.php index c13dd8b..5ecffde 100644 --- a/app/Entities/Customer/CustomerEntity.php +++ b/app/Entities/Customer/CustomerEntity.php @@ -10,9 +10,20 @@ abstract class CustomerEntity extends CommonEntity { parent::__construct($data); } - //고객정보객체 - final public function getClientUID(): int|null + final public function getUserUID(): int|null + { + return $this->attributes['user_uid']; + } + final public function getClientInfoUID(): int|null { return $this->attributes['clientinfo_uid'] ?? null; } + final public function getServiceInfoUID(): int|null + { + return $this->attributes['serviceinfo_uid'] ?? null; + } + final public function getServerInfoUID(): int|null + { + return $this->attributes['serverinfo_uid'] ?? null; + } } diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php index 346a480..3a48110 100644 --- a/app/Entities/Customer/ServiceEntity.php +++ b/app/Entities/Customer/ServiceEntity.php @@ -26,14 +26,6 @@ class ServiceEntity extends CustomerEntity { return $this->attributes['code']; } - final public function getUserUID(): int|null - { - return $this->attributes['user_uid']; - } - final public function getClientInfoUID(): int|null - { - return $this->attributes['clientinfo_uid']; - } public function getType(): string { return $this->attributes['type']; diff --git a/app/Entities/Equipment/EquipmentEntity.php b/app/Entities/Equipment/EquipmentEntity.php index 29dc7ad..0622695 100644 --- a/app/Entities/Equipment/EquipmentEntity.php +++ b/app/Entities/Equipment/EquipmentEntity.php @@ -10,4 +10,20 @@ abstract class EquipmentEntity extends CommonEntity { parent::__construct($data); } + final public function getUserUID(): int|null + { + return $this->attributes['user_uid']; + } + final public function getClientInfoUID(): int|null + { + return $this->attributes['clientinfo_uid'] ?? null; + } + final public function getServiceInfoUID(): int|null + { + return $this->attributes['serviceinfo_uid'] ?? null; + } + final public function getServerInfoUID(): int|null + { + return $this->attributes['serverinfo_uid'] ?? null; + } } diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index 71a43cc..6142889 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -46,12 +46,4 @@ class ServerEntity extends EquipmentEntity { return sprintf("%s[%s]", parent::getTitle(), $this->getCode()); } - public function getClientInfoUID(): int|null - { - return $this->attributes['clientinfo_uid'] ?? null; - } - public function getServiceInfoUID(): int|null - { - return $this->attributes['serviceinfo_uid'] ?? null; - } } diff --git a/app/Entities/Equipment/ServerPartEntity.php b/app/Entities/Equipment/ServerPartEntity.php index 020dc14..35a9c8f 100644 --- a/app/Entities/Equipment/ServerPartEntity.php +++ b/app/Entities/Equipment/ServerPartEntity.php @@ -35,14 +35,6 @@ class ServerPartEntity extends EquipmentEntity { return $this->attributes['part_uid']; } - public function getServerInfoUID(): int - { - return $this->attributes['serverinfo_uid']; - } - public function getServiceInfoUID(): int|null - { - return $this->attributes['serviceinfo_uid']; - } public function getType(): string { return $this->attributes['type']; diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index 8cb2727..17a951b 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -44,15 +44,15 @@ class ServiceHelper extends CustomerHelper } } break; - case 'SWITCH': - case 'IP': - case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': + case 'SWITCH': + case 'IP': + case 'CS': $viewDatas['serverEntity'] = $viewDatas['entity']->getServerEntity(); $value = $this->getServerHelper()->getFieldView($field, $value, $viewDatas, $extras); break; diff --git a/app/Helpers/Equipment/ServerHelper.php b/app/Helpers/Equipment/ServerHelper.php index f192d54..d48977e 100644 --- a/app/Helpers/Equipment/ServerHelper.php +++ b/app/Helpers/Equipment/ServerHelper.php @@ -51,15 +51,15 @@ class ServerHelper extends EquipmentHelper case 'format_at': $value = $value ? date("Y-m-d", strtotime($value)) : ""; break; - case 'SWITCH': - case 'IP': - case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': + case 'SWITCH': + case 'IP': + case 'CS': $serverEntity = array_key_exists('serverEntity', $viewDatas) ? $viewDatas['serverEntity'] : $viewDatas['entity']; $viewDatas['serverPartEntities'] = $serverEntity->getServerPartEntities($field); $value = $this->getServerPartHelper()->getFieldView($field, $value, $viewDatas, $extras); diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php index 331391d..de4c05f 100644 --- a/app/Helpers/Equipment/ServerPartHelper.php +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -72,15 +72,15 @@ class ServerPartHelper extends EquipmentHelper public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null { switch ($field) { - case 'SWITCH': - case 'IP': - case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': + case 'SWITCH': + case 'IP': + case 'CS': $temps = []; foreach ($viewDatas['serverPartEntities'] as $partEntity) { $modal = form_label( @@ -95,10 +95,10 @@ class ServerPartHelper extends EquipmentHelper ] ); $temps[] = sprintf( - "%s%s%s %s", + "%s%s*%s개 %s", $modal, $partEntity->getTitle(), - $partEntity->getCnt() >= 1 ? "*" . $partEntity->getCnt() . "개" : "", + $partEntity->getCnt(), $partEntity->getExtra() ?? "" ); } diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index d6fe815..4d19289 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -4,17 +4,13 @@ namespace App\Services\Customer; use App\Entities\Customer\ServiceEntity; use App\Models\Customer\ServiceModel; -use App\Services\Equipment\CSService; -use App\Services\Equipment\IPService; -use App\Services\Equipment\ServerPartService; +use App\Services\Equipment\ServerService; use App\Traits\IPTrait; class ServiceService extends CustomerService { use IPTrait; - private ?ServerPartService $_serverPartService = null; - private ?IPService $_ipService = null; - private ?CSService $_csService = null; + private ?ServerService $_serverService = null; public function __construct() { parent::__construct(new ServiceModel()); @@ -102,41 +98,20 @@ class ServiceService extends CustomerService } return $entity; } - final public function getServerPartService(): ServerPartService - { - if (!$this->_serverPartService) { - $this->_serverPartService = new ServerPartService(); - } - return $this->_serverPartService; - } - final public function getIPService(): IPService - { - if (!$this->_ipService) { - $this->_ipService = new IPService(); - } - return $this->_ipService; - } - final public function getCSService(): CSService - { - if (!$this->_csService) { - $this->_csService = new CSService(); - } - return $this->_csService; - } //기본 기능부분 public function getFormOption(string $field, array $options = []): array { switch ($field) { - case 'SWITCH': - case 'IP': - case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': - $options = $this->getServerPartService()->getFormOption($field, $options); + case 'SWITCH': + case 'IP': + case 'CS': + $options = $this->getServerService()->getFormOption($field, $options); break; default: $options = parent::getFormOption($field, $options); diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index 7e7d600..ae82354 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -76,7 +76,21 @@ class ServerPartService extends EquipmentService //partEntity 정보 추가 protected function getEntity_process(mixed $entity): ServerPartEntity { - $partEntity = $this->getPartService()->getEntity($entity->getPartUID()); + switch ($entity->getType()) { + case 'SWITCH': + $partService = $this->getSwitchService(); + break; + case 'IP': + $partService = $this->getIPService(); + break; + case 'CS': + $partService = $this->getCSService(); + break; + default: + $partService = $this->getPartService(); + break; + } + $partEntity = $partService->getEntity($entity->getPartUID()); if ($entity) { $entity->setPartEntity($partEntity); } diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index dc9baa3..183a76e 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -2,7 +2,6 @@ namespace App\Services\Equipment; -use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\ServerEntity; use App\Models\Equipment\ServerModel; use App\Services\Equipment\EquipmentService; @@ -94,15 +93,15 @@ class ServerService extends EquipmentService public function getFormOption(string $field, array $options = []): array { switch ($field) { - case 'SWITCH': - case 'IP': - case 'CS': case 'CPU': case 'RAM': case 'DISK': case 'OS': case 'DB': case 'SOFTWARE': + case 'SWITCH': + case 'IP': + case 'CS': $options = $this->getServerPartService()->getFormOption($field, $options); break; default: @@ -193,7 +192,7 @@ class ServerService extends EquipmentService { //기존 ServerPart정보 삭제 foreach ($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()]) as $serverPartEntity) { - $this->getServerPartService()->deleteByServer($serverPartEntity); + $this->getServerPartService()->delete($serverPartEntity); } return parent::delete($entity); }