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