From a68c539ec0d39995ee1fed372b6a22ee89691d18 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Mon, 29 Sep 2025 18:34:50 +0900 Subject: [PATCH] dbmsv2_init...1 --- app/Services/Equipment/ServerPartService.php | 23 ++++++++++++++++++-- app/Services/Equipment/ServerService.php | 9 ++++---- app/Services/Part/CPUService.php | 6 +++-- app/Services/Part/CSService.php | 4 ++-- app/Services/Part/DISKService.php | 6 +++-- app/Services/Part/IPService.php | 4 ++-- app/Services/Part/OSService.php | 6 +++-- app/Services/Part/RAMService.php | 6 +++-- app/Services/Part/SOFTWAREService.php | 6 +++-- app/Services/Part/SWITCHService.php | 4 ++-- 10 files changed, 52 insertions(+), 22 deletions(-) diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index dcf2d27..79a0c1a 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -6,6 +6,7 @@ use App\Entities\Equipment\ServerEntity; use App\Entities\Equipment\ServerPartEntity; use App\Entities\PaymentEntity; use App\Helpers\Equipment\ServerPartHelper; +use App\Interfaces\Customer\ServiceInterface; use App\Interfaces\Equipment\ServerInterface; use App\Models\Equipment\ServerPartModel; use App\Services\Customer\ServiceService; @@ -365,9 +366,27 @@ class ServerPartService extends EquipmentService implements ServerInterface } public function unsetServer(ServerEntity $serverEntity, array $serverDatas): ServerEntity { - //기존 ServerPart정보 삭제 + + //기존 ServerPart정보 삭제(서버파트정보 (월비용,일회성) 상품 회수처리) foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) { - $this->getModel()->delete($serverPartEntity); + switch ($serverPartEntity->getType()) { + case 'CPU': + case 'RAM': + case 'DISK': + //기본이 아닌 결제방식의 경우 모두 회수처리 + if ($serverPartEntity->getBilling() !== PAYMENT['BILLING']['BASE']) { + //Type에 따른 부품서비스 정의 + $this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []); + //서버연결정보 식제 + parent::delete($serverPartEntity); + } + break; + default: //IP,SWITCH,CS,SOFTWARE,OS등은 모두 회수처리 + $this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []); + //서버연결정보 식제 + parent::delete($serverPartEntity); + break; + } } return $serverEntity; } diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 964f13e..9cbbbd3 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -183,7 +183,7 @@ class ServerService extends EquipmentService implements ServiceInterface public function delete(mixed $entity): ServerEntity { //선처리작업 - $entity = $this->action_process($entity, __FUNCTION__ . 'Server'); + $entity = $this->getServerPartService()->unsetServer($entity, []);; return parent::delete($entity); } //List 검색용 @@ -217,7 +217,7 @@ class ServerService extends EquipmentService implements ServiceInterface $formDatas['type'] = $serviceDatas['type']; } //필수정보처리 후 서버정보등록 후 서비스정보 Entity에 서버정보 설정 - return $serviceEntity->setServerEntity($this->getModel()->modify($entity, $formDatas)); + return $serviceEntity->setServerEntity(parent::modify($entity, $formDatas)); } public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity { @@ -247,8 +247,9 @@ class ServerService extends EquipmentService implements ServiceInterface $formDatas['serviceinfo_uid'] = null; $formDatas['format_at'] = date("Y-m-d"); $formDatas['status'] = STATUS['AVAILABLE']; - $entity = $this->getModel()->modify($entity, $formDatas); - //서비스정보 Entity에 서버정보 설정 + $entity = parent::modify($entity, $formDatas); + //서버파트정보 회수처리 호출 + $this->getServerPartService()->unsetServer($entity, []); return $serviceEntity; } //서버파트관련 작업 diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php index b2d621b..b5fd0b8 100644 --- a/app/Services/Part/CPUService.php +++ b/app/Services/Part/CPUService.php @@ -65,7 +65,8 @@ class CPUService extends PartService implements ServerPartInterface if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -85,6 +86,7 @@ class CPUService extends PartService implements ServerPartInterface if (!$entity instanceof CPUEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } } diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php index f5385cc..eefdd5d 100644 --- a/app/Services/Part/CSService.php +++ b/app/Services/Part/CSService.php @@ -122,7 +122,7 @@ class CSService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다."); } //CS정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -150,6 +150,6 @@ class CSService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다."); } //CS정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } } diff --git a/app/Services/Part/DISKService.php b/app/Services/Part/DISKService.php index 84b922b..0005ffb 100644 --- a/app/Services/Part/DISKService.php +++ b/app/Services/Part/DISKService.php @@ -65,7 +65,8 @@ class DISKService extends PartService implements ServerPartInterface if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -85,6 +86,7 @@ class DISKService extends PartService implements ServerPartInterface if (!$entity instanceof DISKEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } } diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php index df32d72..582a6d3 100644 --- a/app/Services/Part/IPService.php +++ b/app/Services/Part/IPService.php @@ -137,7 +137,7 @@ class IPService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다."); } // IP정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -168,6 +168,6 @@ class IPService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다."); } // IP정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } } diff --git a/app/Services/Part/OSService.php b/app/Services/Part/OSService.php index 814472e..3ff875f 100644 --- a/app/Services/Part/OSService.php +++ b/app/Services/Part/OSService.php @@ -65,7 +65,8 @@ class OSService extends PartService implements ServerPartInterface if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -85,6 +86,7 @@ class OSService extends PartService implements ServerPartInterface if (!$entity instanceof OSEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } } diff --git a/app/Services/Part/RAMService.php b/app/Services/Part/RAMService.php index f4b6065..ac9a8d7 100644 --- a/app/Services/Part/RAMService.php +++ b/app/Services/Part/RAMService.php @@ -65,7 +65,8 @@ class RAMService extends PartService implements ServerPartInterface if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -85,6 +86,7 @@ class RAMService extends PartService implements ServerPartInterface if (!$entity instanceof RAMEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + return $serverPartEntity; } } diff --git a/app/Services/Part/SOFTWAREService.php b/app/Services/Part/SOFTWAREService.php index 125af9b..18cd092 100644 --- a/app/Services/Part/SOFTWAREService.php +++ b/app/Services/Part/SOFTWAREService.php @@ -65,7 +65,8 @@ class SOFTWAREService extends PartService implements ServerPartInterface if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -85,6 +86,7 @@ class SOFTWAREService extends PartService implements ServerPartInterface if (!$entity instanceof SOFTWAREEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); + return $serverPartEntity->setPartEntity($entity); } } diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php index 0ec976b..74f0fbc 100644 --- a/app/Services/Part/SWITCHService.php +++ b/app/Services/Part/SWITCHService.php @@ -107,7 +107,7 @@ class SWITCHService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다."); } //SWITCH정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity { @@ -136,6 +136,6 @@ class SWITCHService extends PartService implements ServerPartInterface throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다."); } //SWITCH정보 수정 - return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); + return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas)); } }