91 lines
2.8 KiB
PHP
91 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Customer;
|
|
|
|
use App\Entities\Customer\ClientEntity;
|
|
use App\Helpers\CommonHelper;
|
|
|
|
use App\Models\CommonModel;
|
|
use App\Services\CommonService;
|
|
use App\Services\Customer\ClientService;
|
|
use App\Services\Equipment\ServerService;
|
|
use App\Services\Equipment\SwitchService;
|
|
use App\Services\UserService;
|
|
|
|
abstract class CustomerService extends CommonService
|
|
{
|
|
private ?UserService $_userService = null;
|
|
private ?ClientService $_clientService = null;
|
|
private ?ServiceService $_serviceService = null;
|
|
private ?ServerService $_serverService = null;
|
|
private ?SwitchService $_switchService = null;
|
|
|
|
private $_equipmentService = [];
|
|
protected function __construct(CommonModel $model, CommonHelper $helper)
|
|
{
|
|
parent::__construct($model, $helper);
|
|
$this->addClassName('Customer');
|
|
}
|
|
public function getClientService(): ClientService
|
|
{
|
|
if (!$this->_clientService) {
|
|
$this->_clientService = new ClientService();
|
|
}
|
|
return $this->_clientService;
|
|
}
|
|
public function getUSerService(): UserService
|
|
{
|
|
if (!$this->_userService) {
|
|
$this->_userService = new UserService();
|
|
}
|
|
return $this->_userService;
|
|
}
|
|
public function getServiceService(): ServiceService
|
|
{
|
|
if (!$this->_serviceService) {
|
|
$this->_serviceService = new ServiceService();
|
|
}
|
|
return $this->_serviceService;
|
|
}
|
|
public function getServerService(): ServerService
|
|
{
|
|
if (!$this->_serverService) {
|
|
$this->_serverService = new ServerService();
|
|
}
|
|
return $this->_serverService;
|
|
}
|
|
//ServiceItemController,ServiceController에서 사용
|
|
//기본기능
|
|
//FieldForm관련용
|
|
public function getFormOption(string $field, array $options = []): array
|
|
{
|
|
switch ($field) {
|
|
case 'user_uid':
|
|
$options = $this->getUserService()->getEntities();
|
|
break;
|
|
case 'clientinfo_uid':
|
|
$options = $this->getClientService()->getEntities();
|
|
break;
|
|
case 'serviceinfo_uid':
|
|
$options = $this->getServiceService()->getEntities();
|
|
break;
|
|
case 'serverinfo_uid':
|
|
$options = $this->getServerService()->getEntities();
|
|
break;
|
|
default:
|
|
$options = parent::getFormOption($field, $options);
|
|
break;
|
|
}
|
|
return $options;
|
|
}
|
|
//ItemType에 따른 FilterOption 설정용
|
|
final public function getClient(int $uid): ClientEntity
|
|
{
|
|
$entity = $this->getClientService()->getEntity($uid);
|
|
if (!$entity) {
|
|
throw new \Exception("{$uid}에 해당하는 고객정보가 존재하지 않습니다. uid: {$uid}");
|
|
}
|
|
return $entity;
|
|
}
|
|
}
|