dbmsv2/app/Services/Equipment/IP/ServicePart.php
2025-09-19 16:50:53 +09:00

45 lines
1.9 KiB
PHP

<?php
namespace App\Services\Equipment\IP;
use App\Entities\Equipment\IPEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Services\Equipment\IPService;
class ServicePart extends IPService implements ServerPartInterface
{
public function __construct()
{
parent::__construct();
}
//서버연결정보용 등록
public function setServerPart(string $action, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{
if (!array_key_exists('part_uid', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
}
if (!array_key_exists('status', $serverPartDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
}
$entity = $this->getEntity($serverPartDatas['part_uid']);
if (!($entity instanceof IPEntity)) {
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 IP정보를를 찾을수없습니다.");
}
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
$formDatas = [];
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
//사용가능
$formDatas['clientinfo_uid'] = null;
$formDatas['serviceinfo_uid'] = null;
$formDatas['serverinfo_uid'] = null;
} else {
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
}
$formDatas['status'] = $serverPartDatas['status'];
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
}
}