From 97e7bcdb0c41112acb65e8e97cdd946174b6b0ad Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Mon, 22 Sep 2025 18:53:51 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Controllers/Admin/UserController.php | 2 - app/Services/CommonService.php | 36 +++++++++++++--- .../Customer/Service/PaymentService.php | 2 +- .../Customer/Service/ServerService.php | 2 +- app/Services/Customer/ServiceService.php | 7 +++- app/Services/Equipment/CSService.php | 42 +++++++++++++++++++ app/Services/Equipment/IPService.php | 23 ++++++++++ app/Services/Equipment/ServerService.php | 12 ++++++ app/Services/Equipment/SwitchService.php | 32 ++++++++++++++ app/Services/MyLogService.php | 12 ------ app/Services/PaymentService.php | 6 --- 11 files changed, 147 insertions(+), 29 deletions(-) diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 06c69f9..c73814c 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -8,8 +8,6 @@ use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\Validation\Validation; use Psr\Log\LoggerInterface; - -use App\Helpers\UserHelper; use App\Services\UserService; class UserController extends AdminController diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 7635fb9..ac51893 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -2,17 +2,20 @@ namespace App\Services; -use App\Models\CommonModel; use App\Helpers\CommonHelper; +use App\Models\CommonModel; +use App\Services\Customer\ClientService; +use App\Services\UserService; abstract class CommonService { private $_myAuth = null; private $_model = null; private $_helper = null; - private $_classNames = []; private $_control = []; + private $_userService = null; + private $_clientService = null; protected function __construct(CommonModel $model, CommonHelper $helper) { $this->_model = $model; @@ -201,6 +204,22 @@ abstract class CommonService throw new \Exception($message); } } // + public function getUserService(): UserService + { + if (!$this->_userService) { + $this->_userService = new UserService(); + } + return $this->_userService; + } + public function getClientService(): ClientService + { + if (!$this->_clientService) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + //기본 기능부분 + //FieldForm관련용 final public function getFormDatas(): array { return $this->getControlDatas('form_datas'); @@ -212,8 +231,6 @@ abstract class CommonService } $this->setControlDatas('form_datas', $formDatas); } - //기본 기능부분 - //FieldForm관련용 public function getViewFields(): array { return $this->getFormFields(); @@ -244,12 +261,18 @@ abstract class CommonService 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; default: $options = lang($this->getClassName() . '.' . strtoupper($field)); break; } if (!is_array($options)) { - throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값이 array가 아닙니다.\n" . var_export($options, true)); + throw new \Exception(__FUNCTION__ . "에서 {$field}의 options 값들이 array가 아닙니다.\n" . var_export($options, true)); } return $options; } @@ -259,6 +282,9 @@ abstract class CommonService throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); } switch ($field) { + case 'user_uid': + $options = $this->getUserService()->getEntities(); + break; default: $rule = $this->getModel()->getFormRule($action, $field); break; diff --git a/app/Services/Customer/Service/PaymentService.php b/app/Services/Customer/Service/PaymentService.php index d6d6866..58947ea 100644 --- a/app/Services/Customer/Service/PaymentService.php +++ b/app/Services/Customer/Service/PaymentService.php @@ -1,6 +1,6 @@ getServerService()->getEntities(); + break; case 'CPU': case 'RAM': case 'DISK': diff --git a/app/Services/Equipment/CSService.php b/app/Services/Equipment/CSService.php index 3cd3d79..243ef7a 100644 --- a/app/Services/Equipment/CSService.php +++ b/app/Services/Equipment/CSService.php @@ -4,9 +4,14 @@ namespace App\Services\Equipment; use App\Helpers\Equipment\CSHelper; use App\Models\Equipment\CSModel; +use App\Services\Customer\ClientService; +use App\Services\Customer\ServiceService; class CSService extends EquipmentService { + private ?ClientService $_clientService = null; + private ?ServiceService $_serviceService = null; + private ?ServerService $_serverService = null; public function __construct() { parent::__construct(new CSModel(), new CSHelper()); @@ -50,7 +55,44 @@ class CSService extends EquipmentService { return ['type', 'status']; } + final public function getClientService(): ClientService + { + if (!$this->_clientService) { + $this->_clientService = new ClientService(); + } + return $this->_clientService; + } + 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; + } //기본 기능부분 + //FieldForm관련용 + public function getFormOption(string $field, $options = []): array + { + switch ($field) { + 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; + } //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void diff --git a/app/Services/Equipment/IPService.php b/app/Services/Equipment/IPService.php index a400421..e4b4f1e 100644 --- a/app/Services/Equipment/IPService.php +++ b/app/Services/Equipment/IPService.php @@ -5,6 +5,7 @@ namespace App\Services\Equipment; use App\Helpers\Equipment\IPHelper; use App\Models\Equipment\IPModel; use App\Services\Customer\ClientService; +use App\Services\Customer\ServiceService; use App\Services\Equipment\EquipmentService; use App\Services\Equipment\LineService; @@ -12,6 +13,8 @@ class IPService extends EquipmentService { private ?LineService $_lineService = null; private ?ClientService $_clientService = null; + private ?ServiceService $_serviceService = null; + private ?ServerService $_serverService = null; public function __construct() { parent::__construct(new IPModel(), new IPHelper()); @@ -67,6 +70,20 @@ class IPService extends EquipmentService } return $this->_clientService; } + 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; + } //기본기능 //FieldForm관련용 public function getFormOption(string $field, $options = []): array @@ -78,6 +95,12 @@ class IPService extends EquipmentService case 'old_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; diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 2a6bacb..716120f 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -127,6 +127,18 @@ class ServerService extends EquipmentService } //기본 기능부분 //FieldForm관련용 + public function getFormOption(string $field, $options = []): array + { + switch ($field) { + case 'serviceinfo_uid': + $options = $this->getServiceService()->getEntities(); + break; + default: + $options = parent::getFormOption($field, $options); + break; + } + return $options; + } public function setFormData(string $field, array $requestDatas, array $formDatas): array { switch ($field) { diff --git a/app/Services/Equipment/SwitchService.php b/app/Services/Equipment/SwitchService.php index 52bff5e..c7996f1 100644 --- a/app/Services/Equipment/SwitchService.php +++ b/app/Services/Equipment/SwitchService.php @@ -4,10 +4,13 @@ namespace App\Services\Equipment; use App\Helpers\Equipment\SwitchHelper; use App\Models\Equipment\SwitchModel; +use App\Services\Customer\ServiceService; use App\Services\Equipment\EquipmentService; class SwitchService extends EquipmentService { + private ?ServiceService $_serviceService = null; + private ?ServerService $_serverService = null; public function __construct() { parent::__construct(new SwitchModel(), new SwitchHelper()); @@ -45,7 +48,36 @@ class SwitchService extends EquipmentService { return ['clientinfo_uid', 'serverinfo_uid', 'status']; } + 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; + } //기본 기능부분 + public function getFormOption(string $field, array $options = []): array + { + switch ($field) { + 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; + } //FieldForm관련용 //List 검색용 //OrderBy 처리 diff --git a/app/Services/MyLogService.php b/app/Services/MyLogService.php index 83b0f4b..0246248 100644 --- a/app/Services/MyLogService.php +++ b/app/Services/MyLogService.php @@ -46,18 +46,6 @@ class MyLogService extends CommonService } //기본 기능부분 //FieldForm관련용 - public function getFormOption(string $field, array $options = []): array - { - switch ($field) { - case 'user_uid': - $options = $this->getUserService()->getEntities(); - break; - default: - $options = parent::getFormOption($field, $options); - break; - } - return $options; - } public function save(string $class, string $method, string $title, int $user_uid): MyLogEntity { $formDatas = [ diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index b259e5e..e780d8e 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -122,12 +122,6 @@ class PaymentService extends CommonService final 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;