dbms_init...1

This commit is contained in:
choi.jh 2025-06-10 10:24:04 +09:00
parent b89d928313
commit fd208c6e0d
5 changed files with 114 additions and 95 deletions

View File

@ -8,20 +8,10 @@ use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Services\Customer\ClientService;
use App\Services\Equipment\Part\CpuService;
use App\Services\Equipment\Part\DefenceService;
use App\Services\Equipment\Part\StorageService;
use App\Services\Equipment\Part\IpService;
use App\Services\Equipment\Part\LineService;
use App\Services\Equipment\Part\RamService;
use App\Services\Equipment\Part\SoftwareService;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\DomainService;
abstract class CustomerController extends AdminController
{
private ?ClientService $_clientService = null;
private $_equipmentService = [];
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -34,43 +24,6 @@ abstract class CustomerController extends AdminController
}
return $this->_clientService;
}
final public function getEquipmentService(string $key): mixed
{
if (!array_key_exists($key, $this->_equipmentService)) {
switch ($key) {
case 'SERVER':
$this->_equipmentService[$key] = new ServerService();
break;
case 'CPU':
$this->_equipmentService[$key] = new CpuService();
break;
case 'RAM':
$this->_equipmentService[$key] = new RamService();
break;
case 'STORAGE':
$this->_equipmentService[$key] = new StorageService();
break;
case 'LINE':
$this->_equipmentService[$key] = new LineService();
break;
case 'IP':
$this->_equipmentService[$key] = new IpService();
break;
case 'DEFENCE':
$this->_equipmentService[$key] = new DefenceService();
break;
case 'SOFTWARE':
$this->_equipmentService[$key] = new SoftwareService();
break;
case 'DOMAIN':
$this->_equipmentService[$key] = new DomainService();
break;
default:
throw new \Exception(__FUNCTION__ . "에서 사용하지않는 Service를 요청하였습니다.: {$key}");
}
}
return $this->_equipmentService[$key];
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
@ -79,19 +32,6 @@ abstract class CustomerController extends AdminController
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'SERVER':
case 'CPU':
case 'RAM':
case 'STORAGE':
case 'LINE':
case 'IP':
case 'DEFENCE':
case 'SOFTWARE':
case 'DOMAIN':
foreach ($this->getEquipmentService($field)->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;

View File

@ -11,10 +11,20 @@ use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Services\Equipment\Part\CpuService;
use App\Services\Equipment\Part\DefenceService;
use App\Services\Equipment\Part\StorageService;
use App\Services\Equipment\Part\IpService;
use App\Services\Equipment\Part\LineService;
use App\Services\Equipment\Part\RamService;
use App\Services\Equipment\Part\SoftwareService;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\DomainService;
class ServiceController extends CustomerController
{
private ?ServiceItemService $_serviceItemService = null;
private $_equipmentService = [];
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -45,6 +55,71 @@ class ServiceController extends CustomerController
}
return $this->_serviceItemService;
}
final public function getEquipmentService(string $key): mixed
{
if (!array_key_exists($key, $this->_equipmentService)) {
switch ($key) {
case 'SERVER':
$this->_equipmentService[$key] = new ServerService();
break;
case 'CPU':
$this->_equipmentService[$key] = new CpuService();
break;
case 'RAM':
$this->_equipmentService[$key] = new RamService();
break;
case 'STORAGE':
$this->_equipmentService[$key] = new StorageService();
break;
case 'LINE':
$this->_equipmentService[$key] = new LineService();
break;
case 'IP':
$this->_equipmentService[$key] = new IpService();
break;
case 'DEFENCE':
$this->_equipmentService[$key] = new DefenceService();
break;
case 'SOFTWARE':
$this->_equipmentService[$key] = new SoftwareService();
break;
case 'DOMAIN':
$this->_equipmentService[$key] = new DomainService();
break;
default:
throw new \Exception(__FUNCTION__ . "에서 사용하지않는 Service를 요청하였습니다.: {$key}");
}
}
return $this->_equipmentService[$key];
}
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'ownerinfo_uid':
foreach ($this->getClientService()->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
case 'SERVER':
case 'CPU':
case 'RAM':
case 'STORAGE':
case 'LINE':
case 'IP':
case 'DEFENCE':
case 'SOFTWARE':
case 'DOMAIN':
foreach ($this->getEquipmentService($field)->getEntities() as $entity) {
$options[$entity->getPK()] = $entity->getTitle();
}
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
//Index,FieldForm관련
protected function getResultSuccess(string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
switch ($this->getAction()) {
@ -77,7 +152,7 @@ class ServiceController extends CustomerController
foreach ($this->item_types as $field => $label) {
$entity->setItemEntities(
$field,
$this->getServiceItemService()->getEntities(['serviceinfo_uid'=>$entity->getPK(),'item_type' => $field])
$this->getServiceItemService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $field])
);
}
$entities[] = $entity;

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,8 @@
return [
'title' => "고객서비스정보",
'label' => [
'clientinfo_uid' => "고객명",
'clientinfo_uid' => "고객",
'ownerinfo_uid' => "관리자",
'title' => "서비스명",
'type' => "서비스형식",
'location' => "위치",

View File

@ -26,6 +26,7 @@ class ServiceService extends CustomerService
{
return [
"clientinfo_uid",
"ownerinfo_uid",
"title",
"type",
"location",
@ -40,7 +41,7 @@ class ServiceService extends CustomerService
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'type', 'location', 'switch', 'code', 'raid', 'status'];
return ["clientinfo_uid", 'ownerinfo_uid', 'type', 'location', 'switch', 'code', 'raid', 'status'];
}
public function getBatchJobFields(): array
{
@ -48,6 +49,6 @@ class ServiceService extends CustomerService
}
public function getIndexFields(): array
{
return ['clientinfo_uid', 'title', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'status'];
return ['clientinfo_uid', 'ownerinfo_uid', 'title', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'status'];
}
}