From ee0f5c8e389eeb1f7cd8a90db43c86d895682844 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Mon, 23 Jun 2025 17:16:55 +0900 Subject: [PATCH] dbms_init...1 --- .../Admin/Customer/CustomerController.php | 14 +++++++--- .../Admin/Customer/ServiceController.php | 26 ++----------------- app/Controllers/Admin/Home.php | 16 +++++++----- app/Services/Customer/ServiceService.php | 26 +++++++++++++++++++ 4 files changed, 49 insertions(+), 33 deletions(-) diff --git a/app/Controllers/Admin/Customer/CustomerController.php b/app/Controllers/Admin/Customer/CustomerController.php index 1c6d77a..0ce701c 100644 --- a/app/Controllers/Admin/Customer/CustomerController.php +++ b/app/Controllers/Admin/Customer/CustomerController.php @@ -7,23 +7,31 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Services\Customer\ServiceService; abstract class CustomerController extends AdminController { + private ?ServiceService $_serviceService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); } + public function getServiceService(): ServiceService + { + if (!$this->_serviceService) { + $this->_serviceService = new ServiceService($this->request); + } + return $this->_serviceService; + } //Index,FieldForm관련 //Service,ServicePaymentController사용 //LINE,IP,SERVER등 추가 FilterOption 셋팅용 final protected function setFilterOptionsByItemType(): void { + //LINE,IP,SERVER등 추가 FilterOption 셋팅용 foreach (SERVICE_ITEM_TYPES as $item_type => $label) { - $options = $this->getService()->getServiceItemLinkService($item_type)->getEntities(); - $this->setFilterFieldOption($item_type, $options); + $this->setFilterFieldOption($item_type, $this->getServiceService()->getFilterOptionsByItemType($item_type)); } - // dd($this->getFilterFieldOptions()); } } diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index bc96cf8..5ac347e 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -2,9 +2,7 @@ namespace App\Controllers\Admin\Customer; -use App\Entities\Customer\ServiceEntity; use App\Helpers\Customer\ServiceHelper; -use App\Services\Customer\ServiceItemService; use App\Services\Customer\ServiceService; use App\Services\Equipment\CodeService; @@ -16,7 +14,6 @@ use Psr\Log\LoggerInterface; class ServiceController extends CustomerController { private ?CodeService $_codeService = null; - private ?ServiceItemService $_serviceItemService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -47,13 +44,6 @@ class ServiceController extends CustomerController } return $this->_codeService; } - public function getServiceItemService(): ServiceItemService - { - if (!$this->_serviceItemService) { - $this->_serviceItemService = new ServiceItemService($this->request); - } - return $this->_serviceItemService; - } protected function getResultSuccess(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string { switch ($this->getAction()) { @@ -68,24 +58,12 @@ class ServiceController extends CustomerController return $result; } //Index,FieldForm관련 - - //Service마다 ItemEntities 설정용 - private function setItemEntitiesByService(ServiceEntity $entity): ServiceEntity - { - foreach (SERVICE_ITEM_TYPES as $item_type => $label) { - $entity->setItemEntities( - $item_type, - $this->getServiceItemService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type]) - ); - } - return $entity; - } //View 관련 protected function view_process(mixed $entity): mixed { //LINE,IP,SERVER등 추가 FilterOption 셋팅용 $this->setFilterOptionsByItemType(); - return $this->setItemEntitiesByService($entity); + return $this->getService()->setItemEntitiesByService($entity); } //List 관련 protected function setWordConditionForList(): void @@ -105,7 +83,7 @@ class ServiceController extends CustomerController $this->setFilterOptionsByItemType(); $entities = []; foreach (parent::index_process() as $entity) { - $entities[$entity->getPK()] = $this->setItemEntitiesByService($entity); + $entities[$entity->getPK()] = $this->getService()->setItemEntitiesByService($entity); } return $entities; } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 6fd539e..6323f90 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -69,17 +69,21 @@ class Home extends AdminController { $this->initAction(__FUNCTION__); //최근 inverval(default : 7일)일간 신규서버 정보 + //LINE,IP,SERVER등 추가 FilterOption 셋팅용 + foreach (SERVICE_ITEM_TYPES as $item_type => $label) { + $this->setFilterFieldOption($item_type, $this->getService()->getFilterOptionsByItemType($item_type)); + } $this->interval = intval($this->request->getVar('interval') ?? SERVICE_NEW_INTERVAL); - $this->newServiceEntities = $this->getService()->getEntitiesByNewService($this->interval); + $entities = []; + foreach ($this->getService()->getEntitiesByNewService($this->interval) as $entity) { + $entities[$entity->getPK()] = $this->getService()->setItemEntitiesByService($entity); + } + $this->newServiceEntities = $entities; $this->newServiceCount = count($this->newServiceEntities); + //미납 서버 정보 $this->unPaidEntities = $this->getServicePaymentService()->getEntitiesByUnPaid(); $this->unPaidCount = count($this->unPaidEntities); - //LINE,IP,SERVER등 추가 FilterOption 셋팅용 - foreach (SERVICE_ITEM_TYPES as $item_type => $label) { - $options = $this->getService()->getServiceItemLinkService($item_type)->getEntities(); - $this->setFilterFieldOption($item_type, $options); - } helper(['form']); return $this->getResultSuccess(); } diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index 472405a..7a475c7 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -6,6 +6,7 @@ use App\Entities\Customer\ServiceEntity; use App\Entities\Equipment\CodeEntity; use App\Models\Customer\ServiceModel; +use App\Services\Customer\ServiceItemService; use App\Services\Equipment\CodeService; use App\Services\UserService; @@ -13,6 +14,7 @@ class ServiceService extends CustomerService { private ?UserService $_userService = null; private ?CodeService $_codeService = null; + private ?ServiceItemService $_serviceItemService = null; private ?ServicePaymentService $_servicePaymentService = null; private ?string $_searchIP = null; public function __construct(mixed $request = null) @@ -70,6 +72,13 @@ class ServiceService extends CustomerService } return $this->_codeService; } + public function getServiceItemService(): ServiceItemService + { + if (!$this->_serviceItemService) { + $this->_serviceItemService = new ServiceItemService($this->request); + } + return $this->_serviceItemService; + } public function getServicePaymentService(): ServicePaymentService { if (!$this->_servicePaymentService) { @@ -118,6 +127,23 @@ class ServiceService extends CustomerService } return $options; } + + //ItemType에 따른 FilterOption 설정용 + public function getFilterOptionsByItemType(string $item_type): array + { + return $this->getServiceItemLinkService($item_type)->getEntities(); + } + //Service마다 ItemEntities 설정용 + public function setItemEntitiesByService(ServiceEntity $entity): ServiceEntity + { + foreach (SERVICE_ITEM_TYPES as $item_type => $label) { + $entity->setItemEntities( + $item_type, + $this->getServiceItemService()->getEntities(['serviceinfo_uid' => $entity->getPK(), 'item_type' => $item_type]) + ); + } + return $entity; + } //interval을 기준으로 신규서비스 가져오기 final public function getEntitiesByNewService(int $interval, string $status = DEFAULTS['STATUS']) {