93 lines
3.0 KiB
PHP
93 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Equipment;
|
|
|
|
use App\Entities\Equipment\CSEntity;
|
|
use App\Entities\Equipment\ServerPartEntity;
|
|
use App\Helpers\Equipment\CSHelper;
|
|
use App\Interfaces\Equipment\ServerPartInterface;
|
|
use App\Models\Equipment\CSModel;
|
|
|
|
class CSService extends EquipmentService implements ServerPartInterface
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct(new CSModel(), new CSHelper());
|
|
$this->addClassName('CS');
|
|
}
|
|
public function getFormFields(): array
|
|
{
|
|
return [
|
|
"serverinfo_uid",
|
|
"type",
|
|
"ip",
|
|
"accountid",
|
|
"domain",
|
|
"price",
|
|
"status",
|
|
];
|
|
}
|
|
public function getFormFilters(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
'serverinfo_uid',
|
|
'type',
|
|
'status'
|
|
];
|
|
}
|
|
public function getIndexFields(): array
|
|
{
|
|
return [
|
|
"clientinfo_uid",
|
|
'serverinfo_uid',
|
|
'type',
|
|
'ip',
|
|
'accountid',
|
|
'domain',
|
|
'price',
|
|
'status',
|
|
];
|
|
}
|
|
public function getBatchjobFields(): array
|
|
{
|
|
return ['type', 'status'];
|
|
}
|
|
//기본 기능부분
|
|
//서비스파트 설정
|
|
public function setServerPart(ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
|
|
{
|
|
if (!array_key_exists('part_uid', $serverPartDatas)) {
|
|
throw new \Exception(__METHOD__ . "에서 오류발생: 부품번호가 정의되지 않았습니다.");
|
|
}
|
|
if (!array_key_exists('status', $serverPartDatas)) {
|
|
throw new \Exception(__METHOD__ . "에서 오류발생: 상태가 정의되지 않았습니다.");
|
|
}
|
|
$entity = $this->getEntity($serverPartDatas['part_uid']);
|
|
if (!($entity instanceof CSEntity)) {
|
|
throw new \Exception("{$serverPartDatas['part_uid']}에 해당하는 CS정보를를 찾을수없습니다.");
|
|
}
|
|
//부품정보에 서버정보 설정 및 서비스,고객정보 정의
|
|
$formDatas = [];
|
|
if ($serverPartDatas['status'] === STATUS['AVAILABLE']) {
|
|
//사용가능
|
|
$formDatas['clientinfo_uid'] = null;
|
|
$formDatas['serviceinfo_uid'] = null;
|
|
$formDatas['serverinfo_uid'] = null;
|
|
} else {
|
|
$formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID();
|
|
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
|
|
$formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID();
|
|
}
|
|
$formDatas['status'] = $serverPartDatas['status'];
|
|
return $serverPartEntity->setPartEntity($this->modify($entity, $formDatas));
|
|
}
|
|
//List 검색용
|
|
//OrderBy 처리
|
|
public function setOrderBy(mixed $field = null, mixed $value = null): void
|
|
{
|
|
$this->getModel()->orderBy('INET_ATON(ip)', 'ASC');
|
|
parent::setOrderBy($field, $value);
|
|
}
|
|
}
|