From cad35e3ee3a206f9204756a5dbf00bb1920619d6 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Tue, 28 Oct 2025 11:36:56 +0900 Subject: [PATCH] dbmsv3 init...1 --- app/Interfaces/Part/IPInterface.php | 5 +++-- app/Interfaces/Part/SWITCHInterface.php | 5 +++-- app/Services/Part/IPService.php | 17 +++++++++-------- app/Services/Part/SWITCHService.php | 23 ++++++++++++----------- 4 files changed, 27 insertions(+), 23 deletions(-) diff --git a/app/Interfaces/Part/IPInterface.php b/app/Interfaces/Part/IPInterface.php index 7fac6d5..394e8e0 100644 --- a/app/Interfaces/Part/IPInterface.php +++ b/app/Interfaces/Part/IPInterface.php @@ -3,9 +3,10 @@ namespace App\Interfaces\Part; use App\Entities\Equipment\ServerEntity; +use App\Entities\Part\IPEntity; interface IPInterface { - public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): void; - public function detachFromServer(ServerEntity $serverEntity): void; + public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity; + public function detachFromServer(ServerEntity $serverEntity): IPEntity; } diff --git a/app/Interfaces/Part/SWITCHInterface.php b/app/Interfaces/Part/SWITCHInterface.php index 53a0341..8a3cb21 100644 --- a/app/Interfaces/Part/SWITCHInterface.php +++ b/app/Interfaces/Part/SWITCHInterface.php @@ -3,9 +3,10 @@ namespace App\Interfaces\Part; use App\Entities\Equipment\ServerEntity; +use App\Entities\Part\SWITCHEntity; interface SWITCHInterface { - public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): void; - public function detachFromServer(ServerEntity $serverEntity): void; + public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): SWITCHEntity; + public function detachFromServer(ServerEntity $serverEntity): SWITCHEntity; } diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php index a911317..1b3acf3 100644 --- a/app/Services/Part/IPService.php +++ b/app/Services/Part/IPService.php @@ -112,7 +112,7 @@ class IPService extends PartService implements IPInterface parent::setOrderBy($field, $value); } //서버관련 작업 - public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): void + public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity { $formDatas = []; $formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUID(); @@ -121,14 +121,15 @@ class IPService extends PartService implements IPInterface $formDatas['status'] = STATUS['OCCUPIED']; //IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정 $entity = $this->getEntity(['ip' => $serverEntity->getIP()]); - if ($entity instanceof IPEntity) { - if ($entity->getStatus() !== STATUS['AVAILABLE']) { - throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다."); - } - $entity = parent::modify($entity, $formDatas); + if (!$entity instanceof IPEntity) { + throw new \Exception("{$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다."); } + if ($entity->getStatus() !== STATUS['AVAILABLE']) { + throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다."); + } + return parent::modify($entity, $formDatas); } - public function detachFromServer(ServerEntity $serverEntity): void + public function detachFromServer(ServerEntity $serverEntity): IPEntity { $formDatas = []; $formDatas['clientinfo_uid'] = null; @@ -142,7 +143,7 @@ class IPService extends PartService implements IPInterface throw new \Exception("{$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다."); } //IP정보 수정 - parent::modify($entity, $formDatas); + return parent::modify($entity, $formDatas); } //서버파트관련 작업 public function attachToServerPart(ServerPartEntity $serverPartEntity): IPEntity diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php index dab367d..26e6fda 100644 --- a/app/Services/Part/SWITCHService.php +++ b/app/Services/Part/SWITCHService.php @@ -91,7 +91,7 @@ class SWITCHService extends PartService implements SWITCHInterface parent::setOrderBy($field, $value); } //서버관련 작업 - public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): void + public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): SWITCHEntity { $formDatas = []; $formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUID(); @@ -102,15 +102,16 @@ class SWITCHService extends PartService implements SWITCHInterface throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다."); } //Switch정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정 - $entity = $this->getEntity(['code' => $serverEntity->getCode()]); - if ($entity instanceof SWITCHEntity) { - if ($entity->getStatus() !== STATUS['AVAILABLE']) { - throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다."); - } - $entity = parent::modify($entity, $formDatas); + $entity = $this->getEntity(['code' => $serverEntity->getSwitch()]); + if (!$entity instanceof SWITCHEntity) { + throw new \Exception("{$serverEntity->getSwitch()}에 해당하는 Switch정보를 찾을수없습니다."); } + if ($entity->getStatus() !== STATUS['AVAILABLE']) { + throw new \Exception(__METHOD__ . ":에서 오류발생: {$serverEntity->getTitle()}는 사용중입니다."); + } + return parent::modify($entity, $formDatas); } - public function detachFromServer(ServerEntity $serverEntity): void + public function detachFromServer(ServerEntity $serverEntity): SWITCHEntity { $formDatas = []; $formDatas['clientinfo_uid'] = null; @@ -122,12 +123,12 @@ class SWITCHService extends PartService implements SWITCHInterface throw new \Exception(__METHOD__ . ":에서 오류발생: Switch상태가 설정되지 않았습니다."); } //Switch정보가져오기 - $entity = $this->getEntity(['code' => $serverEntity->getCode()]); + $entity = $this->getEntity(['code' => $serverEntity->getSwitch()]); if (!$entity instanceof SWITCHEntity) { - throw new \Exception("{$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다."); + throw new \Exception("{$serverEntity->getSwitch()}에 해당하는 Switch정보를 찾을수없습니다."); } //Switch정보 수정 - parent::modify($entity, $formDatas); + return parent::modify($entity, $formDatas); } //서버파트관련 작업 public function attachToServerPart(ServerPartEntity $serverPartEntity): SWITCHEntity