From 777ea0f2ff3d0951ffa53eee6aad3acdfeddb78a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 3 Feb 2026 15:06:47 +0900 Subject: [PATCH] dbmsv4 init...5 --- app/Entities/Equipment/ServerEntity.php | 6 +++--- app/Services/CommonService.php | 16 ++++++++++------ app/Services/Customer/ClientService.php | 10 +++++----- app/Services/Customer/ServiceService.php | 9 +++++++++ 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index c2e647c..73084aa 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -18,9 +18,9 @@ class ServerEntity extends EquipmentEntity 'code' => '', 'title' => '', 'type' => '', - 'ip' => '', - 'viewer' => '', - 'os' => '', + 'ip' => null, + 'viewer' => null, + 'os' => null, 'price' => 0, 'manufactur_at' => '', 'format_at' => '', diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index 01f1f67..de43a2d 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -250,6 +250,12 @@ abstract class CommonService } } + //Action 작업시 field에따른 Hook처리(각 Service에서 override); + protected function action_process_fieldhook(string $field, $value, array $formDatas): array + { + return $formDatas; + } + //생성용 protected function create_process(array $formDatas): CommonEntity { @@ -257,11 +263,13 @@ abstract class CommonService $actionForm = $this->getActionForm(); if ($actionForm instanceof CommonForm) { $actionForm->action_init_process('create', $formDatas); + foreach ($formDatas as $field => $value) { + $formDatas = $this->action_process_fieldhook($field, $value, $formDatas); + } $actionForm->validate($formDatas); } $entityClass = $this->getEntityClass(); $entity = new $entityClass($formDatas); - // dd($entity); if (!$entity instanceof $entityClass) { throw new RuntimeException("Return Type은 {$entityClass}만 가능"); } @@ -280,10 +288,6 @@ abstract class CommonService } //수정용 - protected function modify_process_fieldhook(string $field, $value, array $formDatas): array - { - return $formDatas; - } protected function modify_process($entity, array $formDatas): CommonEntity { try { @@ -291,7 +295,7 @@ abstract class CommonService if ($actionForm instanceof CommonForm) { $actionForm->action_init_process('modify', $formDatas); foreach ($formDatas as $field => $value) { - $formDatas = $this->modify_process_fieldhook($field, $value, $formDatas); + $formDatas = $this->action_process_fieldhook($field, $value, $formDatas); } $actionForm->validate($formDatas); // ✅ 여기서 검증 } diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php index 0a67550..6b711f9 100644 --- a/app/Services/Customer/ClientService.php +++ b/app/Services/Customer/ClientService.php @@ -47,7 +47,7 @@ class ClientService extends CustomerService parent::setOrderBy($field, $value); } - protected function modify_process_fieldhook(string $field, $value, array $formDatas): array + protected function action_process_fieldhook(string $field, $value, array $formDatas): array { switch ($field) { case 'role': @@ -56,17 +56,17 @@ class ClientService extends CustomerService } elseif (!is_array($value)) { $value = []; } - $value = array_values(array_filter(array_map( fn($v) => trim((string) ($v ?? ''), " \t\n\r\0\x0B\""), $value ))); - $formDatas[$field] = $value; break; - + case "format_at": + $formDatas[$field] = $value === '' ? null : $value; + break; default: - $formDatas = parent::modify_process_fieldhook($field, $value, $formDatas); + $formDatas = parent::action_process_fieldhook($field, $value, $formDatas); break; } return $formDatas; diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index e20ea10..eef42be 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -123,6 +123,9 @@ class ServiceService extends CustomerService } protected function create_process(array $formDatas): ServiceEntity { + if (empty($formDatas['site'])) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 사이트가 지정되지 않았습니다."); + } if (empty($formDatas['serverinfo_uid'])) { throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서버가 지정되지 않았습니다."); } @@ -144,6 +147,12 @@ class ServiceService extends CustomerService } protected function modify_process($entity, array $formDatas): ServiceEntity { + if (empty($formDatas['site'])) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 사이트가 지정되지 않았습니다."); + } + if (empty($formDatas['serverinfo_uid'])) { + throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서버가 지정되지 않았습니다."); + } //변경전 정보 $oldEntity = clone $entity; //수정폼에는 없는 필수항목 지정용(code)