50 lines
1.9 KiB
PHP
50 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer\ServiceItem;
|
|
|
|
use App\Entities\Equipment\Part\IpEntity;
|
|
use App\Services\Equipment\Part\IpService;
|
|
use CodeIgniter\HTTP\IncomingRequest;
|
|
|
|
class ServiceItemIpService extends ServiceItemService
|
|
{
|
|
protected ?IncomingRequest $request = null;
|
|
private ?IpService $_ipService = null;
|
|
public function __construct(?IncomingRequest $request = null)
|
|
{
|
|
parent::__construct($request);
|
|
}
|
|
|
|
public function getIpService(): IpService
|
|
{
|
|
if (!$this->_ipService) {
|
|
$this->_ipService = new IpService($this->request);
|
|
}
|
|
return $this->_ipService;
|
|
}
|
|
|
|
public function create(array $formDatas, mixed $entity = null): ServiceItemEntity
|
|
{
|
|
//ip의 경우 서비스중으로 설정작업
|
|
$entity = parent::create($formDatas, $entity);
|
|
$this->getIpService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED);
|
|
}
|
|
public function modify(mixed $entity, array $formDatas): ServiceEntity
|
|
{
|
|
//code가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음
|
|
if (array_key_exists('code', $formDatas) && $formDatas['code'] !== $entity->getCode()) {
|
|
//code의 경우 기존code는 사용가능으로 설정작업
|
|
$this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE);
|
|
//coded의 경우 변경된 code는 서비스중으로 설정작업
|
|
$this->getCodeService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED);
|
|
}
|
|
return parent::modify($entity, $formDatas);
|
|
}
|
|
final public function delete(mixed $entity): bool
|
|
{
|
|
//code의 경우 기존code는 사용가능으로 설정작업
|
|
$this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE);
|
|
return parent::delete($entity);
|
|
}
|
|
}
|