63 lines
1.6 KiB
PHP
63 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment;
|
|
|
|
use App\Entities\Equipment\LineEntity;
|
|
use App\Helpers\Equipment\LineHelper;
|
|
use App\Models\Equipment\LineModel;
|
|
use App\Services\Part\IPService;
|
|
|
|
class LineService extends EquipmentService
|
|
{
|
|
private ?IPService $_ipService = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new LineModel(), new LineHelper());
|
|
$this->addClassName('Line');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"type",
|
|
"title",
|
|
"bandwith",
|
|
"start_at",
|
|
"end_at",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
"type",
|
|
'status',
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['status'];
|
|
}
|
|
final public function getIPService(): IPService
|
|
{
|
|
if (!$this->_ipService) {
|
|
$this->_ipService = new IPService();
|
|
}
|
|
return $this->_ipService;
|
|
}
|
|
//기본 기능부분
|
|
protected function create_process(array $formDatas): LineEntity
|
|
{
|
|
//서버정보 생성
|
|
$entity = parent::create_process($formDatas);
|
|
//Prefixed IP to array 자동 등록
|
|
foreach ($this->getHelper()->cidrToIpRange($formDatas['bandwith']) as $ip) {
|
|
$this->getIPService()->create([
|
|
'lineinfo_uid' => $entity->getPK(),
|
|
'ip' => $ip,
|
|
'status' => STATUS['AVAILABLE'],
|
|
]);
|
|
}
|
|
return $entity;
|
|
}
|
|
}
|