116 lines
3.3 KiB
PHP
116 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment;
|
|
|
|
use App\Entities\Equipment\IPEntity;
|
|
use App\Entities\Equipment\LineEntity;
|
|
use App\Models\Equipment\IPModel;
|
|
use App\Services\Equipment\EquipmentService;
|
|
use App\Services\Equipment\LineService;
|
|
|
|
class IPService extends EquipmentService
|
|
{
|
|
private ?LineService $_lineService = null;
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new IPModel());
|
|
$this->addClassName('IP');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
'fields' => [
|
|
"lineinfo_uid",
|
|
"serverinfo_uid",
|
|
"ip",
|
|
"price",
|
|
"status",
|
|
],
|
|
'filters' => [
|
|
'old_clientinfo_uid',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
"lineinfo_uid",
|
|
'status'
|
|
],
|
|
];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return [
|
|
'fields' => [
|
|
'lineinfo_uid',
|
|
'ip',
|
|
'price',
|
|
'status',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
'old_clientinfo_uid'
|
|
],
|
|
'filters' => [
|
|
'old_clientinfo_uid',
|
|
'clientinfo_uid',
|
|
'serverinfo_uid',
|
|
"lineinfo_uid",
|
|
'status'
|
|
],
|
|
'batchjob_fields' => ['status'],
|
|
'batchjob_buttions' => [
|
|
'batchjob' => '일괄 처리',
|
|
'batchjob_delete' => '일괄 삭제',
|
|
]
|
|
];
|
|
}
|
|
final public function getLineService(): LineService
|
|
{
|
|
if (!$this->_lineService) {
|
|
$this->_lineService = new LineService();
|
|
}
|
|
return $this->_lineService;
|
|
}
|
|
//기본기능
|
|
//FieldForm관련용
|
|
public function getFormFieldOption(string $field, $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'lineinfo_uid':
|
|
$options = $this->getLineService()->getEntities();
|
|
break;
|
|
case 'old_clientinfo_uid':
|
|
$options = $this->getClientService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormFieldOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
public function createByLineInfo(LineEntity $entity, string $ip): IPEntity
|
|
{
|
|
$formDatas = [
|
|
'lineinfo_uid' => $entity->getPK(),
|
|
'ip' => $ip,
|
|
'status' => IPEntity::DEFAULT_STATUS,
|
|
];
|
|
return $this->create($formDatas);
|
|
}
|
|
|
|
//상태변경
|
|
public function setStatus(int $uid, string $status): IPEntity
|
|
{
|
|
//code의 경우 사용가능/사용중으로 설정작업
|
|
$entity = $this->getEntity($uid);
|
|
if (!$entity) {
|
|
throw new \Exception("{$uid}에 대한 IP정보를 찾을수 없습니다.");
|
|
}
|
|
return $this->getModel()->modify($entity, ['status' => $status]);
|
|
}
|
|
//List 검색용
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->getModel()->orderBy('INET_ATON(ip)', 'ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|