dbmsv2/app/Services/Equipment/ServerPart/SwitchService.php
2025-09-23 10:43:27 +09:00

56 lines
2.2 KiB
PHP

<?php
namespace App\Services\Equipment\ServerPart;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\SwitchEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Equipment\SwitchService as ParentService;
class SwitchService extends ParentService implements ServerPartInterface
{
public function __construct()
{
parent::__construct();
}
//서버연결정보용 등록
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): SwitchEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: Switch상태가 설정되지 않았습니다.");
}
//Switch정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof SwitchEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 Switch정보를 찾을수없습니다.");
}
//Switch정보 수정
return $this->modify($entity, $formDatas);
}
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
$formDatas['status'] = STATUS['OCCUPIED'];
$entity = $this->action_process($serverPartEntity, $formDatas);
return $serverPartEntity->setPartEntity($entity);
}
public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
return $this->createServerPart($serverPartEntity);
}
public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
$formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->action_process($serverPartEntity, $formDatas);
return $serverPartEntity->setPartEntity($entity);
}
}