dbmsv2/app/Services/Equipment/CS/ServerPart.php
2025-09-20 15:33:47 +09:00

54 lines
2.1 KiB
PHP

<?php
namespace App\Services\Equipment\CS;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\CSEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Equipment\CSService;
class ServerPart extends CSService implements ServerPartInterface
{
public function __construct()
{
parent::__construct();
}
//서버연결정보용 등록
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: CS상태가 설정되지 않았습니다.");
}
//CS정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!($entity instanceof CSEntity)) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
}
//CS정보 수정
return $this->modify($entity, $formDatas);
}
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{
$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);
}
}