diff --git a/app/Config/Services.php b/app/Config/Services.php index 6358aaf..9f97029 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -4,14 +4,16 @@ namespace Config; use App\Services\Auth\GoogleService; use App\Services\Auth\LocalService; -use App\Services\CollectorService; use App\Services\Customer\AccountService; use App\Services\Customer\ClientService; use App\Services\Customer\CouponService; use App\Services\Customer\PointService; +use App\Services\Equipment\LineService; +use App\Services\Equipment\ServerPartService; +use App\Services\Equipment\ServerService; use App\Services\MylogService; +use App\Services\Part\CPUService; use App\Services\PaymentService; -use App\Services\TrafficService; use App\Services\UserService; use CodeIgniter\Config\BaseService; @@ -147,4 +149,86 @@ class Services extends BaseService new \App\Models\Equipment\LineModel(), ); } + public static function equipment_serverservice($getShared = true): ServerService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new ServerService( + new \App\Models\Equipment\ServerModel(), + ); + } + public static function equipment_serverpartservice($getShared = true): ServerPartService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new ServerPartService( + new \App\Models\Equipment\ServerPartModel(), + ); + } + //Part + public static function part_cpuservice($getShared = true): CPUService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new CPUService( + new \App\Models\Part\CPUModel(), + ); + } + public static function part_ramservice($getShared = true): RAMService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new RAMService( + new \App\Models\Part\RAMModel(), + ); + } + public static function part_diskservice($getShared = true): DISKService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new DISKService( + new \App\Models\Part\DISKModel(), + ); + } + public static function part_softwareservice($getShared = true): SOFTWAREService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new SOFTWAREService( + new \App\Models\Part\SOFTWAREModel(), + ); + } + public static function part_switchservice($getShared = true): SWITCHService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new SWITCHService( + new \App\Models\Part\SWITCHModel(), + ); + } + public static function part_ipservice($getShared = true): IPervice + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new IPervice( + new \App\Models\Part\IPModel(), + ); + } + public static function part_csservice($getShared = true): CService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new CService( + new \App\Models\Part\CSModel(), + ); + } } diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php index 606480d..f9dab88 100644 --- a/app/Controllers/Admin/Customer/CouponController.php +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -26,7 +26,7 @@ class CouponController extends CustomerController "title", "cnt", "status", - "content" + "content", ]; $filters = [ "clientinfo_uid", diff --git a/app/Controllers/Admin/Customer/PointController.php b/app/Controllers/Admin/Customer/PointController.php index e4f5220..eb9bd87 100644 --- a/app/Controllers/Admin/Customer/PointController.php +++ b/app/Controllers/Admin/Customer/PointController.php @@ -22,14 +22,11 @@ class PointController extends CustomerController protected function action_init_process(string $action): void { $fields = [ - "uid", - "user_uid", "clientinfo_uid", "title", "content", "amount", "status", - "updated_at" ]; $filters = [ "clientinfo_uid", diff --git a/app/Controllers/Admin/Equipment/LineController.php b/app/Controllers/Admin/Equipment/LineController.php index 8584e65..1626c7a 100644 --- a/app/Controllers/Admin/Equipment/LineController.php +++ b/app/Controllers/Admin/Equipment/LineController.php @@ -22,14 +22,11 @@ class LineController extends EquipmentController protected function action_init_process(string $action): void { $fields = [ - "uid", "type", "title", "bandwith", "start_at", "end_at", - "status", - "updated_at" ]; $filters = [ "clientinfo_uid", @@ -44,13 +41,14 @@ class LineController extends EquipmentController case 'create_form': case 'modify': case 'modify_form': + $fields = [...$fields, 'status']; break; case 'view': - $fields = [...$fields, 'created_at']; + $fields = [...$fields, 'status', 'created_at']; break; case 'index': case 'download': - $fields = [...$fields, 'created_at']; + $fields = [...$fields, 'status', 'created_at']; break; default: throw new \Exception("[{$action}] 지원하지 않는 action입니다."); diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php new file mode 100644 index 0000000..1498067 --- /dev/null +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -0,0 +1,230 @@ +service === null) { + $this->service = service('equipment_serverservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "code", + "type", + "switch", + "ip", + "os", + "title", + "price", + "manufactur_at", + "format_at", + ]; + $filters = [ + "clientinfo_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, '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 ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + 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 ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + $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 ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + $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 ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + 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 ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + $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/Equipment/ServerPartController.php b/app/Controllers/Admin/Equipment/ServerPartController.php new file mode 100644 index 0000000..3493179 --- /dev/null +++ b/app/Controllers/Admin/Equipment/ServerPartController.php @@ -0,0 +1,231 @@ +service === null) { + $this->service = service('equipment_serverpartservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "serverinfo_uid", + "type", + "billing", + "part_uid", + "title", + "cnt", + "extra", + "amount", + ]; + $filters = [ + "serverinfo_uid", + "type", + "part_uid", + "billing", + ]; + $batchjobFilters = ['billing', 'type']; + // $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 ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + 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 ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + $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 ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + $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 ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + 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 ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + $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/MylogController.php b/app/Controllers/Admin/MylogController.php index 32faa8b..a84f332 100644 --- a/app/Controllers/Admin/MylogController.php +++ b/app/Controllers/Admin/MylogController.php @@ -32,11 +32,11 @@ class MylogController extends AdminController case 'modify_form': break; case 'view': - $fields = [...$fields, 'created_at']; + $fields = [...$fields, 'status', 'created_at']; break; case 'index': case 'download': - $fields = [...$fields, 'created_at']; + $fields = [...$fields, 'status', 'created_at']; break; default: throw new \Exception("[{$action}] 지원하지 않는 action입니다."); diff --git a/app/Controllers/Admin/Part/CPUController.php b/app/Controllers/Admin/Part/CPUController.php new file mode 100644 index 0000000..b9c1e56 --- /dev/null +++ b/app/Controllers/Admin/Part/CPUController.php @@ -0,0 +1,223 @@ +service === null) { + $this->service = service('part_cpuservice'); + } + } + 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 CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + 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 CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + $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 CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + $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 CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + 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 CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + $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/PartController.php b/app/Controllers/Admin/Part/PartController.php new file mode 100644 index 0000000..6e0d76a --- /dev/null +++ b/app/Controllers/Admin/Part/PartController.php @@ -0,0 +1,20 @@ +addActionPaths(self::PATH); + } + //Index,FieldForm관련 +} diff --git a/app/Controllers/Admin/PaymentController.php b/app/Controllers/Admin/PaymentController.php index d31078b..04744f4 100644 --- a/app/Controllers/Admin/PaymentController.php +++ b/app/Controllers/Admin/PaymentController.php @@ -23,8 +23,6 @@ class PaymentController extends AdminController protected function action_init_process(string $action): void { $fields = [ - "uid", - "user_uid", "clientinfo_uid", "serviceinfo_uid", "serverpartinfo_uid", diff --git a/app/DTOs/Equipment/LineDTO.php b/app/DTOs/Equipment/LineDTO.php new file mode 100644 index 0000000..1a3a4b3 --- /dev/null +++ b/app/DTOs/Equipment/LineDTO.php @@ -0,0 +1,26 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Equipment/ServerDTO.php b/app/DTOs/Equipment/ServerDTO.php new file mode 100644 index 0000000..632d655 --- /dev/null +++ b/app/DTOs/Equipment/ServerDTO.php @@ -0,0 +1,29 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Equipment/ServerPartDTO.php b/app/DTOs/Equipment/ServerPartDTO.php new file mode 100644 index 0000000..f1517a9 --- /dev/null +++ b/app/DTOs/Equipment/ServerPartDTO.php @@ -0,0 +1,27 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Part/CPUDTO.php b/app/DTOs/Part/CPUDTO.php new file mode 100644 index 0000000..018f1fc --- /dev/null +++ b/app/DTOs/Part/CPUDTO.php @@ -0,0 +1,25 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php index c5fa5d9..fa91b86 100644 --- a/app/Forms/CommonForm.php +++ b/app/Forms/CommonForm.php @@ -133,6 +133,7 @@ abstract class CommonForm } return $label; } + public function getFormRule(string $action, string $field): string { switch ($field) { @@ -152,6 +153,14 @@ abstract class CommonForm $rule = "required|regex_match[/^[a-zA-Z0-9가-힣\-]+$/]|min_length[4]|max_length[20]"; $rule .= in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""; break; + case "user_uid": + $rule = "required|numeric"; + break; + case "clientinfo_uid": + case "serviceinfo_uid": + case "serverinfo_uid": + $rule = "permit_empty|numeric"; + break; case 'picture': $rule = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]"; break; diff --git a/app/Forms/Customer/AccountForm.php b/app/Forms/Customer/AccountForm.php index 00ea3d7..7e4d4f8 100644 --- a/app/Forms/Customer/AccountForm.php +++ b/app/Forms/Customer/AccountForm.php @@ -2,9 +2,7 @@ namespace App\Forms\Customer; -use App\Forms\CommonForm; - -class AccountForm extends CommonForm +class AccountForm extends CustomerForm { public function __construct() { diff --git a/app/Forms/Customer/ClientForm.php b/app/Forms/Customer/ClientForm.php index d00678b..c6c1979 100644 --- a/app/Forms/Customer/ClientForm.php +++ b/app/Forms/Customer/ClientForm.php @@ -2,9 +2,7 @@ namespace App\Forms\Customer; -use App\Forms\CommonForm; - -class ClientForm extends CommonForm +class ClientForm extends CustomerForm { public function __construct() { diff --git a/app/Forms/Customer/CouponForm.php b/app/Forms/Customer/CouponForm.php index 2bd4769..2479b4e 100644 --- a/app/Forms/Customer/CouponForm.php +++ b/app/Forms/Customer/CouponForm.php @@ -2,9 +2,7 @@ namespace App\Forms\Customer; -use App\Forms\CommonForm; - -class CouponForm extends CommonForm +class CouponForm extends CustomerForm { public function __construct() { diff --git a/app/Forms/Customer/CustomerForm.php b/app/Forms/Customer/CustomerForm.php new file mode 100644 index 0000000..a01fe04 --- /dev/null +++ b/app/Forms/Customer/CustomerForm.php @@ -0,0 +1,36 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "user_uid": + case "clientinfo_uid": + $rule = "required|numeric"; + break; + case "price": + $rule = "required|numeric"; + break; + case "status": + $rule = "permit_empty|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Customer/PointForm.php b/app/Forms/Customer/PointForm.php index abedb55..884be74 100644 --- a/app/Forms/Customer/PointForm.php +++ b/app/Forms/Customer/PointForm.php @@ -2,9 +2,7 @@ namespace App\Forms\Customer; -use App\Forms\CommonForm; - -class PointForm extends CommonForm +class PointForm extends CustomerForm { public function __construct() { diff --git a/app/Forms/Equipment/EquipmentForm.php b/app/Forms/Equipment/EquipmentForm.php new file mode 100644 index 0000000..9a35d8a --- /dev/null +++ b/app/Forms/Equipment/EquipmentForm.php @@ -0,0 +1,38 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "user_uid": + case "clientinfo_uid": + case "serviceinfo_uid": + case "serverinfo_uid": + $rule = "permit_empty|numeric"; + break; + case "price": + $rule = "required|numeric"; + break; + case "status": + $rule = "permit_empty|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Equipment/LineForm.php b/app/Forms/Equipment/LineForm.php new file mode 100644 index 0000000..83bba11 --- /dev/null +++ b/app/Forms/Equipment/LineForm.php @@ -0,0 +1,28 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "ip": + $rule = "permit_empty|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) + $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""; + break; + case "os": + $rule = "permit_empty|trim|string"; + break; + case "format_at": + $rule = "permit_empty|valid_date"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Equipment/ServerPartForm.php b/app/Forms/Equipment/ServerPartForm.php new file mode 100644 index 0000000..831d82a --- /dev/null +++ b/app/Forms/Equipment/ServerPartForm.php @@ -0,0 +1,39 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "clientinfo_uid": + case "serviceinfo_uid": + case "serverinfo_uid": + $rule = "permit_empty|trim|string"; + break; + case "price": + case "stock": + $rule = "required|numeric"; + break; + case "status": + $rule = "permit_empty|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Helpers/Equipment/LineHelper.php b/app/Helpers/Equipment/LineHelper.php new file mode 100644 index 0000000..fe5fe88 --- /dev/null +++ b/app/Helpers/Equipment/LineHelper.php @@ -0,0 +1,13 @@ +getFieldView($field, $value, $viewDatas, $extras); + $form .= form_hidden($field, (string)$value); + } + break; + case 'ip': //값 그대료 표시 + $form = "
"; + $form .= form_input($field, $value ?? "", [ + 'id' => 'ipInput', + "list" => "ipList", + "placeholder" => "예: 27.125.207.100", + "autocomplete" => "off", + ...$extras + ]); + $form .= ""; + $form .= "
"; + break; + case 'switch': //값 그대료 표시 + $form = "
"; + $form .= form_input($field, $value ?? "", [ + 'id' => 'switchInput', + "placeholder" => "Switch 코드 입력", + "autocomplete" => "off", + ...$extras + ]); + $form .= ""; + $form .= "
"; + break; + case 'manufactur_at': + case 'format_at': + $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; + $form = form_input($field, $value ?? "", $extras); + break; + default: + $form = parent::getFieldForm($field, $value, $viewDatas, $extras); + break; + } + return $form; + } + public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null + { + switch ($field) { + case 'ip': //값 그대료 표시 + break; + case 'title': + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + break; + case 'price': + $value = number_format($value); + break; + case 'manufactur_at': + case 'format_at': + $value = $value ? date("Y-m-d", strtotime($value)) : ""; + break; + default: + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + break; + } + if (is_array($value)) { + throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다"); + } + return $value; + } + public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string + { + switch ($action) { + case 'modify': + $action = parent::getListButton($action, $viewDatas['entity']->getCode(), $viewDatas, $extras); + break; + case 'history': + $action = $label ? $label : form_label( + $label ? $label : ICONS['HISTORY'], + $action, + [ + "data-src" => "/admin/customer/clienthistory?clientinfo_uid={$viewDatas['entity']->getPK()}", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm btn-primary form-label-sm", + ...$extras + ] + ); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php new file mode 100644 index 0000000..253cbed --- /dev/null +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -0,0 +1,119 @@ + 'title', 'data-price' => 'price']; + $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); + break; + case 'extra': + if (array_key_exists('type', $viewDatas['control']['form_datas']) && $viewDatas['control']['form_datas']['type'] === 'DISK') { + $options = ["" => lang("{$viewDatas['class_path']}.label.{$field}") . " 선택", ...lang("{$viewDatas['class_path']}.EXTRA.{$viewDatas['control']['form_datas']['type']}")]; + $form = form_dropdown($field, $options, $value, $extras); + } else { + $form = parent::getFieldForm($field, $value, $viewDatas, $extras);; + } + break; + default: + $form = parent::getFieldForm($field, $value, $viewDatas, $extras); + break; + } + return $form; + } + public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null + { + switch ($field) { + case 'SERVER': + $value = form_label( + sprintf( + "[%s] %s", + lang("Equipment/ServerPart.TYPE")[$viewDatas['serverEntity']->getType()], + $viewDatas['serverEntity']->getCode(), + ), + $field, + [ + "data-src" => "/admin/equipment/server/modify/{$viewDatas['serverEntity']->getPK()}?ActionTemplate=server", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm text-primary", + ...$extras, + ] + ); + break; + case 'CPU': + case 'RAM': + case 'DISK': + case 'SOFTWARE': + case 'IP': + case 'CS': + //파트 Entity + $title = $viewDatas['entity']->getTitle(); + $title .= $viewDatas['entity']->getCnt() > 1 ? "*" . $viewDatas['entity']->getCnt() . "개" : ""; + $title .= $viewDatas['entity']->getExtra() ? "[" . $viewDatas['entity']->getExtra() . "]" : ""; + if (array_key_exists('return', $extras) && $extras['return'] == 'onlyText') { + $value = $title; + } else { + $billing = $viewDatas['entity']->getBilling() === "" ? "" : ($viewDatas['entity']->getBilling() === PAYMENT['BILLING']["ONETIME"] ? ICONS['ONETIME'] : ($viewDatas['entity']->getBilling() === PAYMENT['BILLING']["MONTH"] ? ICONS['MONTH'] : "")); + $value = form_label( + $billing . $title, + $field, + [ + "data-src" => "/admin/equipment/serverpart/modify/{$viewDatas['entity']->getPK()}?type={$viewDatas['entity']->getType()}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm text-primary", + ...$extras, + ] + ); + } + break; + default: + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + break; + } + if (is_array($value)) { + throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다"); + } + return $value; + } + public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string + { + switch ($action) { + case 'IP': + case 'CS': + case 'CPU': + case 'RAM': + case 'DISK': + case 'SOFTWARE': + $action = form_label( + $label ? $label : ICONS["SERVER_ITEM_{$action}"], + $action, + [ + "data-src" => "/admin/equipment/serverpart/create?serverinfo_uid={$viewDatas['serverinfo_uid']}&type={$action}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm text-primary", + ...$extras, + ] + ); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Helpers/Part/CPUHelper.php b/app/Helpers/Part/CPUHelper.php new file mode 100644 index 0000000..b1249de --- /dev/null +++ b/app/Helpers/Part/CPUHelper.php @@ -0,0 +1,13 @@ + [ 'title' => "모델명", 'price' => "기본가", - 'used' => "사용", + 'used' => "사용갯수", 'stock' => "재고", 'status' => "상태", 'updated_at' => "수정일", diff --git a/app/Language/en/Part/DISK.php b/app/Language/en/Part/DISK.php index 7e8360b..f1f40ae 100644 --- a/app/Language/en/Part/DISK.php +++ b/app/Language/en/Part/DISK.php @@ -4,7 +4,7 @@ return [ 'label' => [ 'title' => "모델명", 'price' => "기본가", - 'used' => "사용", + 'used' => "사용갯수", 'stock' => "재고", 'format' => "포맷", 'status' => "상태", diff --git a/app/Language/en/Part/RAM.php b/app/Language/en/Part/RAM.php index 2db6c8b..9a152fe 100644 --- a/app/Language/en/Part/RAM.php +++ b/app/Language/en/Part/RAM.php @@ -4,7 +4,7 @@ return [ 'label' => [ 'title' => "모델명", 'price' => "기본가", - 'used' => "사용", + 'used' => "사용갯수", 'stock' => "재고", 'status' => "상태", 'updated_at' => "수정일", diff --git a/app/Language/en/Part/SOFTWARE.php b/app/Language/en/Part/SOFTWARE.php index 629e731..093370c 100644 --- a/app/Language/en/Part/SOFTWARE.php +++ b/app/Language/en/Part/SOFTWARE.php @@ -4,7 +4,7 @@ return [ 'label' => [ 'title' => "모델명", 'price' => "기본가", - 'used' => "사용", + 'used' => "사용갯수", 'stock' => "재고", 'status' => "상태", 'updated_at' => "수정일", diff --git a/app/Models/Customer/CustomerModel.php b/app/Models/Customer/CustomerModel.php index 768360e..35fd6f8 100644 --- a/app/Models/Customer/CustomerModel.php +++ b/app/Models/Customer/CustomerModel.php @@ -13,32 +13,4 @@ abstract class CustomerModel extends CommonModel { 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 "user_uid": - $rule = "required|numeric"; - break; - case "clientinfo_uid": - case "serviceinfo_uid": - case "serverinfo_uid": - $rule = "permit_empty|trim|numeric"; - break; - case "title": - $rule = "required|trim|string"; - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : ""; - break; - case "status": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Equipment/EquipmentModel.php b/app/Models/Equipment/EquipmentModel.php index 21e5833..ddefe8a 100644 --- a/app/Models/Equipment/EquipmentModel.php +++ b/app/Models/Equipment/EquipmentModel.php @@ -10,32 +10,4 @@ abstract class EquipmentModel extends CommonModel { 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 "title": - $rule = "required|trim|string"; - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : ""; - break; - case "clientinfo_uid": - case "serviceinfo_uid": - case "serverinfo_uid": - $rule = "permit_empty|trim|string"; - break; - case "price": - $rule = "required|numeric"; - break; - case "status": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Equipment/LineModel.php b/app/Models/Equipment/LineModel.php index f97e3af..e257fac 100644 --- a/app/Models/Equipment/LineModel.php +++ b/app/Models/Equipment/LineModel.php @@ -26,24 +26,4 @@ class LineModel extends EquipmentModel { 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 "bandwith": - case "type": - $rule = "required|trim|string"; - break; - case "start_at": - case "end_at": - $rule = "permit_empty|valid_date"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Equipment/ServerModel.php b/app/Models/Equipment/ServerModel.php index d99706a..c53e292 100644 --- a/app/Models/Equipment/ServerModel.php +++ b/app/Models/Equipment/ServerModel.php @@ -34,67 +34,4 @@ class ServerModel extends EquipmentModel { 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 "user_uid": - case "clientinfo_uid": - case "serviceinfo_uid": - $rule = "permit_empty|numeric"; - break; - case "code": - case "title": - $rule = "required|trim|string"; - break; - case "price": - $rule = "required|numeric"; - break; - case "type": - case "status": - $rule = "required|trim|string"; - break; - case "manufactur_at": - $rule = "required|valid_date"; - break; - case "switch": - $rule = "permit_empty|trim|string"; - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : ""; - break; - case "ip": - $rule = "permit_empty|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6) - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : ""; - break; - case "os": - $rule = "permit_empty|trim|string"; - break; - case "format_at": - $rule = "permit_empty|valid_date"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } - protected function convertFormDatas(string $action, string $field, array $formDatas): mixed - { - // 필드 값 존재 여부 확인 - $value = array_key_exists($field, $formDatas) ? $formDatas[$field] : null; - switch ($field) { - case 'clientinfo_uid': - case 'serviceinfo_uid': - if ($value === '') { - $value = null; - } - break; - default: - $value = parent::convertFormDatas($action, $field, $formDatas); - break; - } - return $value; - } - //기본기능 } diff --git a/app/Models/Equipment/ServerPartModel.php b/app/Models/Equipment/ServerPartModel.php index 656ca21..782b5ad 100644 --- a/app/Models/Equipment/ServerPartModel.php +++ b/app/Models/Equipment/ServerPartModel.php @@ -31,35 +31,4 @@ class ServerPartModel extends EquipmentModel { parent::__construct(); } - final 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 "serverinfo_uid": - case "part_uid": - case "cnt": - case "amount": - $rule = "required|numeric"; - break; - case "clientinfo_uid": - case "serviceinfo_uid": - case "payment_uid": - $rule = "permit_empty|numeric"; - break; - case "title": - case "type": - case "billing": - $rule = "required|trim|string"; - break; - case "extra": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Services/Equipment/EquipmentService.php b/app/Services/Equipment/EquipmentService.php new file mode 100644 index 0000000..8b68250 --- /dev/null +++ b/app/Services/Equipment/EquipmentService.php @@ -0,0 +1,15 @@ +addClassPaths('Equipment'); + } +} diff --git a/app/Services/Equipment/LineService.php b/app/Services/Equipment/LineService.php new file mode 100644 index 0000000..6e98d01 --- /dev/null +++ b/app/Services/Equipment/LineService.php @@ -0,0 +1,95 @@ +addClassPaths('Line'); + } + public function createDTO(array $formDatas): LineDTO + { + return new LineDTO($formDatas); + } + public function getFormService(): LineForm + { + if ($this->_form === null) { + $this->_form = new LineForm(); + $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(): LineHelper + { + if ($this->_helper === null) { + $this->_helper = new LineHelper(); + $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): LineEntity + { + return $entity; + } + protected function create_process(array $formDatas): LineEntity + { + return new LineEntity($formDatas); + } + public function create(object $dto): LineEntity + { + if (!$dto instanceof LineDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): LineEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): LineEntity + { + if (!$dto instanceof LineDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php new file mode 100644 index 0000000..4b0250c --- /dev/null +++ b/app/Services/Equipment/ServerPartService.php @@ -0,0 +1,95 @@ +addClassPaths('ServerPart'); + } + public function createDTO(array $formDatas): ServerPartDTO + { + return new ServerPartDTO($formDatas); + } + public function getFormService(): ServerPartForm + { + if ($this->_form === null) { + $this->_form = new ServerPartForm(); + $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(): ServerPartHelper + { + if ($this->_helper === null) { + $this->_helper = new ServerPartHelper(); + $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): ServerPartEntity + { + return $entity; + } + protected function create_process(array $formDatas): ServerPartEntity + { + return new ServerPartEntity($formDatas); + } + public function create(object $dto): ServerPartEntity + { + if (!$dto instanceof ServerPartDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): ServerPartEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): ServerPartEntity + { + if (!$dto instanceof ServerPartDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof ServerPartEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php new file mode 100644 index 0000000..de47edf --- /dev/null +++ b/app/Services/Equipment/ServerService.php @@ -0,0 +1,95 @@ +addClassPaths('Server'); + } + public function createDTO(array $formDatas): ServerDTO + { + return new ServerDTO($formDatas); + } + public function getFormService(): ServerForm + { + if ($this->_form === null) { + $this->_form = new ServerForm(); + $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(): ServerHelper + { + if ($this->_helper === null) { + $this->_helper = new ServerHelper(); + $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): ServerEntity + { + return $entity; + } + protected function create_process(array $formDatas): ServerEntity + { + return new ServerEntity($formDatas); + } + public function create(object $dto): ServerEntity + { + if (!$dto instanceof ServerDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): ServerEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): ServerEntity + { + if (!$dto instanceof ServerDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof ServerEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php new file mode 100644 index 0000000..c0b9c8f --- /dev/null +++ b/app/Services/Part/CPUService.php @@ -0,0 +1,95 @@ +addClassPaths('CPU'); + } + public function createDTO(array $formDatas): CPUDTO + { + return new CPUDTO($formDatas); + } + public function getFormService(): CPUForm + { + if ($this->_form === null) { + $this->_form = new CPUForm(); + $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(): CPUHelper + { + if ($this->_helper === null) { + $this->_helper = new CPUHelper(); + $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): CPUEntity + { + return $entity; + } + protected function create_process(array $formDatas): CPUEntity + { + return new CPUEntity($formDatas); + } + public function create(object $dto): CPUEntity + { + if (!$dto instanceof CPUDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): CPUEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): CPUEntity + { + if (!$dto instanceof CPUDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof CPUEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Part/PartService.php b/app/Services/Part/PartService.php new file mode 100644 index 0000000..7ff7aa2 --- /dev/null +++ b/app/Services/Part/PartService.php @@ -0,0 +1,15 @@ +addClassPaths('Part'); + } +}