dbms/app/Services/Equipment/SwitchService.php
2025-07-11 14:34:34 +09:00

61 lines
1.5 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\SwitchEntity;
use App\Models\Equipment\SwitchModel;
use App\Services\Equipment\EquipmentService;
class SwitchService extends EquipmentService
{
public function __construct()
{
parent::__construct();
$this->addClassName('Switch');
}
public function getModelClass(): SwitchModel
{
return new SwitchModel();
}
public function getEntityClass(): SwitchEntity
{
return new SwitchEntity();
}
public function getFormFields(): array
{
return [
"code",
"status",
];
}
public function getFilterFields(): array
{
return ['status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
public function getIndexFields(): array
{
return ['code', 'status'];
}
//상태변경
public function setStatus(string $code, string $status): SwitchEntity
{
//code의 경우 사용가능/사용중으로 설정작업
$entity = $this->getEntity($code);
if (!$entity) {
throw new \Exception("{$code}에 대한 Switch Port정보를 찾을수 없습니다.");
}
return $this->getModel()->modify($entity, ['status' => $status]);
}
//List 검색용
//OrderBy 처리
public function setOrderBy(string $field, $value): void
{
$this->getModel()->orderBy('code', 'ASC', false);
parent::setOrderBy($field, $value);
}
}