diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 728cc18..3eddb1d 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -401,6 +401,12 @@ define('DEFAULTS', [ 'STATUS' => STATUS['AVAILABLE'] ]); ######################### +//사이트 선택관련 +define("SITES", [ + "prime" => "PRIME", + "itsolution" => "ITSOLUTION", + "gdidc" => "GDIDC", +]); //서비스 관련 define("SERVICE", [ "NEW_INTERVAL" => $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVICE_NEW_INTERVAL'] ?? 7, diff --git a/app/Config/Services.php b/app/Config/Services.php index bfb7906..1c89846 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -4,10 +4,12 @@ namespace Config; use App\Services\Auth\GoogleService; use App\Services\Auth\LocalService; +use App\Services\BoardService; use App\Services\Customer\AccountService; use App\Services\Customer\ClientService; use App\Services\Customer\CouponService; use App\Services\Customer\PointService; +use App\Services\Customer\ServiceService; use App\Services\Equipment\LineService; use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerService; @@ -99,6 +101,15 @@ class Services extends BaseService new \App\Models\MylogModel(), ); } + public static function boardservice($getShared = true): BoardService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new BoardService( + new \App\Models\BoardModel(), + ); + } public static function paymentservice($getShared = true): PaymentService { if ($getShared) { @@ -145,6 +156,15 @@ class Services extends BaseService new \App\Models\Customer\PointModel(), ); } + public static function customer_serviceservice($getShared = true): ServiceService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new ServiceService( + new \App\Models\Customer\ServiceModel(), + ); + } //Equipment public static function equipment_lineservice($getShared = true): LineService { diff --git a/app/Controllers/AbstractCRUDController.php b/app/Controllers/AbstractCRUDController.php index d3dba57..253605b 100644 --- a/app/Controllers/AbstractCRUDController.php +++ b/app/Controllers/AbstractCRUDController.php @@ -4,6 +4,8 @@ namespace App\Controllers; use App\Entities\CommonEntity; use CodeIgniter\HTTP\RedirectResponse; +use CodeIgniter\Validation\Exceptions\ValidationException; +use RuntimeException; /** * AbstractCRUDController @@ -11,6 +13,10 @@ use CodeIgniter\HTTP\RedirectResponse; */ abstract class AbstractCRUDController extends AbstractWebController { + // 💡 핵심 1: 각 자식 클래스가 사용할 Entity 클래스 경로를 반환하도록 강제 + // 이 메서드는 자식 클래스에서 반드시 구현되어야 합니다. + abstract protected function getEntityClass(): string; + // --- 생성 (Create) --- protected function create_form_process(array $formDatas = []): array @@ -21,9 +27,20 @@ abstract class AbstractCRUDController extends AbstractWebController protected function create_form_result_process(string $action): string|RedirectResponse { - return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); } + final 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()); + } + } protected function create_process(): CommonEntity { // POST 데이터를 DTO 객체로 변환 (getPost()는 POST 요청 본문만 가져옵니다.) @@ -38,6 +55,25 @@ abstract class AbstractCRUDController extends AbstractWebController )->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다."); } + final public function create(): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->create_process(); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + if (!$entity instanceof $entityClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + } + 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()); + } + } + // --- 수정 (Modify) --- protected function modify_form_process($uid): CommonEntity { @@ -53,7 +89,25 @@ abstract class AbstractCRUDController extends AbstractWebController protected function modify_form_result_process(string $action): string|RedirectResponse { - return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); + } + + final public function modify_form($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_form_process($uid); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + if (!$entity instanceof $entityClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + } + $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()); + } } protected function modify_process($uid): CommonEntity @@ -69,6 +123,25 @@ abstract class AbstractCRUDController extends AbstractWebController '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK() )->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다."); } + final public function modify($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->modify_process($uid); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + if (!$entity instanceof $entityClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + } + $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()); + } + } // --- 삭제 (Delete) --- @@ -81,6 +154,20 @@ abstract class AbstractCRUDController extends AbstractWebController { return $this->action_redirect_process('info', "{$this->getTitle()}에서 {$entity->getTitle()} 삭제가 완료되었습니다."); } + final public function delete($uid): RedirectResponse + { + try { + $entity = $this->delete_process($uid); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + if (!$entity instanceof $entityClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + } + return $this->delete_result_process($entity); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); + } + } // --- 상세보기 (View) --- @@ -98,6 +185,24 @@ abstract class AbstractCRUDController extends AbstractWebController protected function view_result_process(string $action): string { - return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); + } + + final public function view($uid): string|RedirectResponse + { + try { + $action = __FUNCTION__; + $this->action_init_process($action); + $entity = $this->view_process($uid); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + if (!$entity instanceof $entityClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + } + $this->addViewDatas('entity', $entity); + return $this->view_result_process($action); + } catch (\Exception $e) { + return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); + } } } diff --git a/app/Controllers/AbstractWebController.php b/app/Controllers/AbstractWebController.php index 1fefdfb..ef2ceb5 100644 --- a/app/Controllers/AbstractWebController.php +++ b/app/Controllers/AbstractWebController.php @@ -32,7 +32,6 @@ abstract class AbstractWebController extends Controller { parent::initController($request, $response, $logger); } - final protected function getAuthContext(): AuthContext { return service('myauth')->getAuthContext(); @@ -111,19 +110,18 @@ abstract class AbstractWebController extends Controller /** * 뷰 경로와 데이터를 이용하여 최종 HTML을 렌더링합니다. */ - protected function action_render_process(array $view_paths, string $view_file, array $viewDatas): string + protected function action_render_process(string $view_file, array $viewDatas, ?string $template_path = null): string { - $self_path = array_pop($view_paths); - if ($path = $this->request->getVar('ActionTemplate')) { - $view_paths[] = $path; + $view_path = $viewDatas['layout']; + if ($template_path) { + $view_path .= DIRECTORY_SEPARATOR . $template_path; } - $full_path = implode(DIRECTORY_SEPARATOR, $view_paths); $view_datas = [ ...$viewDatas, 'forms' => ['attributes' => ['method' => "post",], 'hiddens' => []], ]; helper(['form', __FUNCTION__]); - return view($full_path . DIRECTORY_SEPARATOR . $view_file, ['viewDatas' => $view_datas]); + return view($view_path . DIRECTORY_SEPARATOR . $view_file, ['viewDatas' => $view_datas]); } } diff --git a/app/Controllers/Admin/BoardController.php b/app/Controllers/Admin/BoardController.php new file mode 100644 index 0000000..df2203c --- /dev/null +++ b/app/Controllers/Admin/BoardController.php @@ -0,0 +1,118 @@ +service === null) { + $this->service = service('boardservice'); + } + $this->addActionPaths('board'); + } + //Action작업관련 + protected function action_init_process(string $action): void + { + $fields = [ + 'category', + 'worker_uid', + 'title', + 'status', + 'content', + ]; + $filters = [ + 'user_uid', + 'worker_uid', + 'category', + 'status', + ]; + $batchjobFilters = ['user_uid', 'category', 'status']; + // $actionButtons = ['view' => ICONS['SEARCH']]; + // $batchjobButtons = []; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [ + 'category', + 'worker_uid', + 'title', + 'status', + 'created_at', + 'content' + ]; + break; + case 'index': + $fields = [ + 'category', + 'worker_uid', + 'title', + 'status', + 'created_at' + ]; + break; + case 'download': + $fields = [ + 'category', + 'worker_uid', + 'title', + 'status', + 'created_at', + 'content' + ]; + 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); + } + protected function getEntityClass(): string + { + return UserEntity::class; + } + //기본 함수 작업 + //Custom 추가 함수 + // public function notice(): ResponseInterface + // { + // $this->getService()->setAction(__FUNCTION__); + // $this->getService()->setFormFields(); + // //전달값정의 + // $this->getService()->setFormDatas($this->request->getGet()); + // $formDatas = $this->getSErvice()->getFormDatas(); + // return $this->response->setJSON($this->getService()->getLatest( + // array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : BOARD['CATEGORY']['NOTICE'], + // )); + // } + // public function reqeusttask(): ResponseInterface + // { + // $this->getService()->setAction(__FUNCTION__); + // $this->getService()->setFormFields(); + // //전달값정의 + // $this->getService()->setFormDatas($this->request->getGet()); + // $formDatas = $this->getSErvice()->getFormDatas(); + // return $this->response->setJSON($this->getService()->getLatest( + // array_key_exists('category', $formDatas) && $formDatas['category'] ? $formDatas['category'] : BOARD['CATEGORY']['NOTICE'], + // ['worker_uid' => $this->getMyAuth()->getUIDByAuthInfo()] + // )); + // } +} diff --git a/app/Controllers/Admin/Customer/AccountController.php b/app/Controllers/Admin/Customer/AccountController.php index a125c6b..f24f4c8 100644 --- a/app/Controllers/Admin/Customer/AccountController.php +++ b/app/Controllers/Admin/Customer/AccountController.php @@ -3,13 +3,9 @@ namespace App\Controllers\Admin\Customer; use App\Entities\Customer\AccountEntity; -use CodeIgniter\HTTP\DownloadResponse; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Exceptions\ValidationException; use Psr\Log\LoggerInterface; -use RuntimeException; class AccountController extends CustomerController { @@ -68,163 +64,9 @@ class AccountController extends CustomerController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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 AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - 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 AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - $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 AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - $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 AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - 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 AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - $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()); - } + return AccountEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index 31f0292..64a0238 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -3,13 +3,9 @@ namespace App\Controllers\Admin\Customer; use App\Entities\Customer\ClientEntity; -use CodeIgniter\HTTP\DownloadResponse; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Exceptions\ValidationException; use Psr\Log\LoggerInterface; -use RuntimeException; class ClientController extends CustomerController { @@ -77,163 +73,9 @@ class ClientController extends CustomerController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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 ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - 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 ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - $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 ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - $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 ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - 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 ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - $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()); - } + return ClientEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Customer/CouponController.php b/app/Controllers/Admin/Customer/CouponController.php index 18ad5e5..a4a26e5 100644 --- a/app/Controllers/Admin/Customer/CouponController.php +++ b/app/Controllers/Admin/Customer/CouponController.php @@ -3,13 +3,9 @@ namespace App\Controllers\Admin\Customer; use App\Entities\Customer\CouponEntity; -use CodeIgniter\HTTP\DownloadResponse; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Exceptions\ValidationException; use Psr\Log\LoggerInterface; -use RuntimeException; class CouponController extends CustomerController { @@ -21,6 +17,10 @@ class CouponController extends CustomerController } $this->addActionPaths('coupon'); } + protected function getEntityClass(): string + { + return CouponEntity::class; + } protected function action_init_process(string $action): void { $fields = [ @@ -64,164 +64,6 @@ class CouponController extends CustomerController // $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 index bc16db2..70c9459 100644 --- a/app/Controllers/Admin/Customer/PointController.php +++ b/app/Controllers/Admin/Customer/PointController.php @@ -3,13 +3,9 @@ namespace App\Controllers\Admin\Customer; use App\Entities\Customer\PointEntity; -use CodeIgniter\HTTP\DownloadResponse; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Exceptions\ValidationException; use Psr\Log\LoggerInterface; -use RuntimeException; class PointController extends CustomerController { @@ -64,163 +60,9 @@ class PointController extends CustomerController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return PointEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php new file mode 100644 index 0000000..18b7c09 --- /dev/null +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -0,0 +1,98 @@ +service === null) { + $this->service = service('customer_serviceservice'); + } + $this->addActionPaths('service'); + } + protected function action_init_process(string $action): void + { + $fields = [ + "site", + "location", + "clientinfo_uid", + 'serverinfo_uid', + "rack", + "line", + "title", + "start_at", + "billing_at", + "status", + 'sale', + 'amount', + "history", + ]; + $filters = [ + 'site', + 'location', + 'clientinfo_uid', + 'serverinfo_uid', + 'user_uid', + 'status', + ]; + $batchjobFilters = [ + 'site', + 'location', + 'clientinfo_uid', + 'status' + ]; + // $actionButtons = ['view' => ICONS['SEARCH']]; + $batchjobButtons = ['batchjob' => '일괄 처리 ',]; + 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 = [ + 'site', + 'location', + 'clientinfo_uid', + 'serverinfo_uid', + 'sale', + 'amount', + 'billing_at', + 'status', + 'start_at', + 'updated_at', + '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); + } + protected function getEntityClass(): string + { + return ServiceEntity::class; + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/Controllers/Admin/Equipment/LineController.php b/app/Controllers/Admin/Equipment/LineController.php index 7211fe8..09cd058 100644 --- a/app/Controllers/Admin/Equipment/LineController.php +++ b/app/Controllers/Admin/Equipment/LineController.php @@ -65,163 +65,9 @@ class LineController extends EquipmentController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return LineEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php index 8166a8d..680b6b5 100644 --- a/app/Controllers/Admin/Equipment/ServerController.php +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -69,163 +69,9 @@ class ServerController extends EquipmentController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return ServerEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Equipment/ServerPartController.php b/app/Controllers/Admin/Equipment/ServerPartController.php index 1a510b3..737c9d3 100644 --- a/app/Controllers/Admin/Equipment/ServerPartController.php +++ b/app/Controllers/Admin/Equipment/ServerPartController.php @@ -71,162 +71,9 @@ class ServerPartController extends EquipmentController parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return ServerPartEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index f44a238..257e1dc 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -2,12 +2,12 @@ namespace App\Controllers\Admin; -use App\Controllers\CommonController; +use App\Controllers\AbstractWebController; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -class Home extends AdminController +class Home extends AbstractWebController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { @@ -19,17 +19,19 @@ class Home extends AdminController $dashboards = []; foreach (service('trafficservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) $dashboards[] = $this->action_render_process( - ['admin', 'traffic'], 'dashboard', - ['entity' => $entity] + [ + 'layout' => 'admin', + 'entity' => $entity + ], + 'traffic' ); return $this->action_render_process( - $this->getActionPaths(), __FUNCTION__, [ 'authContext' => $this->getAuthContext(), 'classPath' => service('trafficservice')->getClassPaths(false), - 'layout' => $this->getLayout(), + 'layout' => 'admin', 'dashboards' => $dashboards ] ); diff --git a/app/Controllers/Admin/MylogController.php b/app/Controllers/Admin/MylogController.php index c291bee..0abfa33 100644 --- a/app/Controllers/Admin/MylogController.php +++ b/app/Controllers/Admin/MylogController.php @@ -51,162 +51,9 @@ class MylogController extends AdminController $this->service->getFormService()->setBatchjobFilters($batchjobFilters); parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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 MylogEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능"); - } - 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 MylogEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능"); - } - $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 MylogEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능"); - } - $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 MylogEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능"); - } - 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 MylogEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 MylogEntity만 가능"); - } - $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()); - } + return MylogEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/CPUController.php b/app/Controllers/Admin/Part/CPUController.php index f629df2..87e8a4e 100644 --- a/app/Controllers/Admin/Part/CPUController.php +++ b/app/Controllers/Admin/Part/CPUController.php @@ -62,163 +62,9 @@ class CPUController extends PartController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return CPUEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/CSController.php b/app/Controllers/Admin/Part/CSController.php index c8cbcbb..d3045f1 100644 --- a/app/Controllers/Admin/Part/CSController.php +++ b/app/Controllers/Admin/Part/CSController.php @@ -89,163 +89,9 @@ class CSController extends PartController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return CSEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/DISKController.php b/app/Controllers/Admin/Part/DISKController.php index a3ff382..e3797bb 100644 --- a/app/Controllers/Admin/Part/DISKController.php +++ b/app/Controllers/Admin/Part/DISKController.php @@ -64,162 +64,9 @@ class DISKController extends PartController parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return DISKEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/IPController.php b/app/Controllers/Admin/Part/IPController.php index 3d48cee..0691238 100644 --- a/app/Controllers/Admin/Part/IPController.php +++ b/app/Controllers/Admin/Part/IPController.php @@ -80,163 +80,9 @@ class IPController extends PartController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return IPEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/RAMController.php b/app/Controllers/Admin/Part/RAMController.php index bfd7417..348d062 100644 --- a/app/Controllers/Admin/Part/RAMController.php +++ b/app/Controllers/Admin/Part/RAMController.php @@ -63,162 +63,9 @@ class RAMController extends PartController parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return RAMEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/SOFTWAREController.php b/app/Controllers/Admin/Part/SOFTWAREController.php index 9db28d5..b38551c 100644 --- a/app/Controllers/Admin/Part/SOFTWAREController.php +++ b/app/Controllers/Admin/Part/SOFTWAREController.php @@ -63,162 +63,9 @@ class SOFTWAREController extends PartController parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return SOFTWAREEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/Part/SWITCHController.php b/app/Controllers/Admin/Part/SWITCHController.php index 75915d6..442c4c7 100644 --- a/app/Controllers/Admin/Part/SWITCHController.php +++ b/app/Controllers/Admin/Part/SWITCHController.php @@ -84,162 +84,9 @@ class SWITCHController extends PartController parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->addViewDatas('formDatas', $this->create_form_process()); - return $this->create_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage()); - } - } - public function create(): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->create_process(); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - return $this->create_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage()); - } - } - public function modify_form($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_form_process($uid); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_form_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage()); - } - } - public function modify($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->modify_process($uid); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->modify_result_process($entity); - } catch (ValidationException $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - } - } - public function delete($uid): RedirectResponse - { - try { - $entity = $this->delete_process($uid); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - return $this->delete_result_process($entity); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - } - } - public function view($uid): string|RedirectResponse - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $entity = $this->view_process($uid); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - $this->addViewDatas('entity', $entity); - return $this->view_result_process($action); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage()); - } - } - public function batchjob(): string|RedirectResponse - { - try { - // 사전작업 및 데이터 추출 초기화 - list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process(); - $this->service->getFormService()->setFormFields($selectedFields); - $this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields); - $this->service->getFormService()->setFormFilters($selectedFields); - $this->service->getFormService()->setFormOptions($selectedFields); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_process($uid, $formDatas); - } catch (ValidationException $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage()); - } - } - - public function batchjob_delete(): string|RedirectResponse - { - try { - $uids = $this->batchjob_delete_pre_process(); - $entities = []; - $errors = []; - foreach ($uids as $uid) { - try { - $entities[] = $this->batchjob_delete_process($uid); - } catch (\Exception $e) { - log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage()); - $errors[] = $e->getMessage(); - } - } - return $this->batchjob_delete_result_process($uids, $entities, $errors); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage()); - } - } - - public function index(): string|ResponseInterface - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - $this->index_process($action); - $this->index_result_process($action); - } catch (\Exception $e) { - session()->setFlashdata('message', $e->getMessage()); - } - return $this->index_result_process($action); - } - - public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string - { - try { - $action = __FUNCTION__; - $this->action_init_process($action); - return $this->download_process($action, $output_type, $uid); - } catch (\Exception $e) { - return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage()); - } + return SWITCHEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/PaymentController.php b/app/Controllers/Admin/PaymentController.php index 4a2a43b..cc29098 100644 --- a/app/Controllers/Admin/PaymentController.php +++ b/app/Controllers/Admin/PaymentController.php @@ -69,162 +69,9 @@ class PaymentController extends AdminController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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()); - } + return PaymentEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 3000ab9..ddbacc4 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -3,13 +3,9 @@ namespace App\Controllers\Admin; use App\Entities\UserEntity; -use CodeIgniter\HTTP\DownloadResponse; -use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; -use CodeIgniter\Validation\Exceptions\ValidationException; use Psr\Log\LoggerInterface; -use RuntimeException; class UserController extends AdminController { @@ -65,162 +61,9 @@ class UserController extends AdminController // $this->service->getFormService()->setBatchjobButtons($batchjobButtons); parent::action_init_process($action); } - public function create_form(): string|RedirectResponse + protected function getEntityClass(): string { - 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 UserEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능"); - } - 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 UserEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능"); - } - $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 UserEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능"); - } - $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 UserEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능"); - } - 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 UserEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 UserEntity만 가능"); - } - $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()); - } + return UserEntity::class; } //기본 함수 작업 //Custom 추가 함수 diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index 24df79d..dd6602d 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -5,6 +5,8 @@ namespace App\Controllers; use App\Entities\CommonEntity; use CodeIgniter\HTTP\DownloadResponse; use CodeIgniter\HTTP\RedirectResponse; +use CodeIgniter\HTTP\ResponseInterface; +use CodeIgniter\Validation\Exceptions\ValidationException; use PhpOffice\PhpSpreadsheet\IOFactory; use PhpOffice\PhpSpreadsheet\Reader\Html; use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf; @@ -15,7 +17,128 @@ use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf; */ abstract class CommonController extends AbstractCRUDController { - // --- 목록 (Index / List) 관련 --- + // --- 일괄 작업 (Batch Job) --- + + protected function batchjob_pre_process(array $postDatas = []): array + { + $postDatas = $this->request->getPost(); + + // 1. postDatas에서 선택된 uids 정보 추출 + $uids = $postDatas['batchjob_uids'] ?? []; + if (empty($uids)) { + throw new \Exception("적용할 리스트을 선택하셔야합니다."); + } + + // 2. 변경할 데이터 추출 및 정리 + unset($postDatas['batchjob_uids'], $postDatas['batchjob_submit']); + + $formDatas = array_filter($postDatas, fn($value) => $value !== "" && $value !== null); + + if (empty($formDatas)) { + throw new \Exception("변경할 조건항목을 선택하셔야합니다."); + } + + // 3. 데이터가 있는 필드 추출 + $selectedFields = array_keys($formDatas); + return array($uids, $selectedFields, $formDatas); + } + + protected function batchjob_process($uid, array $formDatas): CommonEntity + { + // Service 로직 호출 (오버라이드 포인트) + return $this->service->batchjob($uid, $formDatas); + } + + protected function batchjob_result_process(array $uids, array $entities, array $errors): string|RedirectResponse + { + return $this->action_redirect_process('info', sprintf( + "%s에서 %s개 처리완료, %s개 오류, 총:%s개 수정이 완료되었습니다.", + $this->getTitle(), + count($entities), + count($errors), + count($uids) + )); + } + final 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()); + } + } + // --- 일괄 삭제 (Batch Job Delete) --- + + protected function batchjob_delete_pre_process(): array + { + $postDatas = $this->request->getPost(); + $uids = $postDatas['batchjob_uids'] ?? []; + + if (empty($uids)) { + throw new \Exception("삭제할 리스트을 선택하셔야합니다."); + } + // $uids는 배열로 반환 + return $uids; + } + + protected function batchjob_delete_result_process(array $uids, array $entities, array $errors): string|RedirectResponse + { + return $this->action_redirect_process('info', sprintf( + "%s에서 %s개 처리완료, %s개 오류, 총:%s개 일괄삭제가 완료되었습니다.", + $this->getTitle(), + count($entities), + count($errors), + count($uids) + )); + } + + /** + * 단일 삭제 로직을 재사용 (Override 가능) + */ + protected function batchjob_delete_process($uid): CommonEntity + { + return $this->service->delete($uid); + } + final 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()); + } + } + + // --- 목록 (Index / List) 관련 --- /** * 조건절(필터, 검색어, 날짜, 정렬)을 처리합니다. (Override 가능) @@ -95,7 +218,7 @@ abstract class CommonController extends AbstractCRUDController protected function index_result_process(string $action): string { - return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); } /** @@ -133,81 +256,19 @@ abstract class CommonController extends AbstractCRUDController $this->addViewDatas('formDatas', $this->request->getVar() ?? []); } - // --- 일괄 작업 (Batch Job) --- - - protected function batchjob_pre_process(array $postDatas = []): array + final public function index(): string|ResponseInterface { - $postDatas = $this->request->getPost(); - - // 1. postDatas에서 선택된 uids 정보 추출 - $uids = $postDatas['batchjob_uids'] ?? []; - if (empty($uids)) { - throw new \Exception("적용할 리스트을 선택하셔야합니다."); + 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()); } - - // 2. 변경할 데이터 추출 및 정리 - unset($postDatas['batchjob_uids'], $postDatas['batchjob_submit']); - - $formDatas = array_filter($postDatas, fn($value) => $value !== "" && $value !== null); - - if (empty($formDatas)) { - throw new \Exception("변경할 조건항목을 선택하셔야합니다."); - } - - // 3. 데이터가 있는 필드 추출 - $selectedFields = array_keys($formDatas); - return array($uids, $selectedFields, $formDatas); + return $this->index_result_process($action); } - protected function batchjob_process($uid, array $formDatas): CommonEntity - { - // Service 로직 호출 (오버라이드 포인트) - return $this->service->batchjob($uid, $formDatas); - } - - protected function batchjob_result_process(array $uids, array $entities, array $errors): string|RedirectResponse - { - return $this->action_redirect_process('info', sprintf( - "%s에서 %s개 처리완료, %s개 오류, 총:%s개 수정이 완료되었습니다.", - $this->getTitle(), - count($entities), - count($errors), - count($uids) - )); - } - - // --- 일괄 삭제 (Batch Job Delete) --- - - protected function batchjob_delete_pre_process(): array - { - $postDatas = $this->request->getPost(); - $uids = $postDatas['batchjob_uids'] ?? []; - - if (empty($uids)) { - throw new \Exception("삭제할 리스트을 선택하셔야합니다."); - } - // $uids는 배열로 반환 - return $uids; - } - - protected function batchjob_delete_result_process(array $uids, array $entities, array $errors): string|RedirectResponse - { - return $this->action_redirect_process('info', sprintf( - "%s에서 %s개 처리완료, %s개 오류, 총:%s개 일괄삭제가 완료되었습니다.", - $this->getTitle(), - count($entities), - count($errors), - count($uids) - )); - } - - /** - * 단일 삭제 로직을 재사용 (Override 가능) - */ - protected function batchjob_delete_process($uid): CommonEntity - { - return $this->service->delete($uid); - } // --- 문서 다운로드 (Download) --- @@ -242,7 +303,7 @@ abstract class CommonController extends AbstractCRUDController $this->addViewDatas('entities', $this->index_entities_process()); // HTML로 렌더링된 내용을 가져옵니다. - $html = $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas()); + $html = $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); // HTML을 PhpSpreadsheet 객체로 로드합니다. $reader = new Html(); @@ -268,4 +329,14 @@ abstract class CommonController extends AbstractCRUDController } return $this->response->download($full_path, null)->setFileName($file_name); } + final 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()); + } + } } diff --git a/app/DTOs/BoardDTO.php b/app/DTOs/BoardDTO.php new file mode 100644 index 0000000..5f722d2 --- /dev/null +++ b/app/DTOs/BoardDTO.php @@ -0,0 +1,24 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/DTOs/Customer/ServiceDTO.php b/app/DTOs/Customer/ServiceDTO.php new file mode 100644 index 0000000..15f4e98 --- /dev/null +++ b/app/DTOs/Customer/ServiceDTO.php @@ -0,0 +1,37 @@ + $value) { + if (property_exists($this, $key)) { + $this->{$key} = $value; + } + } + } +} diff --git a/app/Forms/BoardForm.php b/app/Forms/BoardForm.php new file mode 100644 index 0000000..2d519d4 --- /dev/null +++ b/app/Forms/BoardForm.php @@ -0,0 +1,63 @@ +getEntities() as $entity) { + $tempOptions[$entity->getPK()] = $entity->getTitle(); + // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; + } + $options['options'] = $tempOptions; + break; + default: + $options = parent::getFormOption($field, $options); + break; + } + return $options; + } +} diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php index fa91b86..a2f3140 100644 --- a/app/Forms/CommonForm.php +++ b/app/Forms/CommonForm.php @@ -187,7 +187,7 @@ abstract class CommonForm $options['options'] = $tempOptions; break; case 'clientinfo_uid': - foreach (service('clientervice')->getEntities() as $entity) { + foreach (service('customer_clientservice')->getEntities() as $entity) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } diff --git a/app/Forms/Customer/ServiceForm.php b/app/Forms/Customer/ServiceForm.php new file mode 100644 index 0000000..a22cdb4 --- /dev/null +++ b/app/Forms/Customer/ServiceForm.php @@ -0,0 +1,66 @@ + [], 'extras' => [], 'atttributes' => []]): array + { + $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; + switch ($field) { + case 'serverinfo_uid': + foreach (service('equipment_serverservice')->getEntities() as $entity) { + $tempOptions[$entity->getPK()] = $entity->getTitle(); + // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; + } + $options['options'] = $tempOptions; + break; + default: + $options = parent::getFormOption($field, $options); + break; + } + return $options; + } +} diff --git a/app/Helpers/BoardHelper.php b/app/Helpers/BoardHelper.php new file mode 100644 index 0000000..6090c32 --- /dev/null +++ b/app/Helpers/BoardHelper.php @@ -0,0 +1,11 @@ +form_dropdown_common($field, $value, $viewDatas, $extras); + break; + case 'serverinfo_uid': + $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; + $attributes = ['data-price' => 'price']; + $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); + break; + case 'amount': + $form = form_input($field, 0, ["readonly" => "readonly", ...$extras]); + break; + default: + $form = parent::getFieldForm($field, $value, $viewDatas, $extras); + break; + } + return $form; + } + public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null + { + switch ($field) { + case 'amount': + case 'sale': + $value = number_format($value) . "원"; + break; + case 'billing_at': + if (array_key_exists('unPaids', $viewDatas)) { + if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) { + $value .= sprintf( + "
", + $viewDatas['entity']->getPK(), + $viewDatas['unPaids'][$viewDatas['entity']->getPK()]['cnt'], + number_format($viewDatas['unPaids'][$viewDatas['entity']->getPK()]['amount']) + ); + } + } + break; + default: + $value = parent::getFieldView($field, $value, $viewDatas, $extras); + break; + } + if (is_array($value)) { + throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다"); + } + return $value; + } + + public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string + { + switch ($action) { + case 'modify': + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + case 'addServer': + $action = form_label( + $label ? $label : ICONS['REBOOT'], + $action, + [ + "data-src" => "/admin/customer/service/addServer/{$viewDatas['entity']->getPK()}", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm", + ...$extras + ] + ); + break; + case 'onetime': + $action = form_label( + $label ? $label : ICONS['ONETIME'], + $action, + [ + "data-src" => "/admin/customer/payment/create?serviceinfo_uid={$viewDatas['entity']->getPK()}", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm form-label-sm", + ...$extras + ] + ); + break; + case 'history': + $action = form_label( + $label ? $label : ICONS['HISTORY'], + $action, + [ + "data-src" => "/admin/customer/service/history?serviceinfo_uid={$viewDatas['entity']->getPK()}&serviceinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup", + "data-bs-toggle" => "modal", + "data-bs-target" => "#modal_action_form", + "class" => "btn btn-sm btn-primary form-label-sm", + ...$extras + ] + ); + break; + default: + $action = parent::getListButton($action, $label, $viewDatas, $extras); + break; + } + return $action; + } +} diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 2b1e268..97d7f0d 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -26,29 +26,4 @@ class BoardModel 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 "category": - case "title": - $rule = "required|trim|string"; - break; - case "user_uid": - $rule = "required|numeric"; - break; - case "worker_uid": - $rule = "permit_empty|numeric"; - break; - case "content": - $rule = "permit_empty|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } } diff --git a/app/Models/Customer/ServiceModel.php b/app/Models/Customer/ServiceModel.php index b07f215..ff86a2a 100644 --- a/app/Models/Customer/ServiceModel.php +++ b/app/Models/Customer/ServiceModel.php @@ -39,46 +39,6 @@ class ServiceModel 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 "serverinfo_uid": - case "amount": - case "rack": - case "line": - $rule = "required|numeric"; - break; - case "sale": - case "payment_uid": - $rule = "permit_empty|numeric"; - break; - case "site": - case "location": - case "status": - $rule = "required|trim|string"; - break; - case "billing_at": - case "start_at": - $rule = "required|valid_date"; - break; - case "end_at": - $rule = "permit_empty|valid_date"; - break; - case 'title': - case "history": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); - break; - } - return $rule; - } //입력전 코드처리 final public function create(array $formDatas): ServiceEntity { diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php new file mode 100644 index 0000000..a8c0341 --- /dev/null +++ b/app/Services/BoardService.php @@ -0,0 +1,110 @@ +addClassPaths('Board'); + } + public function createDTO(array $formDatas): BoardDTO + { + return new BoardDTO($formDatas); + } + public function getFormService(): BoardForm + { + if ($this->_form === null) { + $this->_form = new BoardForm(); + $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(): BoardHelper + { + if ($this->_helper === null) { + $this->_helper = new BoardHelper(); + $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): BoardEntity + { + return $entity; + } + protected function create_process(array $formDatas): BoardEntity + { + return new BoardEntity($formDatas); + } + public function create(object $dto): BoardEntity + { + if (!$dto instanceof BoardDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + return parent::create($dto); + } + protected function modify_process($uid, array $formDatas): BoardEntity + { + return parent::modify_process($uid, $formDatas); + } + public function modify($uid, object $dto): BoardEntity + { + if (!$dto instanceof BoardDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + return parent::modify($uid, $dto); + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 + + //추가기능부분 + //Category별 최근 $limit갯수만큼 게시물 + public function getLatest(string $category, array $where = []): array + { + //관리자정보 + $userEntities = service('userservice')->getEntities(); + $datas = []; + foreach ($this->getEntities(['category' => $category, 'status' => STATUS['AVAILABLE'], ...$where]) as $entity) { + $datas[] = [ + 'title' => "", + 'created_at' => date('Y-m-d H:m', strtotime($entity->getCreatedAT())), + 'user' => $userEntities[$entity->getUserUID()]->getTitle(), + ]; + } + return $datas; + } + //요청업무 게시물 + public function getRequestTaskCount(int $worker_uid): int + { + $where = [ + 'category' => BOARD['CATEGORY']['REQUESTTASK'], + 'worker_uid' => $worker_uid, + 'status' => STATUS['AVAILABLE'], + ]; + return count($this->getEntities($where)); + } +} diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php new file mode 100644 index 0000000..f2fda59 --- /dev/null +++ b/app/Services/Customer/ServiceService.php @@ -0,0 +1,95 @@ +addClassPaths('Service'); + } + public function createDTO(array $formDatas): ServiceDTO + { + return new ServiceDTO($formDatas); + } + public function getFormService(): ServiceForm + { + if ($this->_form === null) { + $this->_form = new ServiceForm(); + $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(): ServiceHelper + { + if ($this->_helper === null) { + $this->_helper = new ServiceHelper(); + $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): ServiceEntity + { + return $entity; + } + protected function create_process(array $formDatas): ServiceEntity + { + return new ServiceEntity($formDatas); + } + public function create(object $dto): ServiceEntity + { + if (!$dto instanceof ServiceDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::create($dto); + if (!$entity instanceof ServiceEntity) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능"); + } + return $entity; + } + protected function modify_process($uid, array $formDatas): ServiceEntity + { + $entity = parent::modify_process($uid, $formDatas); + if (!$entity instanceof ServiceEntity) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능"); + } + return $entity; + } + public function modify($uid, object $dto): ServiceEntity + { + if (!$dto instanceof ServiceDTO) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); + } + $entity = parent::modify($uid, $dto); + if (!$entity instanceof ServiceEntity) { + throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServiceEntity만 가능"); + } + return $entity; + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 +}