diff --git a/app/Controllers/AbstractCRUDController.php b/app/Controllers/AbstractCRUDController.php index 253605b..06db23a 100644 --- a/app/Controllers/AbstractCRUDController.php +++ b/app/Controllers/AbstractCRUDController.php @@ -30,7 +30,7 @@ abstract class AbstractCRUDController extends AbstractWebController return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); } - final public function create_form(): string|RedirectResponse + public function create_form(): string|RedirectResponse { try { $action = __FUNCTION__; diff --git a/app/Controllers/Admin/Equipment/ServerPartController.php b/app/Controllers/Admin/Equipment/ServerPartController.php index 7f502c9..7c8304a 100644 --- a/app/Controllers/Admin/Equipment/ServerPartController.php +++ b/app/Controllers/Admin/Equipment/ServerPartController.php @@ -23,4 +23,19 @@ class ServerPartController extends EquipmentController } //기본 함수 작업 //Custom 추가 함수 + protected function create_form_process(array $formDatas = []): array + { + // Form Default값 설정 (오버라이드 포인트) + $formDatas = parent::create_form_process($formDatas); + $formDatas['serverinfo_uid'] = $this->request->getVar('serverinfo_uid') ?? throw new \Exception("ServerPart는 반드시 서버정보가 필요합니다."); + $formDatas['type'] = $this->request->getVar('type') ?? throw new \Exception("ServerPart는 반드시 파트형식 필요합니다."); + //type : CS,IP이면 월비용 기본처리 + switch ($formDatas['type']) { + case 'CS': + case 'IP': + $formDatas['billing'] = PAYMENT['BILLING']['MONTH']; + break; + } + return $formDatas; + } } diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index ed1c250..4856785 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -146,6 +146,7 @@ abstract class CommonController extends AbstractCRUDController { // Filter조건절 처리 $index_filters = []; + // dd($this->service->getFormService()->getIndexFilters($action)); foreach ($this->service->getFormService()->getIndexFilters($action) as $field) { $value = $this->request->getVar($field) ?? null; if ($value) { diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index c7acb12..59d1b72 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -9,7 +9,6 @@ class BoardEntity extends CommonEntity { const PK = Model::PK; const TITLE = Model::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; diff --git a/app/Entities/Customer/AccountEntity.php b/app/Entities/Customer/AccountEntity.php index 83f13f1..69788a5 100644 --- a/app/Entities/Customer/AccountEntity.php +++ b/app/Entities/Customer/AccountEntity.php @@ -8,7 +8,6 @@ class AccountEntity extends CustomerEntity { const PK = AccountModel::PK; const TITLE = AccountModel::TITLE; - const DEFAULT_STATUS = STATUS['DEPOSIT']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; diff --git a/app/Entities/Customer/ClientEntity.php b/app/Entities/Customer/ClientEntity.php index 15f1207..5715b3e 100644 --- a/app/Entities/Customer/ClientEntity.php +++ b/app/Entities/Customer/ClientEntity.php @@ -8,7 +8,6 @@ class ClientEntity extends CustomerEntity { const PK = ClientModel::PK; const TITLE = ClientModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; diff --git a/app/Entities/Customer/CouponEntity.php b/app/Entities/Customer/CouponEntity.php index cbeb7b8..746e273 100644 --- a/app/Entities/Customer/CouponEntity.php +++ b/app/Entities/Customer/CouponEntity.php @@ -8,7 +8,6 @@ class CouponEntity extends CustomerEntity { const PK = CouponModel::PK; const TITLE = CouponModel::TITLE; - const DEFAULT_STATUS = STATUS['DEPOSIT']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; diff --git a/app/Entities/Customer/PointEntity.php b/app/Entities/Customer/PointEntity.php index f5c98e5..626b47c 100644 --- a/app/Entities/Customer/PointEntity.php +++ b/app/Entities/Customer/PointEntity.php @@ -8,7 +8,6 @@ class PointEntity extends CustomerEntity { const PK = PointModel::PK; const TITLE = PointModel::TITLE; - const DEFAULT_STATUS = STATUS['DEPOSIT']; final public function getUserUID(): int|null { return $this->attributes['user_uid']; diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php index 8b2c2fe..d458f06 100644 --- a/app/Entities/Customer/ServiceEntity.php +++ b/app/Entities/Customer/ServiceEntity.php @@ -8,7 +8,6 @@ class ServiceEntity extends CustomerEntity { const PK = ServiceModel::PK; const TITLE = ServiceModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; diff --git a/app/Entities/Equipment/LineEntity.php b/app/Entities/Equipment/LineEntity.php index 572303c..3f3be70 100644 --- a/app/Entities/Equipment/LineEntity.php +++ b/app/Entities/Equipment/LineEntity.php @@ -8,7 +8,6 @@ class LineEntity extends EquipmentEntity { const PK = LineModel::PK; const TITLE = LineModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; public function getBandwith(): string { return $this->attributes['bandwith']; diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index b7eee61..ca4724d 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -8,7 +8,6 @@ class ServerEntity extends EquipmentEntity { const PK = ServerModel::PK; const TITLE = ServerModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; final public function getClientInfoUID(): int|null { return $this->attributes['clientinfo_uid'] ?? null; diff --git a/app/Entities/Equipment/ServerPartEntity.php b/app/Entities/Equipment/ServerPartEntity.php index 27d60a1..c7d4b3f 100644 --- a/app/Entities/Equipment/ServerPartEntity.php +++ b/app/Entities/Equipment/ServerPartEntity.php @@ -53,9 +53,4 @@ class ServerPartEntity extends EquipmentEntity { return $this->attributes['extra']; } - //리스트에서 상태표시용 - public function getStatus(): string - { - return self::DEFAULT_STATUS; - } } diff --git a/app/Entities/Part/CPUEntity.php b/app/Entities/Part/CPUEntity.php index d83eb1b..c2fb329 100644 --- a/app/Entities/Part/CPUEntity.php +++ b/app/Entities/Part/CPUEntity.php @@ -8,7 +8,6 @@ class CPUEntity extends PartEntity { const PK = CPUModel::PK; const TITLE = CPUModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //기본기능 final public function getUsed(): int { diff --git a/app/Entities/Part/CSEntity.php b/app/Entities/Part/CSEntity.php index cb08d0c..c90f625 100644 --- a/app/Entities/Part/CSEntity.php +++ b/app/Entities/Part/CSEntity.php @@ -8,7 +8,6 @@ class CSEntity extends PartEntity { const PK = CSModel::PK; const TITLE = CSModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //기본기능 public function getIP(): string { diff --git a/app/Entities/Part/DISKEntity.php b/app/Entities/Part/DISKEntity.php index 3530f2f..71ef342 100644 --- a/app/Entities/Part/DISKEntity.php +++ b/app/Entities/Part/DISKEntity.php @@ -8,7 +8,6 @@ class DISKEntity extends PartEntity { const PK = DISKModel::PK; const TITLE = DISKModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //기본기능 final public function getUsed(): int { diff --git a/app/Entities/Part/IPEntity.php b/app/Entities/Part/IPEntity.php index c3173a8..df57edf 100644 --- a/app/Entities/Part/IPEntity.php +++ b/app/Entities/Part/IPEntity.php @@ -8,7 +8,6 @@ class IPEntity extends PartEntity { const PK = IPModel::PK; const TITLE = IPModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; final public function getLineInfoUID(): int|null { return $this->attributes['lineinfo_uid'] ?? null; diff --git a/app/Entities/Part/RAMEntity.php b/app/Entities/Part/RAMEntity.php index 43058bf..7d36257 100644 --- a/app/Entities/Part/RAMEntity.php +++ b/app/Entities/Part/RAMEntity.php @@ -8,7 +8,6 @@ class RAMEntity extends PartEntity { const PK = RAMModel::PK; const TITLE = RAMModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //기본기능 final public function getUsed(): int { diff --git a/app/Entities/Part/SOFTWAREEntity.php b/app/Entities/Part/SOFTWAREEntity.php index 9a0ff26..2d9ec46 100644 --- a/app/Entities/Part/SOFTWAREEntity.php +++ b/app/Entities/Part/SOFTWAREEntity.php @@ -8,7 +8,6 @@ class SOFTWAREEntity extends PartEntity { const PK = SOFTWAREModel::PK; const TITLE = SOFTWAREModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //기본기능 final public function getUsed(): int { diff --git a/app/Entities/Part/SWITCHEntity.php b/app/Entities/Part/SWITCHEntity.php index b18d560..beb334e 100644 --- a/app/Entities/Part/SWITCHEntity.php +++ b/app/Entities/Part/SWITCHEntity.php @@ -8,8 +8,6 @@ class SWITCHEntity extends PartEntity { const PK = SWITCHModel::PK; const TITLE = SWITCHModel::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; - final public function getCode(): string { return $this->attributes['code'] ?? ""; diff --git a/app/Entities/PaymentEntity.php b/app/Entities/PaymentEntity.php index 0a5a589..8f124c9 100644 --- a/app/Entities/PaymentEntity.php +++ b/app/Entities/PaymentEntity.php @@ -9,7 +9,6 @@ class PaymentEntity extends CommonEntity { const PK = PaymentModel::PK; const TITLE = PaymentModel::TITLE; - const DEFAULT_STATUS = STATUS['UNPAID']; final public function getUserUID(): int|null { return $this->attributes['user_uid'] ?? null; @@ -46,7 +45,7 @@ class PaymentEntity extends CommonEntity public function getCountDueAt(): string { $result = ""; - if ($this->getStatus() === self::DEFAULT_STATUS) { + if ($this->getStatus() === STATUS['UNPAID']) { $now = new DateTime(); // 오늘 날짜 $due = new DateTime($this->getBillingAt()); if ($due < $now) { diff --git a/app/Entities/UserSNSEntity.php b/app/Entities/UserSNSEntity.php index 7dbd3c9..48b84e9 100644 --- a/app/Entities/UserSNSEntity.php +++ b/app/Entities/UserSNSEntity.php @@ -9,7 +9,6 @@ class UserSNSEntity extends CommonEntity { const PK = Model::PK; const TITLE = Model::TITLE; - const DEFAULT_STATUS = STATUS['AVAILABLE']; //Common Function public function getParent(): int|null { diff --git a/app/Forms/BoardForm.php b/app/Forms/BoardForm.php index 9e5c5d3..cc57d86 100644 --- a/app/Forms/BoardForm.php +++ b/app/Forms/BoardForm.php @@ -49,7 +49,7 @@ class BoardForm extends CommonForm $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; switch ($field) { case 'worker_uid': - foreach (service('userservice')->getEntities() as $entity) { + foreach (service('userservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php index a7fce30..0983187 100644 --- a/app/Forms/CommonForm.php +++ b/app/Forms/CommonForm.php @@ -188,14 +188,14 @@ abstract class CommonForm $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; switch ($field) { case 'user_uid': - foreach (service('userservice')->getEntities() as $entity) { + foreach (service('userservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } $options['options'] = $tempOptions; break; case 'clientinfo_uid': - foreach (service('customer_clientservice')->getEntities() as $entity) { + foreach (service('customer_clientservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } diff --git a/app/Forms/Equipment/ServerForm.php b/app/Forms/Equipment/ServerForm.php index c100065..86e2f09 100644 --- a/app/Forms/Equipment/ServerForm.php +++ b/app/Forms/Equipment/ServerForm.php @@ -45,4 +45,23 @@ class ServerForm extends EquipmentForm } return $rule; } + public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array + { + $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; + switch ($field) { + case 'serviceinfo_uid': + foreach ( + service('customer_serviceservice')->getEntities(['status' => STATUS['AVAILABLE']]) 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/Equipment/ServerPartForm.php b/app/Forms/Equipment/ServerPartForm.php index d15c1f1..16df1b3 100644 --- a/app/Forms/Equipment/ServerPartForm.php +++ b/app/Forms/Equipment/ServerPartForm.php @@ -2,6 +2,8 @@ namespace App\Forms\Equipment; +use App\Services\CommonService; + class ServerPartForm extends EquipmentForm { public function __construct() @@ -36,19 +38,38 @@ class ServerPartForm extends EquipmentForm } return $rule; } + private function getPartService(string $type): CommonService + { + return service('part_' . strtolower($type) . 'service'); + } public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array { $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; switch ($field) { case 'part_uid': - foreach (service('equipment_serverpartservice')->getEntities() as $entity) { + foreach (SERVERPART['ALL_PARTTYPES'] as $type) { + $partService = $this->getPartService($type); + $tempOptions[$type] = [lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택"]; + foreach ($partService->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { + $tempOptions[$type][$entity->getPK()] = $entity->getTitle(); + // $options['attributes'][$type][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; + } + } + $options['options'] = $tempOptions; + break; + case 'serverinfo_uid': + foreach ( + service('equipment_serverservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity + ) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } $options['options'] = $tempOptions; break; - case 'serverinfo_uid': - foreach (service('equipment_serverservice')->getEntities() as $entity) { + case 'serviceinfo_uid': + foreach ( + service('customer_serviceservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity + ) { $tempOptions[$entity->getPK()] = $entity->getTitle(); // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; } diff --git a/app/Forms/Part/CSForm.php b/app/Forms/Part/CSForm.php index eb171e8..50c7ba2 100644 --- a/app/Forms/Part/CSForm.php +++ b/app/Forms/Part/CSForm.php @@ -31,21 +31,4 @@ class CSForm extends PartForm } return $rule; } - public function getFormOption(string $field, array $options = ['options' => [], '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/Forms/Part/IPForm.php b/app/Forms/Part/IPForm.php index 522f604..a1983ab 100644 --- a/app/Forms/Part/IPForm.php +++ b/app/Forms/Part/IPForm.php @@ -46,13 +46,6 @@ class IPForm extends PartForm // dd($tempOptions); $options['options'] = $tempOptions; break; - 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; diff --git a/app/Forms/Part/PartForm.php b/app/Forms/Part/PartForm.php index 63e43d1..dbc584e 100644 --- a/app/Forms/Part/PartForm.php +++ b/app/Forms/Part/PartForm.php @@ -35,4 +35,28 @@ abstract class PartForm extends CommonForm } return $rule; } + public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array + { + $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; + switch ($field) { + case 'serviceinfo_uid': + foreach (service('customer_serviceservice')->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { + $tempOptions[$entity->getPK()] = $entity->getTitle(); + // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; + } + $options['options'] = $tempOptions; + break; + case 'serverinfo_uid': + foreach (service('equipment_serverservice')->getEntities(['status' => STATUS['AVAILABLE']]) 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/Part/SWITCHForm.php b/app/Forms/Part/SWITCHForm.php index a86d986..5e9b1d7 100644 --- a/app/Forms/Part/SWITCHForm.php +++ b/app/Forms/Part/SWITCHForm.php @@ -20,28 +20,4 @@ class SWITCHForm extends PartForm } return $rule; } - public function getFormOption(string $field, array $options = ['options' => [], 'extras' => [], 'atttributes' => []]): array - { - $tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"]; - switch ($field) { - case 'serviceinfo_uid': - foreach (service('customer_serviceservice')->getEntities() as $entity) { - $tempOptions[$entity->getPK()] = $entity->getTitle(); - // $options['attributes'][$entity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $entity->getRole())]; - } - $options['options'] = $tempOptions; - break; - 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/CommonHelper.php b/app/Helpers/CommonHelper.php index 40d3c6e..45f858e 100644 --- a/app/Helpers/CommonHelper.php +++ b/app/Helpers/CommonHelper.php @@ -122,6 +122,7 @@ abstract class CommonHelper break; case 'status': $forms = []; + // dd($viewDatas['formOptions']); array_shift($viewDatas['formOptions'][$field]['options']); foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) $forms[] = form_radio($field, $key, $key == $value, $extras) . $label; diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index cc02a39..690dbfb 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -78,7 +78,7 @@ class ServiceHelper extends CustomerHelper $label ? $label : ICONS['ONETIME'], $action, [ - "data-src" => "/admin/customer/payment/create?serviceinfo_uid={$viewDatas['entity']->getPK()}", + "data-src" => "/admin/payment/create?serviceinfo_uid={$viewDatas['entity']->getPK()}", "data-bs-toggle" => "modal", "data-bs-target" => "#modal_action_form", "class" => "btn btn-sm form-label-sm", diff --git a/app/Helpers/Equipment/ServerPartHelper.php b/app/Helpers/Equipment/ServerPartHelper.php index 0743f3c..4b7e13a 100644 --- a/app/Helpers/Equipment/ServerPartHelper.php +++ b/app/Helpers/Equipment/ServerPartHelper.php @@ -11,19 +11,23 @@ class ServerPartHelper extends EquipmentHelper public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string { switch ($field) { + case 'billing': + $forms = []; + // dd($viewDatas['formOptions']); + array_shift($viewDatas['formOptions'][$field]['options']); + foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) + $forms[] = form_radio($field, $key, $key == $value, $extras) . $label; + $form = implode(" ", $forms); + break; case 'part_uid': + // dd($viewDatas); + $type = array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getType() : $viewDatas['formDatas']['type']; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['onChange'] = "document.querySelector('input[name=\'title\']').value = this.options[this.selectedIndex].getAttribute('data-title'); document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')"; - // $attributes = ['data-title' => 'title', 'data-price' => 'price']; - $form = form_dropdown($field, $value, $viewDatas, $extras); - break; - case 'extra': - if (array_key_exists('type', $viewDatas['control']['form_datas']) && $viewDatas['control']['form_datas']['type'] === 'DISK') { - $options = ["" => lang("{$viewDatas['class_path']}.label.{$field}") . " 선택", ...lang("{$viewDatas['class_path']}.EXTRA.{$viewDatas['control']['form_datas']['type']}")]; - $form = form_dropdown($field, $options, $value, $extras); - } else { - $form = parent::getFieldForm($field, $value, $viewDatas, $extras);; + if (array_key_exists('extras', $viewDatas['formOptions'][$field])) { + $extras = array_merge($extras, $viewDatas['formOptions'][$field]['extras']); } + $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'][$type], $value, $extras); break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php index a229ddb..0da7954 100644 --- a/app/Services/BoardService.php +++ b/app/Services/BoardService.php @@ -7,7 +7,6 @@ use App\Entities\BoardEntity; use App\Forms\BoardForm; use App\Helpers\BoardHelper; use App\Models\BoardModel; -use RuntimeException; class BoardService extends CommonService { @@ -18,6 +17,10 @@ class BoardService extends CommonService parent::__construct($model); $this->addClassPaths('Board'); } + protected function getDTOClass(): string + { + return BOARDDTO::class; + } public function createDTO(array $formDatas): BoardDTO { return new BoardDTO($formDatas); @@ -121,24 +124,10 @@ class BoardService extends CommonService { 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 조건절 처리 //검색어조건절처리 diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 4bbcfe2..60137e1 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -9,11 +9,16 @@ use CodeIgniter\Database\Exceptions\DatabaseException; use CodeIgniter\Validation\Exceptions\ValidationException; use RuntimeException; +/** + * @template TEntity of CommonEntity + * @template TDto of CommonDTO + */ abstract class CommonService { private array $_classPaths = []; protected $title = null; protected function __construct(protected CommonModel $model) {} + abstract protected function getDTOClass(): string; abstract public function createDTO(array $formDatas): CommonDTO; abstract public function getFormService(): mixed; abstract public function getHelper(): mixed; @@ -59,7 +64,7 @@ abstract class CommonService throw new \Exception($errorMessage, $e->getCode(), $e); } } - final public function getEntities(mixed $where = null, array $columns = ['*']): array + final public function getEntities(?array $where = null, array $columns = ['*']): array { try { $entities = $this->getEntities_process($where, $columns); @@ -158,8 +163,14 @@ abstract class CommonService //생성용 abstract protected function create_process(array $formDatas): CommonEntity; - public function create(object $dto): CommonEntity + final public function create(object $dto): CommonEntity { + //DTO 타입 체크 로직을 일반화 + $dtoClass = $this->getDTOClass(); + if (!$dto instanceof $dtoClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)"); + } + $formDatas = $dto->toArray(); if (!$this->getFormService()->validate($formDatas)) { throw new ValidationException(implode("\n", service('validation')->getErrors())); @@ -201,8 +212,14 @@ abstract class CommonService return $entity; } - public function modify(string|int $uid, object $dto): CommonEntity + final public function modify(string|int $uid, object $dto): CommonEntity { + //DTO 타입 체크 로직을 일반화 + $dtoClass = $this->getDTOClass(); + if (!$dto instanceof $dtoClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)"); + } + $formDatas = $dto->toArray(); if (!$this->getFormService()->validate($formDatas)) { throw new ValidationException(implode("\n", service('validation')->getErrors())); @@ -218,8 +235,14 @@ abstract class CommonService $entity = $this->modify_process($uid, $formDatas); return $entity; } - public function batchjob(string|int $uid, object $dto): CommonEntity + final public function batchjob(string|int $uid, object $dto): CommonEntity { + //DTO 타입 체크 로직을 일반화 + $dtoClass = $this->getDTOClass(); + if (!$dto instanceof $dtoClass) { + throw new RuntimeException(__METHOD__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)"); + } + $formDatas = $dto->toArray(); if (!$this->getFormService()->validate($formDatas)) { throw new ValidationException(implode("\n", service('validation')->getErrors())); diff --git a/app/Services/Customer/AccountService.php b/app/Services/Customer/AccountService.php index ad81825..1bae1af 100644 --- a/app/Services/Customer/AccountService.php +++ b/app/Services/Customer/AccountService.php @@ -18,6 +18,10 @@ class AccountService extends CustomerService parent::__construct($model); $this->addClassPaths('Account'); } + protected function getDTOClass(): string + { + return AccountDTO::class; + } public function createDTO(array $formDatas): AccountDTO { return new AccountDTO($formDatas); @@ -101,17 +105,6 @@ class AccountService extends CustomerService { return new AccountEntity($formDatas); } - public function create(object $dto): AccountEntity - { - if (!$dto instanceof AccountDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): AccountEntity { $entity = parent::modify_process($uid, $formDatas); @@ -120,17 +113,6 @@ class AccountService extends CustomerService } return $entity; } - public function modify($uid, object $dto): AccountEntity - { - if (!$dto instanceof AccountDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof AccountEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 AccountEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index ae2d2dc..558292b 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -18,6 +18,10 @@ class ClientService extends CustomerService parent::__construct($model); $this->addClassPaths('Client'); } + protected function getDTOClass(): string + { + return ClientDTO::class; + } public function createDTO(array $formDatas): ClientDTO { return new ClientDTO($formDatas); @@ -110,17 +114,6 @@ class ClientService extends CustomerService { return new ClientEntity($formDatas); } - public function create(object $dto): ClientEntity - { - if (!$dto instanceof ClientDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): ClientEntity { $entity = parent::modify_process($uid, $formDatas); @@ -129,17 +122,6 @@ class ClientService extends CustomerService } return $entity; } - public function modify($uid, object $dto): ClientEntity - { - if (!$dto instanceof ClientDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof ClientEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ClientEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Customer/CouponService.php b/app/Services/Customer/CouponService.php index 20721ce..14b6f84 100644 --- a/app/Services/Customer/CouponService.php +++ b/app/Services/Customer/CouponService.php @@ -18,6 +18,10 @@ class CouponService extends CustomerService parent::__construct($model); $this->addClassPaths('Coupon'); } + protected function getDTOClass(): string + { + return CouponDTO::class; + } public function createDTO(array $formDatas): CouponDTO { return new CouponDTO($formDatas); @@ -95,17 +99,6 @@ class CouponService extends CustomerService { return new CouponEntity($formDatas); } - public function create(object $dto): CouponEntity - { - if (!$dto instanceof CouponDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof CouponEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): CouponEntity { $entity = parent::modify_process($uid, $formDatas); @@ -114,17 +107,6 @@ class CouponService extends CustomerService } return $entity; } - public function modify($uid, object $dto): CouponEntity - { - if (!$dto instanceof CouponDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof CouponEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CouponEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Customer/PointService.php b/app/Services/Customer/PointService.php index 6e11290..b0631ce 100644 --- a/app/Services/Customer/PointService.php +++ b/app/Services/Customer/PointService.php @@ -18,6 +18,10 @@ class PointService extends CustomerService parent::__construct($model); $this->addClassPaths('Point'); } + protected function getDTOClass(): string + { + return PointDTO::class; + } public function createDTO(array $formDatas): PointDTO { return new PointDTO($formDatas); @@ -95,17 +99,6 @@ class PointService extends CustomerService { return new PointEntity($formDatas); } - public function create(object $dto): PointEntity - { - if (!$dto instanceof PointDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof PointEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): PointEntity { $entity = parent::modify_process($uid, $formDatas); @@ -114,17 +107,6 @@ class PointService extends CustomerService } return $entity; } - public function modify($uid, object $dto): PointEntity - { - if (!$dto instanceof PointDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof PointEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 PointEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index b3c3f2c..2bded9f 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -20,6 +20,10 @@ class ServiceService extends CustomerService parent::__construct($model); $this->addClassPaths('Service'); } + protected function getDTOClass(): string + { + return ServiceDTO::class; + } public function createDTO(array $formDatas): ServiceDTO { return new ServiceDTO($formDatas); @@ -125,17 +129,6 @@ class ServiceService extends CustomerService { 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); @@ -144,25 +137,14 @@ class ServiceService extends CustomerService } 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 조건절 처리 //검색어조건절처리 //추가 기능 //interval을 기준으로 최근 신규 서비스정보 가져오기 - final public function getNewServiceEntities(int $interval, string $status = ServiceEntity::DEFAULT_STATUS): array + final public function getNewServiceEntities(int $interval, string $status = STATUS['AVAILABLE']): array { - return $this->getEntities(sprintf("start_at >= NOW()-INTERVAL {$interval} DAY AND status = '%s'", $status)); + return $this->getEntities(["start_at >= NOW()-INTERVAL {$interval} DAY" => null, "status" => $status]); } //서비스별 총 금액 final public function getTotalAmounts($where = []): array diff --git a/app/Services/Equipment/LineService.php b/app/Services/Equipment/LineService.php index 70877a7..5e78fbd 100644 --- a/app/Services/Equipment/LineService.php +++ b/app/Services/Equipment/LineService.php @@ -18,6 +18,10 @@ class LineService extends EquipmentService parent::__construct($model); $this->addClassPaths('Line'); } + protected function getDTOClass(): string + { + return LineDTO::class; + } public function createDTO(array $formDatas): LineDTO { return new LineDTO($formDatas); @@ -96,17 +100,6 @@ class LineService extends EquipmentService { return new LineEntity($formDatas); } - public function create(object $dto): LineEntity - { - if (!$dto instanceof LineDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof LineEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): LineEntity { $entity = parent::modify_process($uid, $formDatas); @@ -115,17 +108,6 @@ class LineService extends EquipmentService } return $entity; } - public function modify($uid, object $dto): LineEntity - { - if (!$dto instanceof LineDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof LineEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index df1b9e6..21c8d03 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -3,10 +3,12 @@ namespace App\Services\Equipment; use App\DTOs\Equipment\ServerPartDTO; +use App\DTOs\UserDTO; use App\Entities\Equipment\ServerPartEntity; use App\Forms\Equipment\ServerPartForm; use App\Helpers\Equipment\ServerPartHelper; use App\Models\Equipment\ServerPartModel; +use App\Services\CommonService; use RuntimeException; class ServerPartService extends EquipmentService @@ -18,6 +20,10 @@ class ServerPartService extends EquipmentService parent::__construct($model); $this->addClassPaths('ServerPart'); } + protected function getDTOClass(): string + { + return ServerPartDTO::class; + } public function createDTO(array $formDatas): ServerPartDTO { return new ServerPartDTO($formDatas); @@ -57,7 +63,6 @@ class ServerPartService extends EquipmentService "type", "billing", "part_uid", - "title", "cnt", "extra", "amount", @@ -68,21 +73,24 @@ class ServerPartService extends EquipmentService "part_uid", "billing", ]; - $indexFilter = $filters; + $indexFilter = [ + "serverinfo_uid", + "type", + "billing", + ]; $batchjobFilters = ['billing', 'type']; switch ($action) { case 'create': case 'create_form': case 'modify': case 'modify_form': - $fields = [...$fields, 'status']; break; case 'view': - $fields = [...$fields, 'status', 'created_at']; + $fields = [...$fields, 'created_at']; break; case 'index': case 'download': - $fields = [...$fields, 'status', 'created_at']; + $fields = [...$fields, 'created_at']; break; } $this->getFormService()->setFormFields($fields); @@ -93,44 +101,38 @@ class ServerPartService extends EquipmentService $this->getFormService()->setBatchjobFilters($batchjobFilters); } //기본 기능부분 + private function getPartService(string $type): CommonService + { + return service('part_' . strtolower($type) . 'service'); + } protected function getEntity_process(mixed $entity): ServerPartEntity { return $entity; } protected function create_process(array $formDatas): ServerPartEntity { + if (!array_key_exists('title', $formDatas)) { + if (!array_key_exists('type', $formDatas)) { + throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다."); + } + $formDatas['title'] = $this->getPartService($formDatas['type']->getTitle()); + } return new ServerPartEntity($formDatas); } - public function create(object $dto): ServerPartEntity - { - if (!$dto instanceof ServerPartDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof ServerPartEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): ServerPartEntity { + if (!array_key_exists('title', $formDatas)) { + if (!array_key_exists('type', $formDatas)) { + throw new \Exception(__METHOD__ . "에서 오류발생:부품형식이 지정되지 않았습니다."); + } + $formDatas['title'] = $this->getPartService($formDatas['type']->getTitle()); + } $entity = parent::modify_process($uid, $formDatas); if (!$entity instanceof ServerPartEntity) { throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); } return $entity; } - public function modify($uid, object $dto): ServerPartEntity - { - if (!$dto instanceof ServerPartDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof ServerPartEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index a3ab100..e2df2ba 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -18,6 +18,10 @@ class ServerService extends EquipmentService parent::__construct($model); $this->addClassPaths('Server'); } + protected function getDTOClass(): string + { + return ServerDTO::class; + } public function createDTO(array $formDatas): ServerDTO { return new ServerDTO($formDatas); @@ -103,17 +107,6 @@ class ServerService extends EquipmentService { return new ServerEntity($formDatas); } - public function create(object $dto): ServerEntity - { - if (!$dto instanceof ServerDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof ServerEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): ServerEntity { $entity = parent::modify_process($uid, $formDatas); @@ -122,17 +115,6 @@ class ServerService extends EquipmentService } return $entity; } - public function modify($uid, object $dto): ServerEntity - { - if (!$dto instanceof ServerDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof ServerEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/MylogService.php b/app/Services/MylogService.php index 52b403c..205829d 100644 --- a/app/Services/MylogService.php +++ b/app/Services/MylogService.php @@ -20,6 +20,10 @@ class MylogService extends CommonService implements PipelineStepInterface parent::__construct($model); $this->addClassPaths('Mylog'); } + protected function getDTOClass(): string + { + return MylogDTO::class; + } public function createDTO(array $formDatas): MylogDTO { return new MylogDTO($formDatas); @@ -111,22 +115,8 @@ class MylogService extends CommonService implements PipelineStepInterface { return new MylogEntity($formDatas); } - public function create(object $dto): MylogEntity - { - if (!$dto instanceof MylogDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::create($dto); - } protected function modify_process($uid, array $formDatas): MyLogEntity { return parent::modify_process($uid, $formDatas); } - public function modify($uid, object $dto): MyLogEntity - { - if (!$dto instanceof MylogDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::modify($uid, $dto); - } } diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php index 39eaa8b..1b0d415 100644 --- a/app/Services/Part/CPUService.php +++ b/app/Services/Part/CPUService.php @@ -18,6 +18,10 @@ class CPUService extends PartService parent::__construct($model); $this->addClassPaths('CPU'); } + protected function getDTOClass(): string + { + return CPUDTO::class; + } public function createDTO(array $formDatas): CPUDTO { return new CPUDTO($formDatas); @@ -93,17 +97,6 @@ class CPUService extends PartService { return new CPUEntity($formDatas); } - public function create(object $dto): CPUEntity - { - if (!$dto instanceof CPUDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof CPUEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): CPUEntity { $entity = parent::modify_process($uid, $formDatas); @@ -112,17 +105,6 @@ class CPUService extends PartService } return $entity; } - public function modify($uid, object $dto): CPUEntity - { - if (!$dto instanceof CPUDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof CPUEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php index edfd376..f2b5564 100644 --- a/app/Services/Part/CSService.php +++ b/app/Services/Part/CSService.php @@ -18,6 +18,10 @@ class CSService extends PartService parent::__construct($model); $this->addClassPaths('CS'); } + protected function getDTOClass(): string + { + return CSDTO::class; + } public function createDTO(array $formDatas): CSDTO { return new CSDTO($formDatas); @@ -120,17 +124,6 @@ class CSService extends PartService { return new CSEntity($formDatas); } - public function create(object $dto): CSEntity - { - if (!$dto instanceof CSDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): CSEntity { $entity = parent::modify_process($uid, $formDatas); @@ -139,18 +132,13 @@ class CSService extends PartService } return $entity; } - public function modify($uid, object $dto): CSEntity - { - if (!$dto instanceof CSDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof CSEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CSEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 + //OrderBy 처리(INET_ATON() 함수를 사용) + public function setOrderBy(mixed $field = null, mixed $value = null): void + { + $this->model->orderBy("INET_ATON(ip) ASC"); + parent::setOrderBy($field, $value); + } } diff --git a/app/Services/Part/DISKService.php b/app/Services/Part/DISKService.php index 7144586..634637e 100644 --- a/app/Services/Part/DISKService.php +++ b/app/Services/Part/DISKService.php @@ -18,6 +18,10 @@ class DISKService extends PartService parent::__construct($model); $this->addClassPaths('DISK'); } + protected function getDTOClass(): string + { + return DISKDTO::class; + } public function createDTO(array $formDatas): DISKDTO { return new DISKDTO($formDatas); @@ -95,17 +99,6 @@ class DISKService extends PartService { return new DISKEntity($formDatas); } - public function create(object $dto): DISKEntity - { - if (!$dto instanceof DISKDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): DISKEntity { $entity = parent::modify_process($uid, $formDatas); @@ -114,17 +107,6 @@ class DISKService extends PartService } return $entity; } - public function modify($uid, object $dto): DISKEntity - { - if (!$dto instanceof DISKDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof DISKEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 DISKEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php index 5236831..cd765f1 100644 --- a/app/Services/Part/IPService.php +++ b/app/Services/Part/IPService.php @@ -18,6 +18,10 @@ class IPService extends PartService parent::__construct($model); $this->addClassPaths('IP'); } + protected function getDTOClass(): string + { + return IPDTO::class; + } public function createDTO(array $formDatas): IPDTO { return new IPDTO($formDatas); @@ -111,17 +115,6 @@ class IPService extends PartService { return new IPEntity($formDatas); } - public function create(object $dto): IPEntity - { - if (!$dto instanceof IPDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): IPEntity { $entity = parent::modify_process($uid, $formDatas); @@ -130,18 +123,13 @@ class IPService extends PartService } return $entity; } - public function modify($uid, object $dto): IPEntity - { - if (!$dto instanceof IPDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof IPEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 IPEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 + //OrderBy 처리(INET_ATON() 함수를 사용) + public function setOrderBy(mixed $field = null, mixed $value = null): void + { + $this->model->orderBy("INET_ATON(ip) ASC"); + parent::setOrderBy($field, $value); + } } diff --git a/app/Services/Part/RAMService.php b/app/Services/Part/RAMService.php index f85085e..cd2c921 100644 --- a/app/Services/Part/RAMService.php +++ b/app/Services/Part/RAMService.php @@ -18,6 +18,10 @@ class RAMService extends PartService parent::__construct($model); $this->addClassPaths('RAM'); } + protected function getDTOClass(): string + { + return RAMDTO::class; + } public function createDTO(array $formDatas): RAMDTO { return new RAMDTO($formDatas); @@ -93,17 +97,6 @@ class RAMService extends PartService { return new RAMEntity($formDatas); } - public function create(object $dto): RAMEntity - { - if (!$dto instanceof RAMDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): RAMEntity { $entity = parent::modify_process($uid, $formDatas); @@ -112,17 +105,6 @@ class RAMService extends PartService } return $entity; } - public function modify($uid, object $dto): RAMEntity - { - if (!$dto instanceof RAMDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof RAMEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 RAMEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Part/SOFTWAREService.php b/app/Services/Part/SOFTWAREService.php index 0dad4c0..6777e6d 100644 --- a/app/Services/Part/SOFTWAREService.php +++ b/app/Services/Part/SOFTWAREService.php @@ -18,6 +18,10 @@ class SOFTWAREService extends PartService parent::__construct($model); $this->addClassPaths('SOFTWARE'); } + protected function getDTOClass(): string + { + return SOFTWAREDTO::class; + } public function createDTO(array $formDatas): SOFTWAREDTO { return new SOFTWAREDTO($formDatas); @@ -93,17 +97,6 @@ class SOFTWAREService extends PartService { return new SOFTWAREEntity($formDatas); } - public function create(object $dto): SOFTWAREEntity - { - if (!$dto instanceof SOFTWAREDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): SOFTWAREEntity { $entity = parent::modify_process($uid, $formDatas); @@ -112,17 +105,6 @@ class SOFTWAREService extends PartService } return $entity; } - public function modify($uid, object $dto): SOFTWAREEntity - { - if (!$dto instanceof SOFTWAREDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof SOFTWAREEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SOFTWAREEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php index 84824ee..fe9c9dc 100644 --- a/app/Services/Part/SWITCHService.php +++ b/app/Services/Part/SWITCHService.php @@ -18,6 +18,10 @@ class SWITCHService extends PartService parent::__construct($model); $this->addClassPaths('SWITCH'); } + protected function getDTOClass(): string + { + return SWITCHDTO::class; + } public function createDTO(array $formDatas): SWITCHDTO { return new SWITCHDTO($formDatas); @@ -112,17 +116,6 @@ class SWITCHService extends PartService { return new SWITCHEntity($formDatas); } - public function create(object $dto): SWITCHEntity - { - if (!$dto instanceof SWITCHDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::create($dto); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - return $entity; - } protected function modify_process($uid, array $formDatas): SWITCHEntity { $entity = parent::modify_process($uid, $formDatas); @@ -131,17 +124,6 @@ class SWITCHService extends PartService } return $entity; } - public function modify($uid, object $dto): SWITCHEntity - { - if (!$dto instanceof SWITCHDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - $entity = parent::modify($uid, $dto); - if (!$entity instanceof SWITCHEntity) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 SWITCHEntity만 가능"); - } - return $entity; - } //List 검색용 //FormFilter 조건절 처리 //검색어조건절처리 diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php index 147c743..17caabe 100644 --- a/app/Services/PaymentService.php +++ b/app/Services/PaymentService.php @@ -18,6 +18,10 @@ class PaymentService extends CommonService parent::__construct($model); $this->addClassPaths('Payment'); } + protected function getDTOClass(): string + { + return PaymentDTO::class; + } public function createDTO(array $formDatas): PaymentDTO { return new PaymentDTO($formDatas); @@ -61,7 +65,7 @@ class PaymentService extends CommonService "content", ]; $filters = ['user_uid', 'clientinfo_uid', 'serviceinfo_uid', 'status', 'billing', 'pay']; - $indexFilter = ['serviceinfo_uid', 'status', 'billing']; + $indexFilter = ['clientinfo_uid', 'serviceinfo_uid', 'status', 'billing']; $batchjobFilters = ['status']; switch ($action) { case 'create': @@ -129,34 +133,12 @@ class PaymentService extends CommonService } protected function create_process(array $formDatas): PaymentEntity { - //confirmpassword 필드는 Entity에 필요없으므로 제거 - if (isset($formDatas['confirmpassword'])) { - unset($formDatas['confirmpassword']); - } return new PaymentEntity($formDatas); } - public function create(object $dto): PaymentEntity - { - if (!$dto instanceof PaymentDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::create($dto); - } protected function modify_process($uid, array $formDatas): PaymentEntity { - //confirmpassword 필드는 Entity에 필요없으므로 제거 - if (isset($formDatas['confirmpassword'])) { - unset($formDatas['confirmpassword']); - } return parent::modify_process($uid, $formDatas); } - public function modify($uid, object $dto): PaymentEntity - { - if (!$dto instanceof PaymentDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::modify($uid, $dto); - } //List 검색용 //FormFilter 조건절 처리 public function setFilter(string $field, mixed $filter_value): void diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 27fb99c..4071ca5 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -18,6 +18,10 @@ class UserService extends CommonService parent::__construct($model); $this->addClassPaths('User'); } + protected function getDTOClass(): string + { + return UserDTO::class; + } public function createDTO(array $formDatas): UserDTO { return new UserDTO($formDatas); @@ -100,13 +104,6 @@ class UserService extends CommonService } return new UserEntity($formDatas); } - public function create(object $dto): UserEntity - { - if (!$dto instanceof UserDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::create($dto); - } protected function modify_process($uid, array $formDatas): UserEntity { //confirmpassword 필드는 Entity에 필요없으므로 제거 @@ -115,13 +112,6 @@ class UserService extends CommonService } return parent::modify_process($uid, $formDatas); } - public function modify($uid, object $dto): UserEntity - { - if (!$dto instanceof UserDTO) { - throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다."); - } - return parent::modify($uid, $dto); - } //List 검색용 //FormFilter 조건절 처리 public function setFilter(string $field, mixed $filter_value): void diff --git a/app/Views/admin/client/detail.php b/app/Views/admin/client/detail.php index feb985c..3dae723 100644 --- a/app/Views/admin/client/detail.php +++ b/app/Views/admin/client/detail.php @@ -38,7 +38,7 @@ "[청구서발행]", 'payment_invoice', [ - "data-src" => "/admin/customer/payment?clientinfo_uid=" . $viewDatas['entity']->getPK() . "&ActionTemplate=popup", + "data-src" => "/admin/payment?clientinfo_uid=" . $viewDatas['entity']->getPK() . "&ActionTemplate=popup", "data-bs-toggle" => "modal", "data-bs-target" => "#modal_action_form", "class" => "text-primary form-label-sm", @@ -97,7 +97,7 @@ sprintf("총:%s건/%s원", $viewDatas['unPaids'][$viewDatas['entity']->getPK()]['cnt'], number_format($viewDatas['unPaids'][$viewDatas['entity']->getPK()]['amount'])), 'payment_unpaid', [ - "data-src" => "/admin/customer/payment?clientinfo_uid={$viewDatas['entity']->getPK()}&status=unpaid&ActionTemplate=popup", + "data-src" => "/admin/payment?clientinfo_uid={$viewDatas['entity']->getPK()}&status=unpaid&ActionTemplate=popup", "data-bs-toggle" => "modal", "data-bs-target" => "#modal_action_form", "class" => "text-primary form-label-sm",