diff --git a/app/Cells/Customer/ServiceCell.php b/app/Cells/Customer/ServiceCell.php index 24ecf58..f50815d 100644 --- a/app/Cells/Customer/ServiceCell.php +++ b/app/Cells/Customer/ServiceCell.php @@ -11,7 +11,7 @@ class ServiceCell extends CustomerCell public function detail(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); //서비스별 미납 Count $unPaids = service('paymentservice')->getUnPaids('serviceinfo_uid', ['clientinfo_uid' => $params['clientinfo_uid']]); //서비스별 서버리스트 diff --git a/app/Cells/Equipment/ServerCell.php b/app/Cells/Equipment/ServerCell.php index c68ef77..9dca791 100644 --- a/app/Cells/Equipment/ServerCell.php +++ b/app/Cells/Equipment/ServerCell.php @@ -59,7 +59,7 @@ class ServerCell extends EquipmentCell } public function detail(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); if (!array_key_exists('serviceEntity', $params)) { return static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스 정보가 정의되지 않았습니다."; } diff --git a/app/Cells/Equipment/ServerPartCell.php b/app/Cells/Equipment/ServerPartCell.php index 363d72d..c0545d3 100644 --- a/app/Cells/Equipment/ServerPartCell.php +++ b/app/Cells/Equipment/ServerPartCell.php @@ -14,7 +14,7 @@ class ServerPartCell extends EquipmentCell public function parttable(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); if (!array_key_exists('serverinfo_uid', $params)) { return "서버정보를 정의하셔야합니다."; } diff --git a/app/Cells/MylogCell.php b/app/Cells/MylogCell.php index 516be9b..935377e 100644 --- a/app/Cells/MylogCell.php +++ b/app/Cells/MylogCell.php @@ -15,7 +15,7 @@ class MylogCell extends CommonCell public function dashboard(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); $this->getService()->setLimit(20); $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return view('cells/mylog/' . $template, [ diff --git a/app/Cells/Part/DISKCell.php b/app/Cells/Part/DISKCell.php index 019086f..f9ed5de 100644 --- a/app/Cells/Part/DISKCell.php +++ b/app/Cells/Part/DISKCell.php @@ -13,7 +13,7 @@ class DISKCell extends PartCell public function stock(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); $template = array_key_exists('template', $params) ? $params['template'] : 'disk_stock'; return view('cells/part/' . $template, [ 'partCellDatas' => [ diff --git a/app/Cells/PaymentCell.php b/app/Cells/PaymentCell.php index 627ae06..5bf2658 100644 --- a/app/Cells/PaymentCell.php +++ b/app/Cells/PaymentCell.php @@ -14,7 +14,7 @@ class PaymentCell extends CommonCell public function detail(array $params): string { - $this->getService()->action_init_process(__FUNCTION__); + $this->getService()->getFormService()->action_init_process(__FUNCTION__); $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid'], 'billing' => PAYMENT['BILLING']['ONETIME'], 'status' => STATUS['UNPAID']]); $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return view('cells/payment/' . $template, [ diff --git a/app/Controllers/Admin/AdminController.php b/app/Controllers/Admin/AdminController.php index 53129aa..1b7a6f8 100644 --- a/app/Controllers/Admin/AdminController.php +++ b/app/Controllers/Admin/AdminController.php @@ -19,11 +19,11 @@ abstract class AdminController extends CommonController } protected function action_init_process(string $action, array $formDatas = []): void { - $this->service->action_init_process($action, $formDatas); parent::action_init_process($action, $formDatas); $this->addViewDatas('layout', $this->layouts); $this->addViewDatas('title', $this->getTitle()); $this->addViewDatas('helper', $this->service->getHelper()); + $this->service->getFormService()->action_init_process($action, $formDatas); $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields()); $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); diff --git a/app/Controllers/Admin/Customer/Wallet/AccountController.php b/app/Controllers/Admin/Customer/Wallet/AccountController.php index 7efd99d..09cbac7 100644 --- a/app/Controllers/Admin/Customer/Wallet/AccountController.php +++ b/app/Controllers/Admin/Customer/Wallet/AccountController.php @@ -2,6 +2,7 @@ namespace App\Controllers\Admin\Customer\Wallet; +use App\Entities\Customer\ClientEntity; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -24,17 +25,17 @@ class AccountController extends WalletController { try { $uid = $this->request->getVar('clientinfo_uid'); - if (!$uid) { - throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 고객정보 번호가 정의되지 않았습니다.."); - } - $clientEntity = service('customer_clientservice')->getEntity($uid); - if (!$clientEntity) { - throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$uid}에 해당하는 고객정보을 찾을수 없습니다."); + $clientEntity = null; + if ($uid) { + $clientEntity = service('customer_clientservice')->getEntity($uid); + if (!$clientEntity) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$uid}에 해당하는 고객정보을 찾을수 없습니다."); + } } $action = __FUNCTION__; $formDatas = []; $formDatas['clientinfo_uid'] = $uid; - $formDatas['alias'] = $clientEntity->getTitle(); + $formDatas['alias'] = $clientEntity instanceof ClientEntity ? $clientEntity->getTitle() : ""; $formDatas['issue_at'] = date('Y-m-d'); $this->action_init_process($action, $formDatas); $this->addViewDatas('formDatas', $formDatas); diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 901f940..4899a32 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -22,10 +22,10 @@ class Home extends AbstractWebController } protected function action_init_process(string $action, array $formDatas = []): void { - $this->service->action_init_process($action, $formDatas); parent::action_init_process($action, $formDatas); $this->addViewDatas('layout', $this->layouts); $this->addViewDatas('helper', $this->service->getHelper()); + $this->service->getFormService()->action_init_process($action, $formDatas); $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields()); $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); diff --git a/app/Controllers/Auth/AuthController.php b/app/Controllers/Auth/AuthController.php index 23f2295..8986d0f 100644 --- a/app/Controllers/Auth/AuthController.php +++ b/app/Controllers/Auth/AuthController.php @@ -21,10 +21,11 @@ abstract class AuthController extends AbstractWebController } protected function action_init_process(string $action, array $formDatas = []): void { - $this->service->action_init_process($action, $formDatas); parent::action_init_process($action, $formDatas); $this->addViewDatas('layout', $this->layouts); $this->addViewDatas('helper', $this->service->getHelper()); + //Fields,Rules,Filters,Options등 초기화 + $this->service->getFormService()->action_init_process($action, $formDatas); $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields()); $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); diff --git a/app/Controllers/Auth/LocalController.php b/app/Controllers/Auth/LocalController.php index 073619f..9d1b913 100644 --- a/app/Controllers/Auth/LocalController.php +++ b/app/Controllers/Auth/LocalController.php @@ -25,7 +25,6 @@ class LocalController extends AuthController //로그인처리 protected function login_process(): UserEntity { - $this->action_init_process('login'); return $this->service->login(new LocalDTO($this->request->getPost())); } protected function logout_process(): void diff --git a/app/DTOs/CommonDTO.php b/app/DTOs/CommonDTO.php index 9a80601..8f25992 100644 --- a/app/DTOs/CommonDTO.php +++ b/app/DTOs/CommonDTO.php @@ -59,7 +59,7 @@ abstract class CommonDTO } } - public function __get(string $name) + public function __get(string $name): mixed { // 1. 속성이 클래스에 실제로 존재하는지 확인 if (property_exists($this, $name)) { diff --git a/app/DTOs/Customer/ClientDTO.php b/app/DTOs/Customer/ClientDTO.php index 2500bd2..22fd413 100644 --- a/app/DTOs/Customer/ClientDTO.php +++ b/app/DTOs/Customer/ClientDTO.php @@ -38,25 +38,24 @@ class ClientDTO extends CommonDTO /** * role 속성을 읽을 때 자동으로 배열로 변환해서 반환 */ - public function __get(string $name) + public function __get(string $name): mixed { // role을 요청했고, 실제 데이터가 문자열로 존재한다면 배열로 변환 - if ($name === 'role') { - if (is_string($this->role)) { - return explode(DEFAULTS["DELIMITER_ROLE"], $this->role); - } - return []; // null이거나 값이 없으면 빈 배열 반환 + switch ($name) { + case 'role': + $value = is_string($this->$name) ? explode(DEFAULTS["DELIMITER_ROLE"], $this->role) : []; + break; + default: + // 부모에게 위임 (혹시 CommonDTO에도 __get이 있다면) + $value = parent::__get($name); + break; } - - // 부모에게 위임 (혹시 CommonDTO에도 __get이 있다면) - // CommonDTO에 __get이 없다면 이 줄은 에러가 날 수 있으므로, - // 보통은 아래처럼 처리하거나 속성을 리턴해야 합니다. - return $this->{$name} ?? null; + return $value; } // role 값을 설정할 때도 배열을 받을 수 있게 하려면 __set도 필요할 수 있습니다. // (선택 사항) - public function setRole(array $roles) + public function setRole(array $roles): void { $this->role = implode(DEFAULTS["DELIMITER_ROLE"], $roles); } diff --git a/app/DTOs/Customer/Wallet/AccountDTO.php b/app/DTOs/Customer/Wallet/AccountDTO.php index 73fd842..89facd3 100644 --- a/app/DTOs/Customer/Wallet/AccountDTO.php +++ b/app/DTOs/Customer/Wallet/AccountDTO.php @@ -12,9 +12,9 @@ class AccountDTO extends CommonDTO public ?string $bank = null; public ?string $title = null; public ?string $alias = null; - public ?string $email = null; public ?string $issue_at = null; public ?int $amount = null; + public ?int $balance = null; public ?string $status = null; public ?string $content = null; diff --git a/app/DTOs/Customer/Wallet/CouponDTO.php b/app/DTOs/Customer/Wallet/CouponDTO.php index bbecc4f..8228909 100644 --- a/app/DTOs/Customer/Wallet/CouponDTO.php +++ b/app/DTOs/Customer/Wallet/CouponDTO.php @@ -11,6 +11,7 @@ class CouponDTO extends CommonDTO public ?int $clientinfo_uid = null; public ?string $title = null; public ?int $amount = null; + public ?int $balance = null; public ?string $status = null; public ?string $content = null; diff --git a/app/DTOs/Customer/Wallet/PointDTO.php b/app/DTOs/Customer/Wallet/PointDTO.php index faf2387..0d16920 100644 --- a/app/DTOs/Customer/Wallet/PointDTO.php +++ b/app/DTOs/Customer/Wallet/PointDTO.php @@ -11,6 +11,7 @@ class PointDTO extends CommonDTO public ?int $clientinfo_uid = null; public ?string $title = null; public ?int $amount = null; + public ?int $balance = null; public ?string $status = null; public ?string $content = null; diff --git a/app/DTOs/UserDTO.php b/app/DTOs/UserDTO.php index 3e4d81a..b784e34 100644 --- a/app/DTOs/UserDTO.php +++ b/app/DTOs/UserDTO.php @@ -31,25 +31,24 @@ class UserDTO extends CommonDTO /** * role 속성을 읽을 때 자동으로 배열로 변환해서 반환 */ - public function __get(string $name) + public function __get(string $name): mixed { // role을 요청했고, 실제 데이터가 문자열로 존재한다면 배열로 변환 - if ($name === 'role') { - if (is_string($this->role)) { - return explode(DEFAULTS["DELIMITER_ROLE"], $this->role); - } - return []; // null이거나 값이 없으면 빈 배열 반환 + switch ($name) { + case 'role': + $value = is_string($this->name) ? explode(DEFAULTS["DELIMITER_ROLE"], $this->role) : []; + break; + default: + // 부모에게 위임 (혹시 CommonDTO에도 __get이 있다면) + $value = parent::__get($name); + break; } - - // 부모에게 위임 (혹시 CommonDTO에도 __get이 있다면) - // CommonDTO에 __get이 없다면 이 줄은 에러가 날 수 있으므로, - // 보통은 아래처럼 처리하거나 속성을 리턴해야 합니다. - return $this->{$name} ?? null; + return $value; } // role 값을 설정할 때도 배열을 받을 수 있게 하려면 __set도 필요할 수 있습니다. // (선택 사항) - public function setRole(array $roles) + public function setRole(array $roles): void { $this->role = implode(DEFAULTS["DELIMITER_ROLE"], $roles); } diff --git a/app/Entities/Customer/ClientEntity.php b/app/Entities/Customer/ClientEntity.php index 49c2aaa..5c464ee 100644 --- a/app/Entities/Customer/ClientEntity.php +++ b/app/Entities/Customer/ClientEntity.php @@ -61,7 +61,7 @@ class ClientEntity extends CustomerEntity return $decodedRole; } // 2-b. JSON이 아니면 CSV로 가정하고 변환 - $parts = explode(',', $role); + $parts = explode(DEFAULTS["DELIMITER_ROLE"], $role); // 각 요소의 불필요한 공백과 따옴표 제거 $cleanedRoles = array_map(fn($item) => trim($item, " \t\n\r\0\x0B\""), $parts); return array_filter($cleanedRoles); diff --git a/app/Entities/UserEntity.php b/app/Entities/UserEntity.php index 4c76b17..fffb15a 100644 --- a/app/Entities/UserEntity.php +++ b/app/Entities/UserEntity.php @@ -44,7 +44,7 @@ class UserEntity extends CommonEntity return $decodedRole; } // 2-b. JSON이 아니면 CSV로 가정하고 변환 - $parts = explode(',', $role); + $parts = explode(DEFAULTS["DELIMITER_ROLE"], $role); // 각 요소의 불필요한 공백과 따옴표 제거 $cleanedRoles = array_map(fn($item) => trim($item, " \t\n\r\0\x0B\""), $parts); return array_filter($cleanedRoles); diff --git a/app/Forms/Auth/GoogleForm.php b/app/Forms/Auth/GoogleForm.php index 4e6d430..330a972 100644 --- a/app/Forms/Auth/GoogleForm.php +++ b/app/Forms/Auth/GoogleForm.php @@ -10,7 +10,21 @@ class GoogleForm extends CommonForm { parent::__construct(); } - + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = ['access_code']; + $filters = []; + switch ($action) { + case 'login': + case 'login_form': + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters); + $this->setBatchjobFilters($filters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Auth/LocalForm.php b/app/Forms/Auth/LocalForm.php index a1a722f..81b4756 100644 --- a/app/Forms/Auth/LocalForm.php +++ b/app/Forms/Auth/LocalForm.php @@ -10,7 +10,21 @@ class LocalForm extends CommonForm { parent::__construct(); } - + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = ['id', 'passwd']; + $filters = []; + switch ($action) { + case 'login': + case 'login_form': + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters); + $this->setBatchjobFilters($filters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/BoardForm.php b/app/Forms/BoardForm.php index fb54a8c..7e1b274 100644 --- a/app/Forms/BoardForm.php +++ b/app/Forms/BoardForm.php @@ -10,18 +10,68 @@ class BoardForm extends CommonForm { parent::__construct(); } - // protected function getValidationRule(string $field, string $rule): array - // { - // switch ($field) { - // case 'role': - // $field = "{$field}.*"; - // break; - // default: - // return parent::getValidationRule($field, $rule); - // // break; - // } - // return array($field, $rule); - // } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + 'category', + 'worker_uid', + 'title', + 'status', + 'content', + ]; + $filters = [ + 'user_uid', + 'worker_uid', + 'category', + 'status', + ]; + $indexFilter = $filters; + $batchjobFilters = ['user_uid', 'category', 'status']; + 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; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php index e646cea..349a1a6 100644 --- a/app/Forms/CommonForm.php +++ b/app/Forms/CommonForm.php @@ -20,6 +20,7 @@ abstract class CommonForm { $this->_validation = service('validation'); } + abstract public function action_init_process(string $action, array $formDatas = []): void; final public function setAttributes(array $attributes): void { $this->_attributes = $attributes; diff --git a/app/Forms/Customer/ClientForm.php b/app/Forms/Customer/ClientForm.php index 5a758fb..3e72ccb 100644 --- a/app/Forms/Customer/ClientForm.php +++ b/app/Forms/Customer/ClientForm.php @@ -8,6 +8,57 @@ class ClientForm extends CustomerForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + 'site', + 'name', + 'email', + 'phone', + 'role', + ]; + $filters = [ + 'site', + 'role', + 'status', + ]; + $indexFilter = $filters; + $batchjobFilters = ['site', 'role', 'status']; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [ + 'site', + 'name', + 'email', + 'phone', + 'role', + 'account_balance', + 'coupon_balance', + 'point_balance', + 'status', + 'created_at', + 'updated_at', + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Customer/ServiceForm.php b/app/Forms/Customer/ServiceForm.php index 712399f..e36d849 100644 --- a/app/Forms/Customer/ServiceForm.php +++ b/app/Forms/Customer/ServiceForm.php @@ -8,6 +8,74 @@ class ServiceForm extends CustomerForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "site", + "location", + "clientinfo_uid", + 'serverinfo_uid', + "rack", + "line", + "title", + "start_at", + "billing_at", + "status", + 'sale', + "history", + ]; + $filters = [ + 'site', + 'location', + "rack", + "line", + 'clientinfo_uid', + 'serverinfo_uid', + 'user_uid', + 'status', + ]; + $indexFilter = $filters; + $batchjobFilters = [ + 'site', + 'location', + 'clientinfo_uid', + 'status' + ]; + 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', + 'created_at' + ]; + break; + case 'alternative_create_form': + $fields = ['serverinfo_uid']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Customer/Wallet/AccountForm.php b/app/Forms/Customer/Wallet/AccountForm.php index a7ca009..b7a3e55 100644 --- a/app/Forms/Customer/Wallet/AccountForm.php +++ b/app/Forms/Customer/Wallet/AccountForm.php @@ -8,27 +8,70 @@ class AccountForm extends WalletForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "clientinfo_uid", + "bank", + "title", + "alias", + "issue_at", + "amount", + "status", + "content" + ]; + $filters = [ + "clientinfo_uid", + "bank", + "status", + ]; + $indexFilter = $filters; + $actionButtons = ['view' => ICONS['SEARCH']]; + $batchjobFilters = ['bank', 'status']; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [ + "clientinfo_uid", + "bank", + "title", + "alias", + "issue_at", + "amount", + "status", + 'created_at', + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setActionButtons($actionButtons); + $this->setBatchjobFilters($batchjobFilters); + } + public function getFormRule(string $action, string $field): string { switch ($field) { - case "user_uid": - case "clientinfo_uid": - case "amount": - case "balance": - $rule = "required|numeric"; - break; case "bank": - case "title": case "alias": - case "status": $rule = "required|trim|string"; break; case "issue_at": $rule = "required|valid_date"; break; - case "content": - $rule = "permit_empty|trim|string"; - break; default: $rule = parent::getFormRule($action, $field); break; diff --git a/app/Forms/Customer/Wallet/CouponForm.php b/app/Forms/Customer/Wallet/CouponForm.php index ee8af15..60249a3 100644 --- a/app/Forms/Customer/Wallet/CouponForm.php +++ b/app/Forms/Customer/Wallet/CouponForm.php @@ -8,24 +8,48 @@ class CouponForm extends WalletForm { parent::__construct(); } - public function getFormRule(string $action, string $field): string + public function action_init_process(string $action, array $formDatas = []): void { - switch ($field) { - case "clientinfo_uid": - case "amount": - $rule = "required|numeric"; + $fields = [ + "clientinfo_uid", + "title", + "amount", + "status", + "content", + ]; + $filters = [ + "clientinfo_uid", + "status", + ]; + $indexFilter = $filters; + $actionButtons = ['view' => ICONS['SEARCH']]; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': break; - case "title": - case "status": - $rule = "required|trim|string"; + case 'view': + $fields = [...$fields, 'created_at']; break; - case "content": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); + case 'index': + case 'download': + $fields = [ + "clientinfo_uid", + "title", + "amount", + "status", + 'created_at' + ]; break; } - return $rule; + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setActionButtons($actionButtons); + $this->setBatchjobFilters($batchjobFilters); } } diff --git a/app/Forms/Customer/Wallet/PointForm.php b/app/Forms/Customer/Wallet/PointForm.php index 724d2e2..745cfa0 100644 --- a/app/Forms/Customer/Wallet/PointForm.php +++ b/app/Forms/Customer/Wallet/PointForm.php @@ -8,24 +8,48 @@ class PointForm extends WalletForm { parent::__construct(); } - public function getFormRule(string $action, string $field): string + public function action_init_process(string $action, array $formDatas = []): void { - switch ($field) { - case "clientinfo_uid": - case "amount": - $rule = "required|numeric"; + $fields = [ + "clientinfo_uid", + "title", + "amount", + "status", + "content", + ]; + $filters = [ + "clientinfo_uid", + "status", + ]; + $indexFilter = $filters; + $actionButtons = ['view' => ICONS['SEARCH']]; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': break; - case "title": - case "status": - $rule = "required|trim|string"; + case 'view': + $fields = [...$fields, 'created_at']; break; - case "content": - $rule = "permit_empty|trim|string"; - break; - default: - $rule = parent::getFormRule($action, $field); + case 'index': + case 'download': + $fields = [ + "clientinfo_uid", + "title", + "amount", + "status", + 'created_at' + ]; break; } - return $rule; + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setActionButtons($actionButtons); + $this->setBatchjobFilters($batchjobFilters); } } diff --git a/app/Forms/Customer/Wallet/WalletForm.php b/app/Forms/Customer/Wallet/WalletForm.php index 2b7319d..1e8b570 100644 --- a/app/Forms/Customer/Wallet/WalletForm.php +++ b/app/Forms/Customer/Wallet/WalletForm.php @@ -10,4 +10,26 @@ abstract class WalletForm extends CustomerForm { parent::__construct(); } + public function getFormRule(string $action, string $field): string + { + switch ($field) { + case "user_uid": + case "clientinfo_uid": + case "amount": + case "balance": + $rule = "required|numeric"; + break; + case "title": + case "status": + $rule = "required|trim|string"; + break; + case "content": + $rule = "permit_empty|trim|string"; + break; + default: + $rule = parent::getFormRule($action, $field); + break; + } + return $rule; + } } diff --git a/app/Forms/Equipment/CHASSISForm.php b/app/Forms/Equipment/CHASSISForm.php index 61b634e..7660a92 100644 --- a/app/Forms/Equipment/CHASSISForm.php +++ b/app/Forms/Equipment/CHASSISForm.php @@ -8,6 +8,40 @@ class CHASSISForm extends EquipmentForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Equipment/LineForm.php b/app/Forms/Equipment/LineForm.php index 83bba11..7375065 100644 --- a/app/Forms/Equipment/LineForm.php +++ b/app/Forms/Equipment/LineForm.php @@ -8,6 +8,43 @@ class LineForm extends EquipmentForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "type", + "title", + "bandwith", + "start_at", + "end_at", + ]; + $filters = [ + "type", + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Equipment/ServerForm.php b/app/Forms/Equipment/ServerForm.php index 2835fe2..480e4c7 100644 --- a/app/Forms/Equipment/ServerForm.php +++ b/app/Forms/Equipment/ServerForm.php @@ -8,6 +8,66 @@ class ServerForm extends EquipmentForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "code", + "type", + "chassisinfo_uid", + "switchinfo_uid", + "ip", + "title", + "os", + "price", + "manufactur_at", + "format_at", + ]; + $filters = [ + "clientinfo_uid", + 'type', + "chassisinfo_uid", + 'switchinfo_uid', + 'ip', + 'os', + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'os', 'status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = ['clientinfo_uid', ...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [ + 'clientinfo_uid', + "code", + "type", + "switchinfo_uid", + "ip", + "title", + "os", + "part", + "price", + "manufactur_at", + "format_at", + 'status', + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Equipment/ServerPartForm.php b/app/Forms/Equipment/ServerPartForm.php index 55bba2c..4157bd9 100644 --- a/app/Forms/Equipment/ServerPartForm.php +++ b/app/Forms/Equipment/ServerPartForm.php @@ -10,6 +10,50 @@ class ServerPartForm extends EquipmentForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "serverinfo_uid", + "type", + "billing", + "part_uid", + "cnt", + "extra", + "amount", + ]; + $filters = [ + "serverinfo_uid", + "type", + "part_uid", + "billing", + ]; + $indexFilter = [ + "serverinfo_uid", + "type", + "billing", + ]; + $batchjobFilters = ['billing', 'type']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + break; + case 'view': + $fields = [...$fields, 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/MylogForm.php b/app/Forms/MylogForm.php index 2cf61dc..b3ac955 100644 --- a/app/Forms/MylogForm.php +++ b/app/Forms/MylogForm.php @@ -10,7 +10,33 @@ class MylogForm extends CommonForm { parent::__construct(); } - + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = ['title', 'content']; + $filters = ['user_uid']; + $indexFilter = $filters; + $batchjobFilters = $filters; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/CPUForm.php b/app/Forms/Part/CPUForm.php index 24314c7..7783239 100644 --- a/app/Forms/Part/CPUForm.php +++ b/app/Forms/Part/CPUForm.php @@ -8,6 +8,40 @@ class CPUForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/CSForm.php b/app/Forms/Part/CSForm.php index 098143b..5b02594 100644 --- a/app/Forms/Part/CSForm.php +++ b/app/Forms/Part/CSForm.php @@ -8,6 +8,67 @@ class CSForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "type", + "ip", + "accountid", + "domain", + "price", + ]; + $filters = [ + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'status' + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [ + ...$fields, + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'ip', + 'accountid', + 'domain', + 'price', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + "clientinfo_uid", + 'serverinfo_uid', + 'type', + 'ip', + 'accountid', + 'domain', + 'price', + 'status', + 'created_at' + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/DISKForm.php b/app/Forms/Part/DISKForm.php index 6eba63f..2fca69b 100644 --- a/app/Forms/Part/DISKForm.php +++ b/app/Forms/Part/DISKForm.php @@ -8,6 +8,41 @@ class DISKForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = [...$fields, "format", 'status']; + break; + case 'view': + $fields = [...$fields, "format", 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, "format", 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/IPForm.php b/app/Forms/Part/IPForm.php index 2770d6f..47de225 100644 --- a/app/Forms/Part/IPForm.php +++ b/app/Forms/Part/IPForm.php @@ -8,6 +8,58 @@ class IPForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "lineinfo_uid", + "ip", + "price", + ]; + $filters = [ + 'old_clientinfo_uid', + 'clientinfo_uid', + 'serverinfo_uid', + "lineinfo_uid", + 'status' + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serverinfo_uid', + 'old_clientinfo_uid', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serverinfo_uid', + 'old_clientinfo_uid', + 'status', + 'created_at' + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/RAMForm.php b/app/Forms/Part/RAMForm.php index 9def8b6..b5ce09e 100644 --- a/app/Forms/Part/RAMForm.php +++ b/app/Forms/Part/RAMForm.php @@ -8,6 +8,40 @@ class RAMForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/SOFTWAREForm.php b/app/Forms/Part/SOFTWAREForm.php index a193b4d..f404877 100644 --- a/app/Forms/Part/SOFTWAREForm.php +++ b/app/Forms/Part/SOFTWAREForm.php @@ -8,6 +8,40 @@ class SOFTWAREForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = [...$fields, 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = [...$fields, 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/Part/SWITCHForm.php b/app/Forms/Part/SWITCHForm.php index 5e9b1d7..0179cc9 100644 --- a/app/Forms/Part/SWITCHForm.php +++ b/app/Forms/Part/SWITCHForm.php @@ -8,6 +8,59 @@ class SWITCHForm extends PartForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "code", + "price", + ]; + $filters = [ + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status' + ]; + $indexFilter = $filters; + $batchjobFilters = ['status',]; + switch ($action) { + case 'create': + case 'create_form': + case 'modify': + case 'modify_form': + $fields = [ + ...$fields, + 'status', + ]; + break; + case 'view': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status', + 'created_at' + ]; + break; + case 'index': + case 'download': + $fields = [ + ...$fields, + 'clientinfo_uid', + 'serviceinfo_uid', + 'serverinfo_uid', + 'status', + 'created_at' + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/PaymentForm.php b/app/Forms/PaymentForm.php index 7b9d972..8a6e470 100644 --- a/app/Forms/PaymentForm.php +++ b/app/Forms/PaymentForm.php @@ -10,6 +10,73 @@ class PaymentForm extends CommonForm { parent::__construct(); } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "serviceinfo_uid", + "title", + "amount", + "billing", + "billing_at", + "pay", + "status", + "content", + ]; + $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; + $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; + $batchjobFilters = ['status']; + $actionButtons = ['paid' => '결제', 'view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']]; + $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + break; + case 'view': + $fields = [ + 'clientinfo_uid', + "serviceinfo_uid", + 'billing', + 'title', + 'amount', + 'billing_at', + 'pay', + 'status', + 'updated_at', + 'countdown', + 'user_uid', + 'created_at', + 'content' + ]; + break; + case 'index': + case 'download': + $fields = [ + 'clientinfo_uid', + "serviceinfo_uid", + 'billing', + 'title', + 'amount', + 'billing_at', + 'pay', + 'updated_at', + 'countdown', + 'user_uid', + 'created_at' + ]; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setActionButtons($actionButtons); + $this->setBatchjobFilters($batchjobFilters); + $this->setBatchjobButtons($batchjobButtons); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Forms/UserForm.php b/app/Forms/UserForm.php index 1229583..2b95bd4 100644 --- a/app/Forms/UserForm.php +++ b/app/Forms/UserForm.php @@ -10,18 +10,43 @@ class UserForm extends CommonForm { parent::__construct(); } - // protected function getValidationRule(string $field, string $rule): array - // { - // switch ($field) { - // case 'role': - // $field = "{$field}.*"; - // break; - // default: - // return parent::getValidationRule($field, $rule); - // // break; - // } - // return array($field, $rule); - // } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + 'id', + 'passwd', + 'confirmpassword', + 'name', + 'email', + 'mobile', + 'role' + ]; + $filters = ['role', 'status']; + $indexFilter = $filters; + $batchjobFilters = ['status']; + switch ($action) { + case 'create': + case 'create_form': + break; + case 'modify': + case 'modify_form': + $fields = [...$fields, 'status']; + break; + case 'view': + $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; + break; + case 'index': + case 'download': + $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; + break; + } + $this->setFormFields($fields); + $this->setFormRules($action, $fields); + $this->setFormFilters($filters); + $this->setFormOptions($action, $filters, $formDatas); + $this->setIndexFilters($indexFilter); + $this->setBatchjobFilters($batchjobFilters); + } public function getFormRule(string $action, string $field): string { switch ($field) { diff --git a/app/Models/Customer/Wallet/CouponModel.php b/app/Models/Customer/Wallet/CouponModel.php index 6bccb0e..2e66516 100644 --- a/app/Models/Customer/Wallet/CouponModel.php +++ b/app/Models/Customer/Wallet/CouponModel.php @@ -19,6 +19,7 @@ class CouponModel extends WalletModel "title", "content", "amount", + "balance", "status", ]; public function __construct() diff --git a/app/Models/Customer/Wallet/PointModel.php b/app/Models/Customer/Wallet/PointModel.php index a10fa8a..f5fac04 100644 --- a/app/Models/Customer/Wallet/PointModel.php +++ b/app/Models/Customer/Wallet/PointModel.php @@ -19,6 +19,7 @@ class PointModel extends WalletModel "title", "content", "amount", + "balance", "status", ]; public function __construct() diff --git a/app/Services/Auth/GoogleService.php b/app/Services/Auth/GoogleService.php index 0b5023f..7daeefe 100644 --- a/app/Services/Auth/GoogleService.php +++ b/app/Services/Auth/GoogleService.php @@ -8,7 +8,6 @@ use App\Forms\Auth\GoogleForm; use App\Libraries\MySocket\GoogleSocket\CURL; use App\Models\UserModel; use CodeIgniter\Exceptions\PageNotFoundException; -use CodeIgniter\Validation\Exceptions\ValidationException; class GoogleService extends AuthService { @@ -40,21 +39,6 @@ class GoogleService extends AuthService } return $this->_form; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = ['access_code']; - $filters = []; - switch ($action) { - case 'login': - case 'login_form': - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters); - $this->getFormService()->setBatchjobFilters($filters); - } protected function getEntity_process(mixed $entity): UserEntity { return $entity; diff --git a/app/Services/Auth/LocalService.php b/app/Services/Auth/LocalService.php index a079475..dcc6a8b 100644 --- a/app/Services/Auth/LocalService.php +++ b/app/Services/Auth/LocalService.php @@ -6,7 +6,6 @@ use App\DTOs\Auth\LocalDTO; use App\Entities\UserEntity; use App\Forms\Auth\LocalForm; use App\Models\UserModel; -use CodeIgniter\Validation\Exceptions\ValidationException; use RuntimeException; class LocalService extends AuthService @@ -39,27 +38,13 @@ class LocalService extends AuthService } return $this->_form; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = ['id', 'passwd']; - $filters = []; - switch ($action) { - case 'login': - case 'login_form': - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters); - $this->getFormService()->setBatchjobFilters($filters); - } protected function getEntity_process(mixed $entity): UserEntity { return $entity; } protected function login_process(array $formDatas): UserEntity { + $this->getFormService()->action_init_process('login', $formDatas); //입력값 검증 $this->getFormService()->validate($formDatas); //로그인 정보확인 diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php index 45552d8..da973ce 100644 --- a/app/Services/BoardService.php +++ b/app/Services/BoardService.php @@ -57,68 +57,6 @@ class BoardService extends CommonService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - 'category', - 'worker_uid', - 'title', - 'status', - 'content', - ]; - $filters = [ - 'user_uid', - 'worker_uid', - 'category', - 'status', - ]; - $indexFilter = $filters; - $batchjobFilters = ['user_uid', 'category', 'status']; - 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; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): BoardEntity { diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 66dec68..dab96bf 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -19,7 +19,6 @@ abstract class CommonService private array $_classPaths = []; protected $title = null; protected function __construct(protected CommonModel $model) {} - abstract public function action_init_process(string $action, array $formDatas = []): void; abstract public function getDTOClass(): string; abstract public function createDTO(array $formDatas): CommonDTO; abstract public function getEntityClass(): string; @@ -177,15 +176,20 @@ abstract class CommonService //생성용 protected function create_process(array $formDatas): CommonEntity { - // 데이터 검증 - $this->getFormService()->validate($formDatas); - // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 - $entityClass = $this->getEntityClass(); - $entity = new $entityClass($formDatas); - if (!$entity instanceof $entityClass) { - throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 {$entityClass}만 가능"); + try { + $this->getFormService()->action_init_process('create', $formDatas); + // 데이터 검증 + $this->getFormService()->validate($formDatas); + // 💡 동적으로 가져온 Entity 클래스 이름으로 instanceof 검사 + $entityClass = $this->getEntityClass(); + $entity = new $entityClass($formDatas); + if (!$entity instanceof $entityClass) { + throw new RuntimeException("Return Type은 {$entityClass}만 가능"); + } + return $this->save_process($entity); + } catch (\Throwable $e) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage() . var_export($entity)); } - return $this->save_process($entity); } final public function create(array $formDatas): CommonEntity { @@ -215,16 +219,20 @@ abstract class CommonService //수정용 protected function modify_process($entity, array $formDatas): CommonEntity { - $fields = array_keys($formDatas); - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules('modify', $fields); - // 데이터 검증 - $this->getFormService()->validate($formDatas); - // 2. 폼 데이터를 엔티티에 병합합니다. (fill() 사용) - $entity->fill($formDatas); - // var_dump($formDatas); - // dd($entity); - return $this->save_process($entity); + try { + $this->getFormService()->action_init_process('modify', $formDatas); + // 2. 사용자 입력값(formDatas)을 Entity에 주입 + // fill()을 사용하면 Entity 내부에서 어떤 값이 변경되었는지(Dirty) 추적 시작 + $entity->fill($formDatas); + if (!$entity->hasChanged()) { + return $entity; + } + // 데이터 검증 + $this->getFormService()->validate($entity->toArray()); + return $this->save_process($entity); + } catch (\Throwable $e) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage() . "\n" . var_export($entity)); + } } final public function modify(string|int $uid, array $formDatas): CommonEntity diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index 453a0d4..c6f9d0c 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -59,57 +59,6 @@ class ClientService extends CustomerService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - 'site', - 'name', - 'email', - 'phone', - 'role', - ]; - $filters = [ - 'site', - 'role', - 'status', - ]; - $indexFilter = $filters; - $batchjobFilters = ['site', 'role', 'status']; - switch ($action) { - case 'create': - case 'create_form': - break; - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [ - 'site', - 'name', - 'email', - 'phone', - 'role', - 'account_balance', - 'coupon_balance', - 'point_balance', - 'status', - 'created_at', - 'updated_at', - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): ClientEntity { diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index c76442a..42c839d 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -60,74 +60,6 @@ class ServiceService extends CustomerService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "site", - "location", - "clientinfo_uid", - 'serverinfo_uid', - "rack", - "line", - "title", - "start_at", - "billing_at", - "status", - 'sale', - "history", - ]; - $filters = [ - 'site', - 'location', - "rack", - "line", - 'clientinfo_uid', - 'serverinfo_uid', - 'user_uid', - 'status', - ]; - $indexFilter = $filters; - $batchjobFilters = [ - 'site', - 'location', - 'clientinfo_uid', - 'status' - ]; - 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', - 'created_at' - ]; - break; - case 'alternative_create_form': - $fields = ['serverinfo_uid']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //추가 기능 //interval을 기준으로 최근 신규 서비스정보 가져오기 final public function getNewServiceEntities(int $interval, string $status = STATUS['AVAILABLE']): array @@ -173,12 +105,21 @@ class ServiceService extends CustomerService return $date->format('Y-m-d'); } // 서비스금액관련처리 - final public function updateAmount(ServiceEntity $entity): ServiceEntity + private function getCalculatedAmount(int $rack_price, int $line_price, int $sale_price, $serverinfo_uid): int { //총 서비스금액 구하기 - $server_amount = service('equipment_serverservice')->getCalculatedAmount($entity->getServerInfoUID()); + $server_amount = service('equipment_serverservice')->getCalculatedAmount($serverinfo_uid); + return (int)$server_amount + $rack_price + $line_price - $sale_price; + } + final public function updateAmount(ServiceEntity $entity): ServiceEntity + { //기본:서버금액(서버비+서버파트(월비용))+상면비+회선비-할인액 - $entity->amount = (int)$server_amount + $entity->getRack() + $entity->getLine() - $entity->getSale(); + $entity->amount = $this->getCalculatedAmount( + $entity->getRack(), + $entity->getLine(), + $entity->getSale(), + $entity->getServerInfoUID() + ); //총 서비스금액 설정 및 저장 if (!$this->model->save($entity)) { // 저장 실패 시 예외 처리 @@ -211,6 +152,8 @@ class ServiceService extends CustomerService { //생성폼에는 없는 필수항목 지정용(code) $formDatas['code'] = $formDatas['site'] . "_s" . uniqid(); + //총서비스금액 + $formDatas['amount'] = $this->getCalculatedAmount($formDatas['rack'], $formDatas['line'], $formDatas['sale'], $formDatas['serverinfo_uid']); //서비스 생성 $entity = parent::create_process($formDatas); if (!$entity instanceof ServiceEntity) { diff --git a/app/Services/Customer/Wallet/AccountService.php b/app/Services/Customer/Wallet/AccountService.php index 1307329..9568582 100644 --- a/app/Services/Customer/Wallet/AccountService.php +++ b/app/Services/Customer/Wallet/AccountService.php @@ -61,59 +61,6 @@ class AccountService extends WalletService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "clientinfo_uid", - "bank", - "title", - "alias", - "issue_at", - "amount", - "status", - "content" - ]; - $filters = [ - "clientinfo_uid", - "bank", - "status", - ]; - $indexFilter = $filters; - $actionButtons = ['view' => ICONS['SEARCH']]; - $batchjobFilters = ['bank', 'status']; - switch ($action) { - case 'create': - case 'create_form': - break; - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'created_at']; - break; - case 'index': - case 'download': - $fields = [ - "clientinfo_uid", - "bank", - "title", - "alias", - "issue_at", - "amount", - "status", - 'created_at', - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setActionButtons($actionButtons); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): AccountEntity { @@ -143,33 +90,37 @@ class AccountService extends WalletService throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 잔액이 0보다 값이 정의 되었습니다."); } //고객 잔액 갱신 - service('customer_clientservice')->modify_process($clientEntity, [self::CLIENTINFO_BALANCE_FIELD => $formDatas['balance']]); + service('customer_clientservice')->modify($clientEntity->getPK(), [self::CLIENTINFO_BALANCE_FIELD => $formDatas['balance']]); return parent::deposit_process($clientEntity, $formDatas); } //결제 관련 출금 처리 protected function withdrawal_process(ClientEntity $clientEntity, array $formDatas): array { - if (!array_key_exists('amount', $formDatas)) { - throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 출금액이 정의되지 않았습니다."); + try { + if (!array_key_exists('amount', $formDatas)) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 출금액이 정의되지 않았습니다."); + } + if ($clientEntity->getAccountBalance() < $formDatas['amount']) { + throw new RuntimeException(sprintf( + "%s 에서 오류발생: 출금액(%s원) , %s 고객의 예치금액(%s원)이 부족합니다.", + static::class . '->' . __FUNCTION__, + number_format($formDatas['amount']), + $clientEntity->getTitle(), + number_format($clientEntity->getAccountBalance()) + )); + } + //최종처리 + $formDatas['bank'] = array_key_exists('bank', $formDatas) ? $formDatas['bank'] : BANKS['결제차감']; + $formDatas['alias'] = array_key_exists('alias', $formDatas) ? $formDatas['alias'] : $clientEntity->getTitle(); + $formDatas['balance'] = $clientEntity->getAccountBalance() - $formDatas['amount']; + if ($formDatas['balance'] < 0) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 잔액({$formDatas['balance']})이 0보다 작은 값이 정의되었습니다."); + } + //고객의 Account Balance수정 + service('customer_clientservice')->modify($clientEntity->getPK(), [self::CLIENTINFO_BALANCE_FIELD => $formDatas['balance']]); + return parent::withdrawal_process($clientEntity, $formDatas); + } catch (\Throwable $e) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage()); } - if ($clientEntity->getAccountBalance() < $formDatas['amount']) { - throw new RuntimeException(sprintf( - "%s 에서 오류발생: 출금액(%s원) , %s 고객의 예치금액(%s원)이 부족합니다.", - static::class . '->' . __FUNCTION__, - number_format($formDatas['amount']), - $clientEntity->getTitle(), - number_format($clientEntity->getAccountBalance()) - )); - } - //최종처리 - $formDatas['bank'] = array_key_exists('bank', $formDatas) ? $formDatas['bank'] : BANKS['결제차감']; - $formDatas['alias'] = array_key_exists('alias', $formDatas) ? $formDatas['alias'] : $clientEntity->getTitle(); - $formDatas['balance'] = $clientEntity->getAccountBalance() - $formDatas['amount']; - if ($formDatas['balance'] < 0) { - throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 잔액({$formDatas['balance']})이 0보다 작은 값이 정의되었습니다."); - } - //고객 잔액 갱신 - service('customer_clientservice')->modify_process($clientEntity, [self::CLIENTINFO_BALANCE_FIELD => $formDatas['balance']]); - return parent::withdrawal_process($clientEntity, $formDatas); } } diff --git a/app/Services/Customer/Wallet/CouponService.php b/app/Services/Customer/Wallet/CouponService.php index 122a7b4..7e9c312 100644 --- a/app/Services/Customer/Wallet/CouponService.php +++ b/app/Services/Customer/Wallet/CouponService.php @@ -61,50 +61,6 @@ class CouponService extends WalletService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "clientinfo_uid", - "title", - "amount", - "status", - "content", - ]; - $filters = [ - "clientinfo_uid", - "status", - ]; - $indexFilter = $filters; - $actionButtons = ['view' => ICONS['SEARCH']]; - $batchjobFilters = ['status']; - 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 = [ - "clientinfo_uid", - "title", - "amount", - "status", - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setActionButtons($actionButtons); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): CouponEntity { diff --git a/app/Services/Customer/Wallet/PointService.php b/app/Services/Customer/Wallet/PointService.php index 908de8d..c0eb987 100644 --- a/app/Services/Customer/Wallet/PointService.php +++ b/app/Services/Customer/Wallet/PointService.php @@ -61,50 +61,6 @@ class PointService extends WalletService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "clientinfo_uid", - "title", - "amount", - "status", - "content", - ]; - $filters = [ - "clientinfo_uid", - "status", - ]; - $indexFilter = $filters; - $actionButtons = ['view' => ICONS['SEARCH']]; - $batchjobFilters = ['status']; - 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 = [ - "clientinfo_uid", - "title", - "amount", - "status", - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setActionButtons($actionButtons); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): PointEntity { diff --git a/app/Services/Customer/Wallet/WalletService.php b/app/Services/Customer/Wallet/WalletService.php index 3e620c7..f4f8432 100644 --- a/app/Services/Customer/Wallet/WalletService.php +++ b/app/Services/Customer/Wallet/WalletService.php @@ -73,8 +73,6 @@ abstract class WalletService extends CustomerService 'amount' => $paymentEntity->getAmount(), 'status' => STATUS['WITHDRAWAL'], ]; - //초기화 - $this->action_init_process('create'); $this->create_process($formDatas); } } diff --git a/app/Services/Equipment/CHASSISService.php b/app/Services/Equipment/CHASSISService.php index 9c6d110..919d0ff 100644 --- a/app/Services/Equipment/CHASSISService.php +++ b/app/Services/Equipment/CHASSISService.php @@ -60,40 +60,6 @@ class CHASSISService extends EquipmentService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "title", - "price", - "stock", - ]; - $filters = [ - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): CHASSISEntity { diff --git a/app/Services/Equipment/LineService.php b/app/Services/Equipment/LineService.php index d407492..b8e87fa 100644 --- a/app/Services/Equipment/LineService.php +++ b/app/Services/Equipment/LineService.php @@ -59,43 +59,6 @@ class LineService extends EquipmentService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "type", - "title", - "bandwith", - "start_at", - "end_at", - ]; - $filters = [ - "type", - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): LineEntity { diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index 955b1a4..adbec35 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -63,50 +63,6 @@ class ServerPartService extends EquipmentService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "serverinfo_uid", - "type", - "billing", - "part_uid", - "cnt", - "extra", - "amount", - ]; - $filters = [ - "serverinfo_uid", - "type", - "part_uid", - "billing", - ]; - $indexFilter = [ - "serverinfo_uid", - "type", - "billing", - ]; - $batchjobFilters = ['billing', 'type']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - break; - case 'view': - $fields = [...$fields, 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //각 파트별 서비스 private function getPartService(string $type): PartService { diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index b8512e9..0e9c426 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -60,66 +60,6 @@ class ServerService extends EquipmentService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "code", - "type", - "chassisinfo_uid", - "switchinfo_uid", - "ip", - "title", - "os", - "price", - "manufactur_at", - "format_at", - ]; - $filters = [ - "clientinfo_uid", - 'type', - "chassisinfo_uid", - 'switchinfo_uid', - 'ip', - 'os', - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'os', 'status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = ['clientinfo_uid', ...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [ - 'clientinfo_uid', - "code", - "type", - "switchinfo_uid", - "ip", - "title", - "os", - "part", - "price", - "manufactur_at", - "format_at", - 'status', - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } final public function getTotalServiceCount(array $where = []): array { $totalCounts = [ diff --git a/app/Services/MylogService.php b/app/Services/MylogService.php index 39deb19..84bcec6 100644 --- a/app/Services/MylogService.php +++ b/app/Services/MylogService.php @@ -45,33 +45,6 @@ class MylogService extends CommonService implements PipelineStepInterface } return $this->_form; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = ['title', 'content']; - $filters = ['user_uid']; - $indexFilter = $filters; - $batchjobFilters = $filters; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } public function getHelper(): MylogHelper { if ($this->_helper === null) { diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php index e347c49..ee94c56 100644 --- a/app/Services/Part/CPUService.php +++ b/app/Services/Part/CPUService.php @@ -59,40 +59,6 @@ class CPUService extends PartType1Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "title", - "price", - "stock", - ]; - $filters = [ - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): CPUEntity { diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php index ebb46c0..9d37a85 100644 --- a/app/Services/Part/CSService.php +++ b/app/Services/Part/CSService.php @@ -60,67 +60,6 @@ class CSService extends PartType2Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "type", - "ip", - "accountid", - "domain", - "price", - ]; - $filters = [ - "clientinfo_uid", - 'serverinfo_uid', - 'type', - 'status' - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [ - ...$fields, - "clientinfo_uid", - 'serverinfo_uid', - 'type', - 'ip', - 'accountid', - 'domain', - 'price', - 'status', - 'created_at' - ]; - break; - case 'index': - case 'download': - $fields = [ - ...$fields, - "clientinfo_uid", - 'serverinfo_uid', - 'type', - 'ip', - 'accountid', - 'domain', - 'price', - 'status', - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): CSEntity { diff --git a/app/Services/Part/DISKService.php b/app/Services/Part/DISKService.php index c88555e..6bc26ab 100644 --- a/app/Services/Part/DISKService.php +++ b/app/Services/Part/DISKService.php @@ -60,42 +60,6 @@ class DISKService extends PartType1Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "title", - "price", - "stock", - ]; - $filters = [ - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - break; - case 'modify': - case 'modify_form': - $fields = [...$fields, "format", 'status']; - break; - case 'view': - $fields = [...$fields, "format", 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, "format", 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } - //기본 기능부분 protected function getEntity_process(mixed $entity): DISKEntity { diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php index 24001aa..7517e11 100644 --- a/app/Services/Part/IPService.php +++ b/app/Services/Part/IPService.php @@ -60,58 +60,6 @@ class IPService extends PartType3Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "lineinfo_uid", - "ip", - "price", - ]; - $filters = [ - 'old_clientinfo_uid', - 'clientinfo_uid', - 'serverinfo_uid', - "lineinfo_uid", - 'status' - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [ - ...$fields, - 'clientinfo_uid', - 'serverinfo_uid', - 'old_clientinfo_uid', - 'status', - 'created_at' - ]; - break; - case 'index': - case 'download': - $fields = [ - ...$fields, - 'clientinfo_uid', - 'serverinfo_uid', - 'old_clientinfo_uid', - 'status', - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): IPEntity { diff --git a/app/Services/Part/RAMService.php b/app/Services/Part/RAMService.php index 44015da..ce3b85e 100644 --- a/app/Services/Part/RAMService.php +++ b/app/Services/Part/RAMService.php @@ -8,7 +8,6 @@ use App\Helpers\Part\RAMHelper; use App\Forms\Part\RAMForm; use App\Entities\Part\RAMEntity; use App\Entities\Equipment\ServerPartEntity; -use App\Entities\CommonEntity; use App\DTOs\Part\RAMDTO; class RAMService extends PartType1Service @@ -60,40 +59,6 @@ class RAMService extends PartType1Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "title", - "price", - "stock", - ]; - $filters = [ - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): RAMEntity { diff --git a/app/Services/Part/SOFTWAREService.php b/app/Services/Part/SOFTWAREService.php index cd41c55..0a568a0 100644 --- a/app/Services/Part/SOFTWAREService.php +++ b/app/Services/Part/SOFTWAREService.php @@ -46,40 +46,6 @@ class SOFTWAREService extends PartType1Service } return $this->_form; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "title", - "price", - "stock", - ]; - $filters = [ - "status", - ]; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = [...$fields, 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = [...$fields, 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } public function getHelper(): SOFTWAREHelper { if ($this->_helper === null) { diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php index 9884ad3..520df72 100644 --- a/app/Services/Part/SWITCHService.php +++ b/app/Services/Part/SWITCHService.php @@ -61,59 +61,6 @@ class SWITCHService extends PartType3Service } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "code", - "price", - ]; - $filters = [ - 'clientinfo_uid', - 'serviceinfo_uid', - 'serverinfo_uid', - 'status' - ]; - $indexFilter = $filters; - $batchjobFilters = ['status',]; - switch ($action) { - case 'create': - case 'create_form': - case 'modify': - case 'modify_form': - $fields = [ - ...$fields, - 'status', - ]; - break; - case 'view': - $fields = [ - ...$fields, - 'clientinfo_uid', - 'serviceinfo_uid', - 'serverinfo_uid', - 'status', - 'created_at' - ]; - break; - case 'index': - case 'download': - $fields = [ - ...$fields, - 'clientinfo_uid', - 'serviceinfo_uid', - 'serverinfo_uid', - 'status', - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): SWITCHEntity { diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 7d9c596..e1904aa 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -65,73 +65,6 @@ class PaymentService extends CommonService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - "serviceinfo_uid", - "title", - "amount", - "billing", - "billing_at", - "pay", - "status", - "content", - ]; - $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; - $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; - $batchjobFilters = ['status']; - $actionButtons = ['paid' => '결제', 'view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']]; - $batchjobButtons = ['batchjob' => '일괄결제', 'invoice' => '청구서발행']; - switch ($action) { - case 'create': - case 'create_form': - break; - case 'modify': - case 'modify_form': - break; - case 'view': - $fields = [ - 'clientinfo_uid', - "serviceinfo_uid", - 'billing', - 'title', - 'amount', - 'billing_at', - 'pay', - 'status', - 'updated_at', - 'countdown', - 'user_uid', - 'created_at', - 'content' - ]; - break; - case 'index': - case 'download': - $fields = [ - 'clientinfo_uid', - "serviceinfo_uid", - 'billing', - 'title', - 'amount', - 'billing_at', - 'pay', - 'updated_at', - 'countdown', - 'user_uid', - 'created_at' - ]; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setActionButtons($actionButtons); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - $this->getFormService()->setBatchjobButtons($batchjobButtons); - } //총 미납건수, 금액 final public function getUnPaids(string $group, array $where = []): array { @@ -357,7 +290,6 @@ class PaymentService extends CommonService throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다."); } $formDatas = $this->getFormDatasFromServerPart($serverPartEntity); - $this->action_init_process('create', $formDatas); return parent::create_process($formDatas); } public function modifyByServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PaymentEntity diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 20a12b1..c5ef152 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -59,43 +59,6 @@ class UserService extends CommonService } return $this->_helper; } - public function action_init_process(string $action, array $formDatas = []): void - { - $fields = [ - 'id', - 'passwd', - 'confirmpassword', - 'name', - 'email', - 'mobile', - 'role' - ]; - $filters = ['role', 'status']; - $indexFilter = $filters; - $batchjobFilters = ['status']; - switch ($action) { - case 'create': - case 'create_form': - break; - case 'modify': - case 'modify_form': - $fields = [...$fields, 'status']; - break; - case 'view': - $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; - break; - case 'index': - case 'download': - $fields = ['id', 'name', 'email', 'mobile', 'role', 'status', 'created_at']; - break; - } - $this->getFormService()->setFormFields($fields); - $this->getFormService()->setFormRules($action, $fields); - $this->getFormService()->setFormFilters($filters); - $this->getFormService()->setFormOptions($action, $filters, $formDatas); - $this->getFormService()->setIndexFilters($indexFilter); - $this->getFormService()->setBatchjobFilters($batchjobFilters); - } //기본 기능부분 protected function getEntity_process(mixed $entity): UserEntity {