83 lines
2.5 KiB
PHP
83 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment;
|
|
|
|
use App\Entities\Equipment\ServerPartEntity;
|
|
use App\Entities\Equipment\SwitchEntity;
|
|
use App\Helpers\Equipment\SwitchHelper;
|
|
use App\Interfaces\Equipment\ServerPartInterface;
|
|
use App\Models\Equipment\SwitchModel;
|
|
use App\Services\Equipment\EquipmentService;
|
|
|
|
class SwitchService extends EquipmentService implements ServerPartInterface
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new SwitchModel(), new SwitchHelper());
|
|
$this->addClassName('Switch');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"serverinfo_uid",
|
|
"code",
|
|
"price",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
'clientinfo_uid',
|
|
'serviceinfo_uid',
|
|
'serverinfo_uid',
|
|
'status'
|
|
];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return [
|
|
'clientinfo_uid',
|
|
'serviceinfo_uid',
|
|
'serverinfo_uid',
|
|
"price",
|
|
'status',
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['clientinfo_uid', 'serverinfo_uid', 'status'];
|
|
}
|
|
//기본 기능부분
|
|
//FieldForm관련용
|
|
//서비스파트 설정
|
|
public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): SwitchEntity
|
|
{
|
|
$entity = $this->getEntity($uid);
|
|
if (!($entity instanceof SwitchEntity)) {
|
|
throw new \Exception("{$uid}에 해당하는 스위치정보를 찾을수없습니다.");
|
|
}
|
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
$formDatas = [];
|
|
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('code', 'ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|