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 = "