diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9a558c5..21f6d60 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -71,6 +71,24 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('notice', 'BoardController::notice'); $routes->get('reqeusttask', 'BoardController::reqeusttask'); }); + $routes->group('payment', ['namespace' => 'App\Controllers\Admin'], function ($routes) { + $routes->get('/', 'PaymentController::index'); + //일회성결제관련용 + $routes->get('create', 'PaymentController::create_form'); + $routes->post('create', 'PaymentController::create'); + $routes->get('modify/(:num)', 'PaymentController::modify_form/$1'); + $routes->post('modify/(:num)', 'PaymentController::modify/$1'); + $routes->get('view/(:num)', 'PaymentController::view/$1'); + $routes->get('delete/(:num)', 'PaymentController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'PaymentController::toggle/$1/$2'); + $routes->post('batchjob', 'PaymentController::batchjob'); + $routes->post('batchjob_delete', 'PaymentController::batchjob_delete'); + $routes->get('download/(:alpha)', 'PaymentController::download/$1'); + //결체처리 + $routes->post('paid', 'PaymentController::paid'); + //청구서발행용 + $routes->post('invoice', 'PaymentController::invoice'); + }); //Customer 관련 $routes->group('customer', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { $routes->group('client', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { @@ -145,24 +163,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->get('terminateServer/(:num)', 'ServiceController::terminateServer/$1'); $routes->post('history/(:num)', 'ServiceController::history/$1'); }); - $routes->group('payment', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) { - $routes->get('/', 'PaymentController::index'); - //일회성결제관련용 - $routes->get('create', 'PaymentController::create_form'); - $routes->post('create', 'PaymentController::create'); - $routes->get('modify/(:num)', 'PaymentController::modify_form/$1'); - $routes->post('modify/(:num)', 'PaymentController::modify/$1'); - $routes->get('view/(:num)', 'PaymentController::view/$1'); - $routes->get('delete/(:num)', 'PaymentController::delete/$1'); - $routes->get('toggle/(:num)/(:any)', 'PaymentController::toggle/$1/$2'); - $routes->post('batchjob', 'PaymentController::batchjob'); - $routes->post('batchjob_delete', 'PaymentController::batchjob_delete'); - $routes->get('download/(:alpha)', 'PaymentController::download/$1'); - //결체처리 - $routes->post('paid', 'PaymentController::paid'); - //청구서발행용 - $routes->post('invoice', 'PaymentController::invoice'); - }); }); //Customer 관련 //Equipment 관련 diff --git a/app/Config/Services.php b/app/Config/Services.php index 494040f..6358aaf 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -6,7 +6,11 @@ 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\MylogService; +use App\Services\PaymentService; use App\Services\TrafficService; use App\Services\UserService; use CodeIgniter\Config\BaseService; @@ -78,7 +82,6 @@ class Services extends BaseService new \App\Models\USerModel() ); } - public static function mylogservice($getShared = true): MylogService { if ($getShared) { @@ -88,17 +91,16 @@ class Services extends BaseService new \App\Models\MylogModel(), ); } - - //Customer - public static function customer_accountservice($getShared = true): AccountService + public static function paymentservice($getShared = true): PaymentService { if ($getShared) { return static::getSharedInstance(__FUNCTION__); } - return new AccountService( - new \App\Models\Customer\AccountModel(), + return new PaymentService( + new \App\Models\PaymentModel(), ); } + //Customer public static function customer_clientservice($getShared = true): ClientService { if ($getShared) { @@ -108,4 +110,41 @@ class Services extends BaseService new \App\Models\Customer\ClientModel(), ); } + public static function customer_accountservice($getShared = true): AccountService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new AccountService( + new \App\Models\Customer\AccountModel(), + ); + } + public static function customer_coupontservice($getShared = true): CouponService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new CouponService( + new \App\Models\Customer\CouponModel(), + ); + } + public static function customer_pointservice($getShared = true): PointService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new PointService( + new \App\Models\Customer\PointModel(), + ); + } + //Equipment + public static function equipment_lineservice($getShared = true): LineService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new LineService( + new \App\Models\Equipment\LineModel(), + ); + } } diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php new file mode 100644 index 0000000..606480d --- /dev/null +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -0,0 +1,225 @@ +service === null) { + $this->service = service('customer_couponservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "clientinfo_uid", + "title", + "cnt", + "status", + "content" + ]; + $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': + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, '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 CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + 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 CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + $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 CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + $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 CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + 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 CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + $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/Customer/PointController.php b/app/Controllers/Admin/Customer/PointController.php new file mode 100644 index 0000000..e4f5220 --- /dev/null +++ b/app/Controllers/Admin/Customer/PointController.php @@ -0,0 +1,228 @@ +service === null) { + $this->service = service('customer_pointservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "uid", + "user_uid", + "clientinfo_uid", + "title", + "content", + "amount", + "status", + "updated_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': + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, '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 PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + 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 PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + $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 PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + $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 PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + 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 PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + $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/EquipmentController.php b/app/Controllers/Admin/Equipment/EquipmentController.php new file mode 100644 index 0000000..5880ed4 --- /dev/null +++ b/app/Controllers/Admin/Equipment/EquipmentController.php @@ -0,0 +1,20 @@ +addActionPaths(self::PATH); + } + //Index,FieldForm관련 +} diff --git a/app/Controllers/Admin/Equipment/LineController.php b/app/Controllers/Admin/Equipment/LineController.php new file mode 100644 index 0000000..8584e65 --- /dev/null +++ b/app/Controllers/Admin/Equipment/LineController.php @@ -0,0 +1,228 @@ +service === null) { + $this->service = service('equipment_lineservice'); + } + } + protected function action_init_process(string $action): void + { + $fields = [ + "uid", + "type", + "title", + "bandwith", + "start_at", + "end_at", + "status", + "updated_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': + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, '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 LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + 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 LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + $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 LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + $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 LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + 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 LineEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); + } + $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/PaymentController.php b/app/Controllers/Admin/PaymentController.php new file mode 100644 index 0000000..d31078b --- /dev/null +++ b/app/Controllers/Admin/PaymentController.php @@ -0,0 +1,231 @@ +service === null) { + $this->service = service('paymentservice'); + } + } + //Action작업관련 + protected function action_init_process(string $action): void + { + $fields = [ + "uid", + "user_uid", + "clientinfo_uid", + "serviceinfo_uid", + "serverpartinfo_uid", + "title", + "content", + "amount", + "billing", + "billing_at", + "pay", + "status", + "updated_at" + ]; + $filters = ['role', 'status']; + $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = ['title', 'amount', 'pay', 'status']; + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, '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 PaymentEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + 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 PaymentEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + $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 PaymentEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + $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 PaymentEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + 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 PaymentEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PaymentEntity만 가능"); + } + $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/UserController.php b/app/Controllers/Admin/UserController.php index 2732f32..1665cf9 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -22,9 +22,19 @@ class UserController extends AdminController //Action작업관련 protected function action_init_process(string $action): void { - $fields = ['id', 'passwd', 'confirmpassword', 'name', 'email', 'mobile', 'role']; + $fields = [ + 'id', + 'passwd', + 'confirmpassword', + 'name', + 'email', + 'mobile', + 'role' + ]; $filters = ['role', 'status']; $batchjobFilters = ['status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; switch ($action) { case 'create': case 'create_form': @@ -49,6 +59,8 @@ class UserController extends AdminController $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 diff --git a/app/DTOs/Customer/AccountDTO.php b/app/DTOs/Customer/AccountDTO.php index 7c3f8f6..9023bf8 100644 --- a/app/DTOs/Customer/AccountDTO.php +++ b/app/DTOs/Customer/AccountDTO.php @@ -7,6 +7,7 @@ use App\DTOs\CommonDTO; class AccountDTO extends CommonDTO { public ?int $uid = null; + public ?int $user_uid = null; public ?int $clientinfo_uid = null; public ?string $bank = null; public ?string $title = null; diff --git a/app/DTOs/Customer/ClientDTO.php b/app/DTOs/Customer/ClientDTO.php new file mode 100644 index 0000000..190a4c2 --- /dev/null +++ b/app/DTOs/Customer/ClientDTO.php @@ -0,0 +1,31 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Customer/CouponDTO.php b/app/DTOs/Customer/CouponDTO.php new file mode 100644 index 0000000..ef5b2c1 --- /dev/null +++ b/app/DTOs/Customer/CouponDTO.php @@ -0,0 +1,26 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Customer/PointDTO.php b/app/DTOs/Customer/PointDTO.php new file mode 100644 index 0000000..a7a2ea3 --- /dev/null +++ b/app/DTOs/Customer/PointDTO.php @@ -0,0 +1,26 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/PaymentDTO.php b/app/DTOs/PaymentDTO.php new file mode 100644 index 0000000..2cb06d4 --- /dev/null +++ b/app/DTOs/PaymentDTO.php @@ -0,0 +1,29 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/Forms/Customer/ClientForm.php b/app/Forms/Customer/ClientForm.php new file mode 100644 index 0000000..d00678b --- /dev/null +++ b/app/Forms/Customer/ClientForm.php @@ -0,0 +1,45 @@ +getAttribute('table')}.{$field}]" : ""; + break; + case "site": + case "role": + $rule = "required|trim|string"; + break; + case "email": + $rule = "permit_empty|trim|valid_email"; + break; + case "phone": + case "history": + $rule = "permit_empty|trim|string"; + break; + case "account_balance": + case "coupon_balance": + case "point_balance": + $rule = "permit_empty|numeric"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } +} diff --git a/app/Forms/Customer/CouponForm.php b/app/Forms/Customer/CouponForm.php new file mode 100644 index 0000000..2bd4769 --- /dev/null +++ b/app/Forms/Customer/CouponForm.php @@ -0,0 +1,34 @@ +_attributes = $attributes; } + final protected function getAuthContext(): AuthContext + { + return service('myauth')->getAuthContext(); + } final public function getAttribute(string $key): string { if (!array_key_exists($key, $this->_attributes)) { diff --git a/app/Helpers/Customer/AccountHelper.php b/app/Helpers/Customer/AccountHelper.php index 0c31086..c004a04 100644 --- a/app/Helpers/Customer/AccountHelper.php +++ b/app/Helpers/Customer/AccountHelper.php @@ -2,7 +2,6 @@ namespace App\Helpers\Customer; -use App\Entities\AccountEntity; use App\Helpers\CommonHelper; class AccountHelper extends CommonHelper diff --git a/app/Helpers/Customer/ClientHelper.php b/app/Helpers/Customer/ClientHelper.php new file mode 100644 index 0000000..640b53d --- /dev/null +++ b/app/Helpers/Customer/ClientHelper.php @@ -0,0 +1,117 @@ +getPK()}\">" . $value . ""; + break; + case "email": + case "phone": + $value = $this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']]) ? parent::getFieldView($field, $value, $viewDatas, $extras) : "***********"; + break; + case 'account_balance': + $value = form_label( + number_format(intval($value)) . "원", + 'index', + [ + "data-src" => "/admin/customer/account?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm text-primary", + ...$extras, + ] + ); + break; + case 'coupon_balance': + $value = form_label( + number_format(intval($value)) . "개", + 'index', + [ + "data-src" => "/admin/customer/coupon?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm text-primary", + ...$extras, + ] + ); + break; + case 'point_balance': + $value = form_label( + number_format(intval($value)) . "원", + 'index', + [ + "data-src" => "/admin/customer/point?clientinfo_uid={$viewDatas['entity']->getPK()}&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 'modify': + $action = $this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']]) ? parent::getListButton($action, $label, $viewDatas, $extras) : $label; + break; + case 'create': + case 'delete': + case 'batchjob': + case 'batchjob_delete': + $action = $this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']]) ? parent::getListButton($action, $label, $viewDatas, $extras) : ""; + break; + case 'history': + $action = form_label( + $label ? $label : ICONS['HISTORY'], + $action, + [ + "data-src" => "/admin/customer/client/history?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; + case 'coupon': + case 'account': + case 'point': + $action = form_label( + $label, + $action, + [ + "data-src" => "/admin/customer/{$action}?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "text-primary", + ...$extras + ] + ); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Helpers/Customer/CouponHelper.php b/app/Helpers/Customer/CouponHelper.php new file mode 100644 index 0000000..175c26b --- /dev/null +++ b/app/Helpers/Customer/CouponHelper.php @@ -0,0 +1,28 @@ +getCountDueAt(); + break; + case 'amount': + $value = number_format($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 'create': + case 'batchjob': + case 'batchjob_delete': + $action = ""; + break; + case 'modify': + if ($this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']])) { + $action = parent::getListButton($action, $label, $viewDatas, $extras); + } else { + $oldBatchJobUids = old("batchjob_uids", null); + $oldBatchJobUids = is_array($oldBatchJobUids) ? $oldBatchJobUids : [$oldBatchJobUids]; + $action = form_checkbox([ + "id" => "checkbox_uid_{$viewDatas['entity']->getPK()}", + "name" => "batchjob_uids[]", + "value" => $viewDatas['entity']->getPK(), + "class" => "batchjobuids_checkboxs", + "checked" => in_array($viewDatas['entity']->getPK(), $oldBatchJobUids) + ]); + $action .= $label; + } + break; + case 'delete': + $action = ""; + if ($this->getAuthContext()->isAccessRole([ROLE['USER']['SECURITY']])) { + $action = parent::getListButton($action, $label, $viewDatas, $extras); + } + break; + case 'paid': + $action = form_submit($action . "_submit", $label ? $label : '결제 처리', [ + "formaction" => current_url() . '/' . $action, + "class" => "btn btn-outline btn-warning", + ]); + break; + case 'invoice': + $action = form_submit($action . "_submit", $label ? $label : '청구서 발행', [ + "formaction" => current_url() . '/' . $action, + "class" => "btn btn-outline btn-primary", + ]); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php index e51600a..1bea9e7 100644 --- a/app/Helpers/UserHelper.php +++ b/app/Helpers/UserHelper.php @@ -2,8 +2,6 @@ namespace App\Helpers; -use App\Entities\UserEntity; - class UserHelper extends CommonHelper { public function __construct() diff --git a/app/Models/Customer/ClientModel.php b/app/Models/Customer/ClientModel.php index 54359ec..5392451 100644 --- a/app/Models/Customer/ClientModel.php +++ b/app/Models/Customer/ClientModel.php @@ -32,40 +32,4 @@ class ClientModel extends CustomerModel { 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 "name": - $rule = "required|trim|string"; - $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : ""; - break; - case "site": - case "role": - $rule = "required|trim|string"; - break; - case "email": - $rule = "permit_empty|trim|valid_email"; - break; - case "phone": - case "history": - $rule = "permit_empty|trim|string"; - break; - case "account_balance": - case "coupon_balance": - case "point_balance": - $rule = "permit_empty|numeric"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } - //입력전 코드처리 } diff --git a/app/Models/Customer/CouponModel.php b/app/Models/Customer/CouponModel.php index 34b62ab..5f34523 100644 --- a/app/Models/Customer/CouponModel.php +++ b/app/Models/Customer/CouponModel.php @@ -7,11 +7,11 @@ use App\Entities\Customer\CouponEntity; class CouponModel extends CustomerModel { const TABLE = "couponinfo"; - const PK = "uid"; + const PK = "uid"; const TITLE = "title"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; - protected $returnType = CouponEntity::class; + protected $table = self::TABLE; + protected $primaryKey = self::PK; + protected $returnType = CouponEntity::class; protected $allowedFields = [ "uid", "user_uid", @@ -26,28 +26,4 @@ class CouponModel extends CustomerModel { 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 "cnt": - $rule = "required|numeric"; - break; - case "title": - case "status": - $rule = "required|trim|string"; - break; - case "content": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Customer/PointModel.php b/app/Models/Customer/PointModel.php index 688e5d7..a612ca7 100644 --- a/app/Models/Customer/PointModel.php +++ b/app/Models/Customer/PointModel.php @@ -6,19 +6,19 @@ use App\Entities\Customer\PointEntity; class PointModel extends CustomerModel { - const TABLE = "pointinfo"; - const PK = "uid"; + const TABLE = "couponinfo"; + const PK = "uid"; const TITLE = "title"; - protected $table = self::TABLE; - protected $primaryKey = self::PK; - protected $returnType = PointEntity::class; + protected $table = self::TABLE; + protected $primaryKey = self::PK; + protected $returnType = PointEntity::class; protected $allowedFields = [ "uid", "user_uid", "clientinfo_uid", "title", "content", - "amount", + "cnt", "status", "updated_at" ]; @@ -26,28 +26,4 @@ class PointModel extends CustomerModel { 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 "amount": - $rule = "required|numeric"; - break; - case "title": - case "status": - $rule = "required|trim|string"; - break; - case "content": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/PaymentModel.php b/app/Models/PaymentModel.php index 212c83c..f29d3f1 100644 --- a/app/Models/PaymentModel.php +++ b/app/Models/PaymentModel.php @@ -31,37 +31,4 @@ class PaymentModel 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": - case "clientinfo_uid": - case "serviceinfo_uid": - case "amount": - $rule = "required|numeric"; - break; - case "serverpartinfo_uid": - $rule = "permit_empty|numeric"; - break; - case "title": - case "billing": - case "pay": - case "status": - $rule = "required|trim|string"; - break; - case "billing_at": - $rule = "required|valid_date"; - break; - case "content": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Services/Customer/AccountService.php b/app/Services/Customer/AccountService.php index 0c6acd7..9d5a749 100644 --- a/app/Services/Customer/AccountService.php +++ b/app/Services/Customer/AccountService.php @@ -7,10 +7,9 @@ use App\Entities\Customer\AccountEntity; use App\Forms\Customer\AccountForm; use App\Helpers\Customer\AccountHelper; use App\Models\Customer\AccountModel; -use App\Services\CommonService; use RuntimeException; -class AccountService extends CommonService +class AccountService extends CustomerService { private $_form = null; private $_helper = null; diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php new file mode 100644 index 0000000..68b8ae4 --- /dev/null +++ b/app/Services/Customer/ClientService.php @@ -0,0 +1,106 @@ +addClassPaths('Client'); + } + public function createDTO(array $formDatas): ClientDTO + { + return new ClientDTO($formDatas); + } + public function getFormService(): ClientForm + { + if ($this->_form === null) { + $this->_form = new ClientForm(); + $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(): ClientHelper + { + if ($this->_helper === null) { + $this->_helper = new ClientHelper(); + $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): ClientEntity + { + return $entity; + } + protected function create_process(array $formDatas): ClientEntity + { + return new ClientEntity($formDatas); + } + public function create(object $dto): ClientEntity + { + if (!$dto instanceof ClientDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof ClientEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): ClientEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof ClientEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): ClientEntity + { + if (!$dto instanceof ClientDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof ClientEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 + public function setSearchWord(string $word): void + { + $this->model->orLike($this->model->getTable() . '.alias', $word, 'both'); + parent::setSearchWord($word); + } + //OrderBy 처리 + public function setOrderBy(mixed $field = null, mixed $value = null): void + { + $this->model->orderBy("site ASC,name ASC"); + parent::setOrderBy($field, $value); + } +} diff --git a/app/Services/Customer/CouponService.php b/app/Services/Customer/CouponService.php new file mode 100644 index 0000000..879d5d0 --- /dev/null +++ b/app/Services/Customer/CouponService.php @@ -0,0 +1,95 @@ +addClassPaths('Coupon'); + } + public function createDTO(array $formDatas): CouponDTO + { + return new CouponDTO($formDatas); + } + public function getFormService(): CouponForm + { + if ($this->_form === null) { + $this->_form = new CouponForm(); + $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(): CouponHelper + { + if ($this->_helper === null) { + $this->_helper = new CouponHelper(); + $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): CouponEntity + { + return $entity; + } + protected function create_process(array $formDatas): CouponEntity + { + return new CouponEntity($formDatas); + } + public function create(object $dto): CouponEntity + { + if (!$dto instanceof CouponDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): CouponEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): CouponEntity + { + if (!$dto instanceof CouponDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof CouponEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/Customer/CustomerService.php b/app/Services/Customer/CustomerService.php new file mode 100644 index 0000000..bc5deb2 --- /dev/null +++ b/app/Services/Customer/CustomerService.php @@ -0,0 +1,15 @@ +addClassPaths('Customer'); + } +} diff --git a/app/Services/Customer/PointService.php b/app/Services/Customer/PointService.php new file mode 100644 index 0000000..577a947 --- /dev/null +++ b/app/Services/Customer/PointService.php @@ -0,0 +1,95 @@ +addClassPaths('Point'); + } + public function createDTO(array $formDatas): PointDTO + { + return new PointDTO($formDatas); + } + public function getFormService(): PointForm + { + if ($this->_form === null) { + $this->_form = new PointForm(); + $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(): PointHelper + { + if ($this->_helper === null) { + $this->_helper = new PointHelper(); + $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): PointEntity + { + return $entity; + } + protected function create_process(array $formDatas): PointEntity + { + return new PointEntity($formDatas); + } + public function create(object $dto): PointEntity + { + if (!$dto instanceof PointDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): PointEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): PointEntity + { + if (!$dto instanceof PointDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof PointEntity) { + throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +} diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php new file mode 100644 index 0000000..14d2967 --- /dev/null +++ b/app/Services/PaymentService.php @@ -0,0 +1,111 @@ +addClassPaths('Payment'); + } + public function createDTO(array $formDatas): PaymentDTO + { + return new PaymentDTO($formDatas); + } + public function getFormService(): PaymentForm + { + if ($this->_form === null) { + $this->_form = new PaymentForm(); + $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(): PaymentHelper + { + if ($this->_helper === null) { + $this->_helper = new PaymentHelper(); + $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): PaymentEntity + { + return $entity; + } + protected function create_process(array $formDatas): PaymentEntity + { + //confirmpassword 필드는 Entity에 필요없으므로 제거 + if (isset($formDatas['confirmpassword'])) { + unset($formDatas['confirmpassword']); + } + return new PaymentEntity($formDatas); + } + public function create(object $dto): PaymentEntity + { + if (!$dto instanceof PaymentDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + return parent::create($dto); + } + protected function modify_process($uid, array $formDatas): PaymentEntity + { + //confirmpassword 필드는 Entity에 필요없으므로 제거 + if (isset($formDatas['confirmpassword'])) { + unset($formDatas['confirmpassword']); + } + return parent::modify_process($uid, $formDatas); + } + public function modify($uid, object $dto): PaymentEntity + { + if (!$dto instanceof PaymentDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + return parent::modify($uid, $dto); + } + //List 검색용 + //FormFilter 조건절 처리 + public function setFilter(string $field, mixed $filter_value): void + { + switch ($field) { + case 'role': + //FIND_IN_SET()은 MySQL 함수이므로 CodeIgniter가 이를 일반 컬럼명으로 착각하고 escape하게 되면 오류가 발생 + // 따라서 ->where($sql, null, false)로 명시하여 escape를 꺼줘야 정상 작동 + $where = "FIND_IN_SET(" . $this->model->escape($filter_value) . ", {$this->model->getTable()}.{$field}) > 0"; + $this->model->where($where, null, false); + break; + default: + parent::setFilter($field, $filter_value); + break; + } + } + //검색어조건절처리 + public function setSearchWord(string $word): void + { + $this->model->orLike($this->model->getTable() . '.id', $word, 'both'); + $this->model->orLike($this->model->getTable() . '.email', $word, 'both'); + parent::setSearchWord($word); + } +}