113 lines
3.5 KiB
PHP
113 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment;
|
|
|
|
use App\Entities\Equipment\IPEntity;
|
|
use App\Entities\Equipment\ServerPartEntity;
|
|
use App\Helpers\Equipment\IPHelper;
|
|
use App\Interfaces\Equipment\ServerPartInterface;
|
|
use App\Models\Equipment\IPModel;
|
|
use App\Services\Equipment\EquipmentService;
|
|
use App\Services\Equipment\LineService;
|
|
|
|
class IPService extends EquipmentService implements ServerPartInterface
|
|
{
|
|
private ?LineService $_lineService = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new IPModel(), new IPHelper());
|
|
$this->addClassName('IP');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"lineinfo_uid",
|
|
"serverinfo_uid",
|
|
"ip",
|
|
"price",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
'old_clientinfo_uid',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
"lineinfo_uid",
|
|
'status'
|
|
];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return [
|
|
'lineinfo_uid',
|
|
'ip',
|
|
'price',
|
|
'status',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
'old_clientinfo_uid'
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
final public function getLineService(): LineService
|
|
{
|
|
if (!$this->_lineService) {
|
|
$this->_lineService = new LineService();
|
|
}
|
|
return $this->_lineService;
|
|
}
|
|
//기본기능
|
|
//FieldForm관련용
|
|
public function getFormOption(string $field, $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'lineinfo_uid':
|
|
$options = $this->getLineService()->getEntities();
|
|
break;
|
|
case 'old_clientinfo_uid':
|
|
$options = $this->getClientService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
//서비스 설정
|
|
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): IPEntity
|
|
{
|
|
$entity = $this->getEntity($uid);
|
|
if (!($entity instanceof IPEntity)) {
|
|
throw new \Exception("{$uid}에 해당하는 IP정보를 찾을수없습니다.");
|
|
}
|
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
$formDatas = [];
|
|
//기존IP 사용자로 고객정보 설정
|
|
$formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
if ($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'] = $status;
|
|
return $this->modify($entity, $formDatas);
|
|
}
|
|
//List 검색용
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->getModel()->orderBy('INET_ATON(ip)', 'ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|