dbmsv2/app/Services/Equipment/ServerService.php
2025-08-27 11:14:41 +09:00

139 lines
4.5 KiB
PHP

<?php
namespace App\Services\Equipment;
use App\Entities\Equipment\ServerEntity;
use App\Models\Equipment\ServerModel;
use App\Models\Equipment\ServerPartModel;
use App\Services\Equipment\EquipmentService;
class ServerService extends EquipmentService
{
private ?ServerPartService $_serverPartService = null;
public function __construct()
{
parent::__construct(new ServerModel());
$this->addClassName('Server');
}
public function getFormFields(): array
{
return [
'fields' => [
"code",
"type",
"title",
"serverpartinfo_cpu_uid",
"serverpartinfo_ram_uid",
"serverpartinfo_disk_uid",
"serverpartinfo_os_uid",
"price",
"amount",
"manufactur_at",
"format_at",
"status",
],
'filters' => [
"clientinfo_uid",
"serviceinfo_uid",
"type",
"title",
"serverpartinfo_cpu_uid",
"serverpartinfo_ram_uid",
"serverpartinfo_disk_uid",
"serverpartinfo_os_uid",
"status"
],
];
}
public function getIndexFields(): array
{
return [
'fields' => [
'clientinfo_uid',
'serviceinfo_uid',
"type",
'title',
"serverpartinfo",
'price',
'amount',
'manufactur_at',
"format_at",
'status'
],
'filters' => ['clientinfo_uid', 'serviceinfo_uid', 'type', 'status'],
];
}
public function getBatchjobFields(): array
{
return ['clientinfo_uid', 'status'];
}
final public function getServerPartService(): ServerPartService
{
if (!$this->_serverPartService) {
$this->_serverPartService = new ServerPartService();
}
return $this->_serverPartService;
}
final public function getIPService(): IPService
{
if (!$this->_ipService) {
$this->_ipService = new IPService();
}
return $this->_ipService;
}
final public function getCSService(): CSService
{
if (!$this->_csService) {
$this->_csService = new CSService();
}
return $this->_csService;
}
//기본 기능부분
public function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serverpartinfo_cpu_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_cpu_uid');
break;
case 'serverpartinfo_ram_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_ram_uid');
break;
case 'serverpartinfo_disk_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_disk_uid');
break;
case 'serverpartinfo_os_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_os_uid');
break;
case 'serverpartinfo_db_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_db_uid');
break;
case 'serverpartinfo_software_uid':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_software_uid');
break;
case 'ipinfo_uid': //수정때문에 전체가 필요
$options = $this->getIPService()->getEntities();
break;
case 'csinfo_uid': //수정때문에 전체가 필요
$options = $this->getCSService()->getEntities();
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//FieldForm관련용
//create용 장비코드 마지막번호 가져오기
final public function getLastestCode(string $format, int $default): string
{
return $this->getModel()->getLastestCode($format, $default);
}
//List 검색용
//OrderBy 처리
public function setOrderBy(mixed $field = null, mixed $value = null): void
{
$this->getModel()->orderBy("code ASC,title ASC");
parent::setOrderBy($field, $value);
}
}