dbmsv2/app/Services/Equipment/ServerPartService.php
2025-08-27 17:54:08 +09:00

90 lines
2.8 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\ServerPartEntity;
use App\Models\Equipment\ServerPartModel;
use App\Services\Equipment\EquipmentService;
class ServerPartService extends EquipmentService
{
private ?PartService $_partService = null;
public function __construct()
{
parent::__construct(new ServerPartModel());
$this->addClassName('Server');
}
public function getFormFields(): array
{
return [
'fields' => [
"partinfo_uid",
"serverinfo_uid",
"serviceinfo_uid",
"billing",
"amount",
"cnt",
"extra",
],
'filters' => [
"partinfo_uid",
"serverinfo_uid",
"serviceinfo_uid",
],
];
}
public function getIndexFields(): array
{
return $this->getFormFields();
}
public function getBatchjobFields(): array
{
return ['partinfo_uid', "serverinfo_uid", "serviceinfo_uid",];
}
final public function getPartService(): PartService
{
if (!$this->_partService) {
$this->_partService = new PartService();
}
return $this->_partService;
}
//partEntity 정보 추가
protected function getEntity_process(mixed $entity): ServerPartEntity
{
$entity->setPartEntity($this->getPartService()->getEntity($entity->getPartInfoUID()));
return $entity;
}
//기본 기능부분
//FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'partinfo_CPU_uid':
$options = $this->getPartService()->getEntities(['type' => 'CPU']);
break;
case 'partinfo_RAM_uid':
$options = $this->getPartService()->getEntities(['type' => 'RAM']);
break;
case 'partinfo_DISK_uid':
$options = $this->getPartService()->getEntities(['type' => 'DISK']);
break;
case 'partinfo_OS_uid':
$options = $this->getPartService()->getEntities(['type' => 'OS']);
break;
case 'partinfo_DB_uid':
$options = $this->getPartService()->getEntities(['type' => 'DB']);
break;
case 'partinfo_SOFTWARE_uid':
$options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']);
break;
case 'partinfo_uid': //수정때문에 전체가 필요
$options = $this->getPartService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
}