From 3542458ac7d61f9d20d6b88b6ebfc79c9c353c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 19 Nov 2025 11:16:04 +0900 Subject: [PATCH] dbmsv4 init...1 --- app/Config/Services.php | 14 +- app/Controllers/Admin/Part/CSController.php | 250 ++++++++++++++++++ app/Controllers/Admin/Part/DISKController.php | 224 ++++++++++++++++ app/Controllers/Admin/Part/IPController.php | 241 +++++++++++++++++ app/Controllers/Admin/Part/RAMController.php | 223 ++++++++++++++++ .../Admin/Part/SOFTWAREController.php | 223 ++++++++++++++++ .../Admin/Part/SWITCHController.php | 244 +++++++++++++++++ app/DTOs/Part/CPUDTO.php | 2 +- app/DTOs/Part/CSDTO.php | 29 ++ app/DTOs/Part/DISKDTO.php | 26 ++ app/DTOs/Part/IPDTO.php | 28 ++ app/DTOs/Part/RAMDTO.php | 25 ++ app/DTOs/Part/SOFTWAREDTO.php | 25 ++ app/DTOs/Part/SWITCHDTO.php | 26 ++ app/Forms/Part/CPUForm.php | 5 +- app/Forms/Part/CSForm.php | 34 +++ app/Forms/Part/DISKForm.php | 20 ++ app/Forms/Part/IPForm.php | 30 +++ app/Forms/Part/PartForm.php | 2 +- app/Forms/Part/RAMForm.php | 20 ++ app/Forms/Part/SOFTWAREForm.php | 20 ++ app/Forms/Part/SWITCHForm.php | 23 ++ app/Helpers/CommonHelper.php | 3 +- app/Helpers/Customer/AccountHelper.php | 4 +- app/Helpers/Customer/ClientHelper.php | 4 +- app/Helpers/Customer/CouponHelper.php | 4 +- app/Helpers/Customer/CustomerHelper.php | 13 + app/Helpers/Customer/PointHelper.php | 4 +- app/Helpers/Equipment/EquipmentHelper.php | 13 + app/Helpers/Equipment/LineHelper.php | 4 +- app/Helpers/Equipment/ServerHelper.php | 4 +- app/Helpers/Equipment/ServerPartHelper.php | 4 +- app/Helpers/Part/CPUHelper.php | 4 +- app/Helpers/Part/CSHelper.php | 11 + app/Helpers/Part/DISKHelper.php | 11 + app/Helpers/Part/IPHelper.php | 11 + app/Helpers/Part/PartHelper.php | 13 + app/Helpers/Part/RAMHelper.php | 11 + app/Helpers/Part/SOFTWAREHelper.php | 11 + app/Helpers/Part/SWITCHHelper.php | 23 ++ app/Models/Part/CSModel.php | 26 -- app/Models/Part/IPModel.php | 28 -- app/Models/Part/SWITCHModel.php | 15 -- app/Services/Part/CSService.php | 95 +++++++ app/Services/Part/DISKService.php | 95 +++++++ app/Services/Part/IPService.php | 95 +++++++ app/Services/Part/RAMService.php | 95 +++++++ app/Services/Part/SOFTWAREService.php | 95 +++++++ app/Services/Part/SWITCHService.php | 95 +++++++ 49 files changed, 2422 insertions(+), 103 deletions(-) create mode 100644 app/Controllers/Admin/Part/CSController.php create mode 100644 app/Controllers/Admin/Part/DISKController.php create mode 100644 app/Controllers/Admin/Part/IPController.php create mode 100644 app/Controllers/Admin/Part/RAMController.php create mode 100644 app/Controllers/Admin/Part/SOFTWAREController.php create mode 100644 app/Controllers/Admin/Part/SWITCHController.php create mode 100644 app/DTOs/Part/CSDTO.php create mode 100644 app/DTOs/Part/DISKDTO.php create mode 100644 app/DTOs/Part/IPDTO.php create mode 100644 app/DTOs/Part/RAMDTO.php create mode 100644 app/DTOs/Part/SOFTWAREDTO.php create mode 100644 app/DTOs/Part/SWITCHDTO.php create mode 100644 app/Forms/Part/CSForm.php create mode 100644 app/Forms/Part/DISKForm.php create mode 100644 app/Forms/Part/IPForm.php create mode 100644 app/Forms/Part/RAMForm.php create mode 100644 app/Forms/Part/SOFTWAREForm.php create mode 100644 app/Forms/Part/SWITCHForm.php create mode 100644 app/Helpers/Customer/CustomerHelper.php create mode 100644 app/Helpers/Equipment/EquipmentHelper.php create mode 100644 app/Helpers/Part/CSHelper.php create mode 100644 app/Helpers/Part/DISKHelper.php create mode 100644 app/Helpers/Part/IPHelper.php create mode 100644 app/Helpers/Part/PartHelper.php create mode 100644 app/Helpers/Part/RAMHelper.php create mode 100644 app/Helpers/Part/SOFTWAREHelper.php create mode 100644 app/Helpers/Part/SWITCHHelper.php create mode 100644 app/Services/Part/CSService.php create mode 100644 app/Services/Part/DISKService.php create mode 100644 app/Services/Part/IPService.php create mode 100644 app/Services/Part/RAMService.php create mode 100644 app/Services/Part/SOFTWAREService.php create mode 100644 app/Services/Part/SWITCHService.php diff --git a/app/Config/Services.php b/app/Config/Services.php index 9f97029..bfb7906 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -13,6 +13,12 @@ use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerService; use App\Services\MylogService; use App\Services\Part\CPUService; +use App\Services\Part\CSService; +use App\Services\Part\DISKService; +use App\Services\Part\IPService; +use App\Services\Part\RAMService; +use App\Services\Part\SOFTWAREService; +use App\Services\Part\SWITCHService; use App\Services\PaymentService; use App\Services\UserService; use CodeIgniter\Config\BaseService; @@ -213,21 +219,21 @@ class Services extends BaseService new \App\Models\Part\SWITCHModel(), ); } - public static function part_ipservice($getShared = true): IPervice + public static function part_ipservice($getShared = true): IPService { if ($getShared) { return static::getSharedInstance(__FUNCTION__); } - return new IPervice( + return new IPService( new \App\Models\Part\IPModel(), ); } - public static function part_csservice($getShared = true): CService + public static function part_csservice($getShared = true): CSService { if ($getShared) { return static::getSharedInstance(__FUNCTION__); } - return new CService( + return new CSService( new \App\Models\Part\CSModel(), ); } diff --git a/app/Controllers/Admin/Part/CSController.php b/app/Controllers/Admin/Part/CSController.php new file mode 100644 index 0000000..0c5b753 --- /dev/null +++ b/app/Controllers/Admin/Part/CSController.php @@ -0,0 +1,250 @@ +service === null) { + $this->service = service('part_softwareservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "type", + "ip", + "accountid", + "domain", + "price", + ]; + $filters = [ + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'status' + ]; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [ + ...$fields, + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'ip', + 'accountid', + 'domain', + 'price', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'ip', + 'accountid', + 'domain', + 'price', + 'status', + 'created_at' + ]; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Part/DISKController.php b/app/Controllers/Admin/Part/DISKController.php new file mode 100644 index 0000000..ebb1ba8 --- /dev/null +++ b/app/Controllers/Admin/Part/DISKController.php @@ -0,0 +1,224 @@ +service === null) { + $this->service = service('part_diskservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "title", + "price", + "stock", + "format", + ]; + $filters = [ + "status", + ]; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Part/IPController.php b/app/Controllers/Admin/Part/IPController.php new file mode 100644 index 0000000..2608c39 --- /dev/null +++ b/app/Controllers/Admin/Part/IPController.php @@ -0,0 +1,241 @@ +service === null) { + $this->service = service('part_softwareservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "lineinfo_uid", + "ip", + "price", + ]; + $filters = [ + 'old_clientinfo_uid', + 'clientinfo_uid', + 'serverinfo_uid', + "lineinfo_uid", + 'status' + ]; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serverinfo_uid', + 'old_clientinfo_uid', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serverinfo_uid', + 'old_clientinfo_uid', + 'status', + 'created_at' + ]; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Part/RAMController.php b/app/Controllers/Admin/Part/RAMController.php new file mode 100644 index 0000000..0af5fda --- /dev/null +++ b/app/Controllers/Admin/Part/RAMController.php @@ -0,0 +1,223 @@ +service === null) { + $this->service = service('part_ramservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Part/SOFTWAREController.php b/app/Controllers/Admin/Part/SOFTWAREController.php new file mode 100644 index 0000000..90a64ca --- /dev/null +++ b/app/Controllers/Admin/Part/SOFTWAREController.php @@ -0,0 +1,223 @@ +service === null) { + $this->service = service('part_softwareservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Part/SWITCHController.php b/app/Controllers/Admin/Part/SWITCHController.php new file mode 100644 index 0000000..293599a --- /dev/null +++ b/app/Controllers/Admin/Part/SWITCHController.php @@ -0,0 +1,244 @@ +service === null) { + $this->service = service('part_softwareservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "code", + "price", + ]; + $filters = [ + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status' + ]; + $batchjobFilters = [ + 'status', + ]; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + parent::action_init_process($action); + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [ + ...$fields, + 'status', + ]; + break; + case 'view': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status', + 'created_at' + ]; + break; + default: + throw new \Exception("[{$action}] 지원하지 않는 action입니다."); + // break; + } + $this->service->getFormService()->setFormFields($fields); + $this->service->getFormService()->setFormRules($action, $fields); + $this->service->getFormService()->setFormFilters($filters); + $this->service->getFormService()->setFormOptions($filters); + $this->service->getFormService()->setBatchjobFilters($batchjobFilters); + // $this->service->getFormService()->setActionButtons($actionButtons); + // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); + parent::action_init_process($action); + } + + public function create_form(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->addViewDatas('formDatas', $this->create_form_process()); + return $this->create_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); + } + } + public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + return $this->create_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); + } + } + public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_form_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); + } + } + public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->modify_result_process($entity); + } catch (ValidationException $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + } + } + public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } + public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } + } + public function batchjob(): string|RedirectResponse + { + try { + // 사전작업 및 데이터 추출 초기화 + list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); + $this->service->getFormService()->setFormFields($selectedFields); + $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); + $this->service->getFormService()->setFormFilters($selectedFields); + $this->service->getFormService()->setFormOptions($selectedFields); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_process($uid, $formDatas); + } catch (ValidationException $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); + } + } + + public function batchjob_delete(): string|RedirectResponse + { + try { + $uids = $this->batchjob_delete_pre_process(); + $entities = []; + $errors = []; + foreach ($uids as $uid) { + try { + $entities[] = $this->batchjob_delete_process($uid); + } catch (\Exception $e) { + log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + $errors[] = $e->getMessage(); + } + } + return $this->batchjob_delete_result_process($uids, $entities, $errors); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); + } + } + + public function index(): string|ResponseInterface + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $this->index_process($action); + $this->index_result_process($action); + } catch (\Exception $e) { + session()->setFlashdata('message', $e->getMessage()); + } + return $this->index_result_process($action); + } + + public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + return $this->download_process($action, $output_type, $uid); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); + } + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/DTOs/Part/CPUDTO.php b/app/DTOs/Part/CPUDTO.php index 018f1fc..55691bf 100644 --- a/app/DTOs/Part/CPUDTO.php +++ b/app/DTOs/Part/CPUDTO.php @@ -10,7 +10,7 @@ class CPUDTO extends CommonDTO public ?string $title = null; public ?int $price = null; public ?string $used = null; - public ?int $string = null; + public ?int $stock = null; public ?string $status = null; public function __construct(array $datas = []) diff --git a/app/DTOs/Part/CSDTO.php b/app/DTOs/Part/CSDTO.php new file mode 100644 index 0000000..b765283 --- /dev/null +++ b/app/DTOs/Part/CSDTO.php @@ -0,0 +1,29 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/DISKDTO.php b/app/DTOs/Part/DISKDTO.php new file mode 100644 index 0000000..aad476f --- /dev/null +++ b/app/DTOs/Part/DISKDTO.php @@ -0,0 +1,26 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/IPDTO.php b/app/DTOs/Part/IPDTO.php new file mode 100644 index 0000000..9ca132b --- /dev/null +++ b/app/DTOs/Part/IPDTO.php @@ -0,0 +1,28 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/RAMDTO.php b/app/DTOs/Part/RAMDTO.php new file mode 100644 index 0000000..0c26649 --- /dev/null +++ b/app/DTOs/Part/RAMDTO.php @@ -0,0 +1,25 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/SOFTWAREDTO.php b/app/DTOs/Part/SOFTWAREDTO.php new file mode 100644 index 0000000..9400174 --- /dev/null +++ b/app/DTOs/Part/SOFTWAREDTO.php @@ -0,0 +1,25 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/SWITCHDTO.php b/app/DTOs/Part/SWITCHDTO.php new file mode 100644 index 0000000..6debbd4 --- /dev/null +++ b/app/DTOs/Part/SWITCHDTO.php @@ -0,0 +1,26 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/Forms/Part/CPUForm.php b/app/Forms/Part/CPUForm.php index f77e089..5e66a6a 100644 --- a/app/Forms/Part/CPUForm.php +++ b/app/Forms/Part/CPUForm.php @@ -2,8 +2,6 @@ namespace App\Forms\Part; -use App\Forms\CommonForm; - class CPUForm extends PartForm { public function __construct() @@ -13,6 +11,9 @@ class CPUForm extends PartForm public function getFormRule(string $action, string $field): string { switch ($field) { + case "format": + $rule = "required|numeric"; + break; default: $rule = parent::getFormRule($action, $field); break; diff --git a/app/Forms/Part/CSForm.php b/app/Forms/Part/CSForm.php new file mode 100644 index 0000000..50c7ba2 --- /dev/null +++ b/app/Forms/Part/CSForm.php @@ -0,0 +1,34 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "accountid": + case "domain": + $rule = "permit_empty|trim|string"; + break; + case "status": + $rule = "required|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Part/DISKForm.php b/app/Forms/Part/DISKForm.php new file mode 100644 index 0000000..58ceac4 --- /dev/null +++ b/app/Forms/Part/DISKForm.php @@ -0,0 +1,20 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "status": + $rule = "required|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Part/PartForm.php b/app/Forms/Part/PartForm.php index d1b78e5..63e43d1 100644 --- a/app/Forms/Part/PartForm.php +++ b/app/Forms/Part/PartForm.php @@ -20,7 +20,7 @@ abstract class PartForm extends CommonForm case "clientinfo_uid": case "serviceinfo_uid": case "serverinfo_uid": - $rule = "permit_empty|trim|string"; + $rule = "permit_empty|numeric"; break; case "price": case "stock": diff --git a/app/Forms/Part/RAMForm.php b/app/Forms/Part/RAMForm.php new file mode 100644 index 0000000..92be45e --- /dev/null +++ b/app/Forms/Part/RAMForm.php @@ -0,0 +1,20 @@ +getCode(), $viewDatas, $extras); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Models/Part/CSModel.php b/app/Models/Part/CSModel.php index 45ef928..48bfdf2 100644 --- a/app/Models/Part/CSModel.php +++ b/app/Models/Part/CSModel.php @@ -29,30 +29,4 @@ class CSModel extends PartModel { parent::__construct(); } - public function getFormRule(string $action, string $field): string - { - if (is_array($field)) { - throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); - } - switch ($field) { - case "type": - $rule = "required|trim|string"; - break; - case "ip": - $rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : ""; - break; - case "accountid": - case "domain": - $rule = "permit_empty|trim|string"; - break; - case "status": - $rule = "required|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Part/IPModel.php b/app/Models/Part/IPModel.php index 0b503d1..8175903 100644 --- a/app/Models/Part/IPModel.php +++ b/app/Models/Part/IPModel.php @@ -28,32 +28,4 @@ class IPModel extends PartModel { parent::__construct(); } - public function getFormRule(string $action, string $field): string - { - if (is_array($field)) { - throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); - } - switch ($field) { - case "lineinfo_uid": - $rule = "required|numeric"; - break; - case "old_clientinfo_uid": - case "clientinfo_uid": - case "serviceinfo_uid": - case "serverinfo_uid": - $rule = "permit_empty|numeric"; - break; - case "ip": - $rule = "required|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : ""; - break; - case "status": - $rule = "required|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Part/SWITCHModel.php b/app/Models/Part/SWITCHModel.php index 59e89ab..6c1b035 100644 --- a/app/Models/Part/SWITCHModel.php +++ b/app/Models/Part/SWITCHModel.php @@ -27,19 +27,4 @@ class SWITCHModel extends PartModel { parent::__construct(); } - public function getFormRule(string $action, string $field): string - { - if (is_array($field)) { - throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); - } - switch ($field) { - case "status": - $rule = "required|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php new file mode 100644 index 0000000..3909b90 --- /dev/null +++ b/app/Services/Part/CSService.php @@ -0,0 +1,95 @@ +addClassPaths('CS'); + } + public function createDTO(array $formDatas): CSDTO + { + return new CSDTO($formDatas); + } + public function getFormService(): CSForm + { + if ($this->_form === null) { + $this->_form = new CSForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): CSHelper + { + if ($this->_helper === null) { + $this->_helper = new CSHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): CSEntity + { + return $entity; + } + protected function create_process(array $formDatas): CSEntity + { + return new CSEntity($formDatas); + } + public function create(object $dto): CSEntity + { + if (!$dto instanceof CSDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): CSEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): CSEntity + { + if (!$dto instanceof CSDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof CSEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/DISKService.php b/app/Services/Part/DISKService.php new file mode 100644 index 0000000..5dd8333 --- /dev/null +++ b/app/Services/Part/DISKService.php @@ -0,0 +1,95 @@ +addClassPaths('DISK'); + } + public function createDTO(array $formDatas): DISKDTO + { + return new DISKDTO($formDatas); + } + public function getFormService(): DISKForm + { + if ($this->_form === null) { + $this->_form = new DISKForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): DISKHelper + { + if ($this->_helper === null) { + $this->_helper = new DISKHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): DISKEntity + { + return $entity; + } + protected function create_process(array $formDatas): DISKEntity + { + return new DISKEntity($formDatas); + } + public function create(object $dto): DISKEntity + { + if (!$dto instanceof DISKDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): DISKEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): DISKEntity + { + if (!$dto instanceof DISKDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof DISKEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php new file mode 100644 index 0000000..59d36f6 --- /dev/null +++ b/app/Services/Part/IPService.php @@ -0,0 +1,95 @@ +addClassPaths('IP'); + } + public function createDTO(array $formDatas): IPDTO + { + return new IPDTO($formDatas); + } + public function getFormService(): IPForm + { + if ($this->_form === null) { + $this->_form = new IPForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): IPHelper + { + if ($this->_helper === null) { + $this->_helper = new IPHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): IPEntity + { + return $entity; + } + protected function create_process(array $formDatas): IPEntity + { + return new IPEntity($formDatas); + } + public function create(object $dto): IPEntity + { + if (!$dto instanceof IPDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): IPEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): IPEntity + { + if (!$dto instanceof IPDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof IPEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/RAMService.php b/app/Services/Part/RAMService.php new file mode 100644 index 0000000..af9ddc4 --- /dev/null +++ b/app/Services/Part/RAMService.php @@ -0,0 +1,95 @@ +addClassPaths('RAM'); + } + public function createDTO(array $formDatas): RAMDTO + { + return new RAMDTO($formDatas); + } + public function getFormService(): RAMForm + { + if ($this->_form === null) { + $this->_form = new RAMForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): RAMHelper + { + if ($this->_helper === null) { + $this->_helper = new RAMHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): RAMEntity + { + return $entity; + } + protected function create_process(array $formDatas): RAMEntity + { + return new RAMEntity($formDatas); + } + public function create(object $dto): RAMEntity + { + if (!$dto instanceof RAMDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): RAMEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): RAMEntity + { + if (!$dto instanceof RAMDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof RAMEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/SOFTWAREService.php b/app/Services/Part/SOFTWAREService.php new file mode 100644 index 0000000..05572b7 --- /dev/null +++ b/app/Services/Part/SOFTWAREService.php @@ -0,0 +1,95 @@ +addClassPaths('SOFTWARE'); + } + public function createDTO(array $formDatas): SOFTWAREDTO + { + return new SOFTWAREDTO($formDatas); + } + public function getFormService(): SOFTWAREForm + { + if ($this->_form === null) { + $this->_form = new SOFTWAREForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): SOFTWAREHelper + { + if ($this->_helper === null) { + $this->_helper = new SOFTWAREHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): SOFTWAREEntity + { + return $entity; + } + protected function create_process(array $formDatas): SOFTWAREEntity + { + return new SOFTWAREEntity($formDatas); + } + public function create(object $dto): SOFTWAREEntity + { + if (!$dto instanceof SOFTWAREDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): SOFTWAREEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): SOFTWAREEntity + { + if (!$dto instanceof SOFTWAREDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof SOFTWAREEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php new file mode 100644 index 0000000..1239621 --- /dev/null +++ b/app/Services/Part/SWITCHService.php @@ -0,0 +1,95 @@ +addClassPaths('SWITCH'); + } + public function createDTO(array $formDatas): SWITCHDTO + { + return new SWITCHDTO($formDatas); + } + public function getFormService(): SWITCHForm + { + if ($this->_form === null) { + $this->_form = new SWITCHForm(); + $this->_form->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_form; + } + public function getHelper(): SWITCHHelper + { + if ($this->_helper === null) { + $this->_helper = new SWITCHHelper(); + $this->_helper->setAttributes([ + 'pk_field' => $this->model->getPKField(), + 'title_field' => $this->model->getTitleField(), + 'table' => $this->model->getTable(), + 'useAutoIncrement' => $this->model->useAutoIncrement(), + 'class_path' => $this->getClassPaths(false) + ]); + } + return $this->_helper; + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): SWITCHEntity + { + return $entity; + } + protected function create_process(array $formDatas): SWITCHEntity + { + return new SWITCHEntity($formDatas); + } + public function create(object $dto): SWITCHEntity + { + if (!$dto instanceof SWITCHDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): SWITCHEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): SWITCHEntity + { + if (!$dto instanceof SWITCHDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof SWITCHEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +}