diff --git a/app/Controllers/AbstractCRUDController.php b/app/Controllers/AbstractCRUDController.php
index 0e74611..f95e60a 100644
--- a/app/Controllers/AbstractCRUDController.php
+++ b/app/Controllers/AbstractCRUDController.php
@@ -41,15 +41,7 @@ abstract class AbstractCRUDController extends AbstractWebController
}
protected function create_process(array $formDatas): CommonEntity
{
- // POST 데이터를 DTO 객체로 변환
- $dto = $this->service->createDTO($formDatas);
- // dd($dto->toArray());
- //DTO 타입 체크 로직을 일반화
- $dtoClass = $this->service->getDTOClass();
- if (!$dto instanceof $dtoClass) {
- throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
- }
- return $this->service->create($dto->toArray());
+ return $this->service->create($formDatas);
}
protected function create_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
@@ -108,15 +100,7 @@ abstract class AbstractCRUDController extends AbstractWebController
protected function modify_process($uid, array $formDatas): CommonEntity
{
- // POST 데이터를 DTO 객체로 변환
- $formDatas[$this->service->getPKField()] = $uid;
- $dto = $this->service->createDTO($formDatas);
- //DTO 타입 체크 로직을 일반화
- $dtoClass = $this->service->getDTOClass();
- if (!$dto instanceof $dtoClass) {
- throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: " . get_class($dto) . "는 사용할 수 없습니다. ({$dtoClass} 필요)");
- }
- return $this->service->modify($uid, $dto->toArray());
+ return $this->service->modify($uid, $formDatas);
}
protected function modify_result_process($entity, ?string $redirect_url = null): string|RedirectResponse
diff --git a/app/Controllers/Auth/GoogleController.php b/app/Controllers/Auth/GoogleController.php
index a2683e7..fcf9b52 100644
--- a/app/Controllers/Auth/GoogleController.php
+++ b/app/Controllers/Auth/GoogleController.php
@@ -2,7 +2,6 @@
namespace App\Controllers\Auth;
-use App\DTOs\Auth\GoogleDTO;
use App\Entities\UserEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@@ -25,8 +24,7 @@ class GoogleController extends AuthController
//로그인처리
protected function login_process(): UserEntity
{
- //요청 데이터를 DTO 객체로 변환
- return $this->service->login(new GoogleDTO($this->request->getPost()));
+ return $this->service->login($this->request->getPost());
}
protected function logout_process(): void
{
diff --git a/app/Controllers/Auth/LocalController.php b/app/Controllers/Auth/LocalController.php
index 9d1b913..ef675d6 100644
--- a/app/Controllers/Auth/LocalController.php
+++ b/app/Controllers/Auth/LocalController.php
@@ -2,7 +2,6 @@
namespace App\Controllers\Auth;
-use App\DTOs\Auth\LocalDTO;
use App\Entities\UserEntity;
use App\Services\Auth\LocalService;
use CodeIgniter\HTTP\RequestInterface;
@@ -25,7 +24,7 @@ class LocalController extends AuthController
//로그인처리
protected function login_process(): UserEntity
{
- return $this->service->login(new LocalDTO($this->request->getPost()));
+ return $this->service->login($this->request->getPost());
}
protected function logout_process(): void
{
diff --git a/app/DTOs/Auth/AuthDTO.php b/app/DTOs/Auth/AuthDTO.php
deleted file mode 100644
index b0124bb..0000000
--- a/app/DTOs/Auth/AuthDTO.php
+++ /dev/null
@@ -1,13 +0,0 @@
- $value) {
- if (!$reflection->hasProperty($key))
- continue;
-
- $property = $reflection->getProperty($key);
- $type = $property->getType();
- $assignValue = $value;
-
- // *_uid 규칙 처리
- if ($value === '' && preg_match('/_uid$/', $key)) {
- if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
- $this->{$key} = null;
- continue;
- }
- }
-
- // 1) 기존: 빈 문자열('') 처리
- if ($value === '') {
- if ($type instanceof ReflectionNamedType && $type->allowsNull()) {
- $assignValue = null;
- } else {
- $typeName = ($type instanceof ReflectionNamedType) ? $type->getName() : '';
- $assignValue = ($typeName === 'int' || $typeName === 'float') ? 0 : '';
- }
- }
- // 2) 기존: 타입별 캐스팅
- elseif ($type instanceof ReflectionNamedType) {
- $typeName = $type->getName();
-
- if ($typeName === 'array' && is_string($value)) {
- $assignValue = explode(DEFAULTS["DELIMITER_COMMA"], $value);
- } elseif ($typeName === 'int' && is_numeric($value)) {
- $assignValue = (int) $value;
- } elseif ($typeName === 'float' && is_numeric($value)) {
- $assignValue = (float) $value;
- }
- }
-
- $this->{$key} = $assignValue;
- }
- }
-
- public function toArray(): array
- {
- $reflection = new ReflectionClass($this);
- $properties = $reflection->getProperties();
- $result = [];
-
- foreach ($properties as $property) {
- $name = $property->getName();
- $result[$name] = $this->{$name};
- }
-
- return $result;
- }
-}
diff --git a/app/DTOs/Customer/ClientDTO.php b/app/DTOs/Customer/ClientDTO.php
deleted file mode 100644
index 030eaa6..0000000
--- a/app/DTOs/Customer/ClientDTO.php
+++ /dev/null
@@ -1,51 +0,0 @@
-role);
- }
-}
diff --git a/app/DTOs/Customer/ServiceDTO.php b/app/DTOs/Customer/ServiceDTO.php
deleted file mode 100644
index a3b1488..0000000
--- a/app/DTOs/Customer/ServiceDTO.php
+++ /dev/null
@@ -1,31 +0,0 @@
-role);
- }
-}
diff --git a/app/Exceptions/FormValidationException.php b/app/Exceptions/FormValidationException.php
new file mode 100644
index 0000000..6f7c205
--- /dev/null
+++ b/app/Exceptions/FormValidationException.php
@@ -0,0 +1,16 @@
+errors = $errors;
+ parent::__construct($message, $code, $previous);
+ }
+}
diff --git a/app/Forms/Auth/GoogleForm.php b/app/Forms/Auth/GoogleForm.php
index 7ebcb15..dcc7716 100644
--- a/app/Forms/Auth/GoogleForm.php
+++ b/app/Forms/Auth/GoogleForm.php
@@ -12,6 +12,7 @@ class GoogleForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = ['access_code'];
$filters = [];
switch ($action) {
@@ -20,18 +21,18 @@ class GoogleForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters);
+ $this->setFormOptions($filters);
$this->setBatchjobFilters($filters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "access_code":
$formRules[$field] = "required|trim|string";
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Auth/LocalForm.php b/app/Forms/Auth/LocalForm.php
index 9b98078..59108c3 100644
--- a/app/Forms/Auth/LocalForm.php
+++ b/app/Forms/Auth/LocalForm.php
@@ -12,6 +12,7 @@ class LocalForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = ['id', 'passwd'];
$filters = [];
switch ($action) {
@@ -20,22 +21,22 @@ class LocalForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters);
+ $this->setFormOptions($filters);
$this->setBatchjobFilters($filters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "id":
- $formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "passwd":
- $formRules[$field] = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
+ $formRules[$field] = in_array($this->formAction, ["create", "create_form"]) ? "required|trim|string" : "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/BoardForm.php b/app/Forms/BoardForm.php
index 59d274b..8d1da73 100644
--- a/app/Forms/BoardForm.php
+++ b/app/Forms/BoardForm.php
@@ -12,6 +12,7 @@ class BoardForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
'category',
'worker_uid',
@@ -59,13 +60,13 @@ class BoardForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "category":
@@ -82,24 +83,24 @@ class BoardForm extends CommonForm
$formRules[$field] = "permit_empty|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'worker_uid':
- foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/CommonForm.php b/app/Forms/CommonForm.php
index aff5df4..b713e43 100644
--- a/app/Forms/CommonForm.php
+++ b/app/Forms/CommonForm.php
@@ -17,7 +17,6 @@ use RuntimeException;
abstract class CommonForm
{
private $_validation = null;
-
private array $_attributes = [];
private array $_formFields = [];
private array $_formRules = [];
@@ -28,6 +27,8 @@ abstract class CommonForm
private array $_actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
private array $_batchjobButtons = ['batchjob' => '일괄처리', 'batchjob_delete' => '일괄삭제'];
+ protected $formAction = null;
+
protected function __construct()
{
$this->_validation = service('validation');
@@ -35,6 +36,8 @@ abstract class CommonForm
public function action_init_process(string $action, array &$formDatas = []): void
{
+ log_message('debug', static::class . '->' . __FUNCTION__ . "에서 Called...");
+ $this->formAction = $action;
$actionButtons = ['view' => ICONS['SEARCH'], 'delete' => ICONS['DELETE']];
$batchjobButtons = [];
$this->setActionButtons($actionButtons);
@@ -70,10 +73,10 @@ abstract class CommonForm
return array_intersect_key($this->_formFields, array_flip($fields));
}
- public function setFormRules(string $action, array $fields, $formRules = []): void
+ public function setFormRules(array $fields, $formRules = []): void
{
foreach ($fields as $field) {
- $formRules = $this->getFormRule($action, $field, $formRules);
+ $formRules = $this->getFormRule($field, $formRules);
}
$this->_formRules = $formRules;
}
@@ -86,10 +89,10 @@ abstract class CommonForm
return array_intersect_key($this->_formRules, array_flip($fields));
}
- final public function setFormOptions(string $action, array $fields, array $formDatas = [], $formOptions = []): void
+ final public function setFormOptions(array $fields, array $formDatas = [], $formOptions = []): void
{
foreach ($fields as $field) {
- $formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($action, $field, $formDatas);
+ $formOptions[$field] = $formOptions[$field] ?? $this->getFormOption($field, $formDatas);
}
$this->_formOptions = $formOptions;
}
@@ -298,71 +301,89 @@ abstract class CommonForm
*/
final public function validate(array &$formDatas): void
{
- log_message('debug', '>>> CommonForm::validate CALLED: ' . static::class);
- if ($this->_validation === null) {
- throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: Validation 서비스가 초기화되지 않았습니다.");
- }
-
+ log_message('debug', '>>> CommonForm::validate CALLED: ' . static::class . ', formAction:' . $this->formAction);
try {
// 0) 데이터 구조 정리 (null 변환 X)
$formDatas = $this->sanitizeFormDatas($formDatas);
- // 1) 필드 라벨/규칙
- $formFields = $this->getFormFields();
- $formRules = $this->getFormRules();
-
- if (empty($formRules)) {
+ // 1) 전체 라벨/룰
+ $allFormFields = $this->getFormFields(); // ['field' => '라벨', ...]
+ $allFormRules = $this->getFormRules(); // ['field' => 'rules', ...]
+ if (empty($allFormRules)) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 지정된 Form RULE이 없습니다.");
}
- // 2) wildcard(role.*) 부모 배열 보정
+ // 2) 액션별 "검증 대상 필드" 결정
+ if ($this->formAction === 'modify') {
+ // (1) formDatas에 실제로 넘어온 필드만
+ $targetFields = array_keys($formDatas);
+
+ // (2) 내부 제어용 키 제거(프로젝트에 맞게 추가/삭제)
+ $exclude = ['_method', 'csrf_test_name', 'submit', 'token', 'action'];
+ $targetFields = array_values(array_diff($targetFields, $exclude));
+
+ // (3) wildcard(role.*) 같은 규칙이 있으면 부모 기반으로 같이 포함
+ // - formDatas에 role이 있으면 role.* 규칙도 함께 검사되도록 추가
+ foreach ($allFormRules as $ruleField => $_ruleStr) {
+ $ruleField = (string) $ruleField;
+ if (!str_contains($ruleField, '.*')) {
+ continue;
+ }
+ $parent = str_replace('.*', '', $ruleField);
+ if (in_array($parent, $targetFields, true)) {
+ $targetFields[] = $ruleField; // e.g. 'role.*'
+ }
+ }
+
+ // (4) 실제로 룰이 정의된 필드만 남김
+ $targetFields = array_values(array_intersect($targetFields, array_keys($allFormRules)));
+
+ // 최종: modify에서는 "타겟만" 룰/라벨 세팅
+ $formRules = $this->getFormRules($targetFields);
+ $formFields = $this->getFormFields($targetFields);
+ } else {
+ // create (및 기타 액션): 전체 룰 검사
+ $formRules = $allFormRules;
+ $formFields = $allFormFields;
+ }
+
+ if (empty($formRules)) {
+ throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 검증할 대상 RULE이 없습니다.");
+ }
+
+ // 3) wildcard(role.*) 부모 배열 보정
$this->ensureParentArrayForWildcardRules($formDatas, $formRules);
- // 3) numeric(FK 포함) 필드: '' -> null, 숫자 문자열 -> int
- // (규칙 기반 자동 수집)
+ // 4) numeric(FK 포함) 필드: '' -> null, 숫자 문자열 -> int
$numericFields = $this->collectNumericFieldsFromRules($formRules);
$formDatas = $this->normalizeNumericEmptyToNull($formDatas, $numericFields);
- // 4) dynamicRules 누적 구성 (버그 수정: 루프마다 초기화 금지)
+ // 5) dynamicRules 구성
$dynamicRules = [];
foreach ($formRules as $field => $rule) {
- try {
- // 필드명/규칙 추출(확장 포인트)
- [$fieldName, $ruleStr] = $this->getValidationRule((string) $field, (string) $rule);
+ [$fieldName, $ruleStr] = $this->getValidationRule((string) $field, (string) $rule);
- // label 결정
- if (isset($formFields[$fieldName])) {
- $label = $formFields[$fieldName];
- } elseif (str_contains($fieldName, '.*')) {
- $parentField = str_replace('.*', '', $fieldName);
- $label = ($formFields[$parentField] ?? $fieldName) . " 항목";
- } else {
- $label = $fieldName;
- }
-
- $dynamicRules[$fieldName] = [
- 'label' => $label,
- 'rules' => $ruleStr,
- ];
-
- // ❌ 존재 보장으로 '' 삽입하지 않음
- // - required는 CI4가 "키 없음"도 실패 처리 가능(일반적으로)
- // - permit_empty는 키 없어도 통과 (강제로 '' 만들면 FK/숫자 문제 발생)
-
- } catch (\Throwable $e) {
- throw new RuntimeException("유효성 검사 규칙 준비 중 오류 발생 (필드: {$field}): " . $e->getMessage());
+ // label 결정
+ if (isset($formFields[$fieldName])) {
+ $label = $formFields[$fieldName];
+ } elseif (str_contains($fieldName, '.*')) {
+ $parentField = str_replace('.*', '', $fieldName);
+ $label = ($allFormFields[$parentField] ?? $formFields[$parentField] ?? $fieldName) . " 항목";
+ } else {
+ $label = $fieldName;
}
+
+ $dynamicRules[$fieldName] = [
+ 'label' => $label,
+ 'rules' => $ruleStr,
+ ];
}
$this->_validation->setRules($dynamicRules);
- try {
- if (!$this->_validation->run($formDatas)) {
- $errors = $this->_validation->getErrors();
- throw new RuntimeException(implode("\n", $errors));
- }
- } catch (\TypeError $e) {
- throw new RuntimeException("검증 도중 타입 오류 발생: " . $e->getMessage());
+ if (!$this->_validation->run($formDatas)) {
+ $errors = $this->_validation->getErrors();
+ throw new RuntimeException(implode("\n", $errors));
}
} catch (\Throwable $e) {
@@ -398,14 +419,14 @@ abstract class CommonForm
* - permit_empty|numeric 인 FK들이 여기서 정의되면,
* validate()에서 자동으로 ''->null 정규화 대상에 포함됩니다.
*/
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case $this->getAttribute('pk_field'):
if (!$this->getAttribute('useAutoIncrement')) {
$formRules[$field] = sprintf(
"required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]%s",
- in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
+ in_array($this->formAction, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
);
} else {
$formRules[$field] = "required|numeric";
@@ -414,13 +435,13 @@ abstract class CommonForm
case $this->getAttribute('title_field'):
$formRules[$field] = sprintf(
"required|trim|string%s",
- in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
+ in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
);
break;
case "code":
$formRules[$field] = sprintf(
"required|regex_match[/^[a-zA-Z0-9가-힣\-\_]+$/]|min_length[4]%s",
- in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
+ in_array($this->formAction, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : ""
);
break;
case "user_uid":
@@ -449,13 +470,13 @@ abstract class CommonForm
* Options
* --------------------------------------------------------------------- */
- protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
+ protected function getFormOption_process($service, string $field, array $formDatas = []): array
{
$entities = [];
switch ($field) {
default:
- if (in_array($action, ['create_form', 'modify_form', 'alternative_create_form'])) {
+ if (in_array($this->formAction, ['create_form', 'modify_form', 'alternative_create_form'])) {
if (array_key_exists($field, $formDatas)) {
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $this->getAttribute('pk_field'), $formDatas[$field]);
} else {
@@ -471,20 +492,20 @@ abstract class CommonForm
return $entities;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'user_uid':
- foreach ($this->getFormOption_process(service('userservice'), $action, $field, $formDatas) as $entity) {
+ foreach ($this->getFormOption_process(service('userservice'), $field, $formDatas) as $entity) {
$tempOptions[$entity->getPK()] = $entity->getTitle();
}
$options['options'] = $tempOptions;
break;
case 'clientinfo_uid':
- foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $entity) {
+ foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $entity) {
$tempOptions[$entity->getPK()] = $entity->getCustomTitle();
}
$options['options'] = $tempOptions;
diff --git a/app/Forms/Customer/ClientForm.php b/app/Forms/Customer/ClientForm.php
index 92d68c1..6414304 100644
--- a/app/Forms/Customer/ClientForm.php
+++ b/app/Forms/Customer/ClientForm.php
@@ -10,6 +10,7 @@ class ClientForm extends CustomerForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
'site',
'name',
@@ -47,17 +48,17 @@ class ClientForm extends CustomerForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "name":
- $formRules[$field] = sprintf("required|trim|string%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|string%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "site":
$formRules[$field] = "required|trim|string";
@@ -79,7 +80,7 @@ class ClientForm extends CustomerForm
$formRules[$field] = "permit_empty|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Customer/ServiceForm.php b/app/Forms/Customer/ServiceForm.php
index bbf0357..6504486 100644
--- a/app/Forms/Customer/ServiceForm.php
+++ b/app/Forms/Customer/ServiceForm.php
@@ -10,6 +10,7 @@ class ServiceForm extends CustomerForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"site",
"location",
@@ -65,13 +66,13 @@ class ServiceForm extends CustomerForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "clientinfo_uid":
@@ -100,25 +101,25 @@ class ServiceForm extends CustomerForm
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serverinfo_uid':
- foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getCustomTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/Customer/Wallet/AccountForm.php b/app/Forms/Customer/Wallet/AccountForm.php
index acb45a6..ba47a45 100644
--- a/app/Forms/Customer/Wallet/AccountForm.php
+++ b/app/Forms/Customer/Wallet/AccountForm.php
@@ -49,16 +49,16 @@ class AccountForm extends WalletForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "bank":
@@ -69,7 +69,7 @@ class AccountForm extends WalletForm
$formRules[$field] = "required|valid_date";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Customer/Wallet/CouponForm.php b/app/Forms/Customer/Wallet/CouponForm.php
index f69b662..a81f7e0 100644
--- a/app/Forms/Customer/Wallet/CouponForm.php
+++ b/app/Forms/Customer/Wallet/CouponForm.php
@@ -42,9 +42,9 @@ class CouponForm extends WalletForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
diff --git a/app/Forms/Customer/Wallet/PointForm.php b/app/Forms/Customer/Wallet/PointForm.php
index dbb6411..2dcb9fe 100644
--- a/app/Forms/Customer/Wallet/PointForm.php
+++ b/app/Forms/Customer/Wallet/PointForm.php
@@ -42,9 +42,9 @@ class PointForm extends WalletForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
diff --git a/app/Forms/Customer/Wallet/WalletForm.php b/app/Forms/Customer/Wallet/WalletForm.php
index c89365d..4843258 100644
--- a/app/Forms/Customer/Wallet/WalletForm.php
+++ b/app/Forms/Customer/Wallet/WalletForm.php
@@ -10,7 +10,7 @@ abstract class WalletForm extends CustomerForm
{
parent::__construct();
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "user_uid":
@@ -26,7 +26,7 @@ abstract class WalletForm extends CustomerForm
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Equipment/CHASSISForm.php b/app/Forms/Equipment/CHASSISForm.php
index e4b7ee6..e53970e 100644
--- a/app/Forms/Equipment/CHASSISForm.php
+++ b/app/Forms/Equipment/CHASSISForm.php
@@ -10,6 +10,7 @@ class CHASSISForm extends EquipmentForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"title",
"price",
@@ -43,15 +44,15 @@ class CHASSISForm extends EquipmentForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "used":
@@ -68,38 +69,38 @@ class CHASSISForm extends EquipmentForm
$formRules[$field] = "permit_empty|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case "cpuinfo_uid":
- foreach ($this->getFormOption_process(service('part_cpuservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('part_cpuservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case "raminfo_uid":
- foreach ($this->getFormOption_process(service('part_ramservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('part_ramservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case "diskinfo_uid":
- foreach ($this->getFormOption_process(service('part_diskservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('part_diskservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/Equipment/LineForm.php b/app/Forms/Equipment/LineForm.php
index 488f157..747cf04 100644
--- a/app/Forms/Equipment/LineForm.php
+++ b/app/Forms/Equipment/LineForm.php
@@ -10,6 +10,7 @@ class LineForm extends EquipmentForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"type",
"protocol",
@@ -37,15 +38,15 @@ class LineForm extends EquipmentForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "bandwith":
@@ -58,7 +59,7 @@ class LineForm extends EquipmentForm
$formRules[$field] = "permit_empty|valid_date";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Equipment/ServerForm.php b/app/Forms/Equipment/ServerForm.php
index 3b5dd0a..13fe98e 100644
--- a/app/Forms/Equipment/ServerForm.php
+++ b/app/Forms/Equipment/ServerForm.php
@@ -10,6 +10,7 @@ class ServerForm extends EquipmentForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"serviceinfo_uid",
"code",
@@ -61,17 +62,17 @@ class ServerForm extends EquipmentForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "switchinfo_uid":
- $formRules[$field] = sprintf("permit_empty|numeric%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("permit_empty|numeric%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "code":
case "title":
@@ -85,7 +86,7 @@ class ServerForm extends EquipmentForm
$formRules[$field] = "required|trim|string";
break;
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
- $formRules[$field] = sprintf("permit_empty|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("permit_empty|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "os":
$formRules[$field] = "permit_empty|trim|string";
@@ -97,41 +98,41 @@ class ServerForm extends EquipmentForm
$formRules[$field] = "permit_empty|valid_date";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- protected function getFormOption_process($service, string $action, string $field, array $formDatas = []): array
+ protected function getFormOption_process($service, string $field, array $formDatas = []): array
{
$entities = [];
switch ($field) {
case 'ip':
- if (in_array($action, ['create_form', 'modify_form'])) {
+ if (in_array($this->formAction, ['create_form', 'modify_form'])) {
if (array_key_exists($field, $formDatas)) {
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $field, $formDatas[$field]);
$entities = $service->getEntities([$where => null]);
} else {
- $entities = parent::getFormOption_process($service, $action, $field, $formDatas);
+ $entities = parent::getFormOption_process($service, $field, $formDatas);
}
} else {
- $entities = parent::getFormOption_process($service, $action, $field, $formDatas);
+ $entities = parent::getFormOption_process($service, $field, $formDatas);
}
break;
default:
- $entities = parent::getFormOption_process($service, $action, $field, $formDatas);
+ $entities = parent::getFormOption_process($service, $field, $formDatas);
break;
}
return $entities;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serviceinfo_uid':
- foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
@@ -144,7 +145,7 @@ class ServerForm extends EquipmentForm
'text' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"
]
];
- foreach ($this->getFormOption_process(service('equipment_chassisservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('equipment_chassisservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = [
'value' => $tempEntity->getPK(),
'text' => $tempEntity->getTitle(),
@@ -156,7 +157,7 @@ class ServerForm extends EquipmentForm
// dd($options);
break;
case 'switchinfo_uid':
- foreach ($this->getFormOption_process(service('part_switchservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('part_switchservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
@@ -164,7 +165,7 @@ class ServerForm extends EquipmentForm
// dd($options);
break;
case 'ip': //key=value이 같음주의
- foreach ($this->getFormOption_process(service('part_ipservice'), $action, 'ip', $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('part_ipservice'), 'ip', $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
@@ -177,7 +178,7 @@ class ServerForm extends EquipmentForm
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/Equipment/ServerPartForm.php b/app/Forms/Equipment/ServerPartForm.php
index 5c283d6..11e9bb7 100644
--- a/app/Forms/Equipment/ServerPartForm.php
+++ b/app/Forms/Equipment/ServerPartForm.php
@@ -12,6 +12,7 @@ class ServerPartForm extends EquipmentForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"serverinfo_uid",
"type",
@@ -20,7 +21,6 @@ class ServerPartForm extends EquipmentForm
"cnt",
"extra",
"amount",
- "status"
];
$filters = [
"serverinfo_uid",
@@ -44,13 +44,13 @@ class ServerPartForm extends EquipmentForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "serverinfo_uid":
@@ -72,7 +72,7 @@ class ServerPartForm extends EquipmentForm
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
@@ -81,7 +81,7 @@ class ServerPartForm extends EquipmentForm
{
return service('part_' . strtolower($type) . 'service');
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
@@ -95,7 +95,7 @@ class ServerPartForm extends EquipmentForm
'text' => lang("{$this->getAttribute('class_path')}.TYPE.{$type}") . " 선택",
]
];
- foreach ($this->getFormOption_process($partService, $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process($partService, $field, $formDatas) as $tempEntity) {
$tempOptions[$type][$tempEntity->getPK()] = [
'value' => $tempEntity->getPK(),
'text' => $tempEntity->getTitle(),
@@ -107,21 +107,21 @@ class ServerPartForm extends EquipmentForm
$options['options'] = $tempOptions;
break;
case 'serverinfo_uid':
- foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case 'serviceinfo_uid':
- foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/MylogForm.php b/app/Forms/MylogForm.php
index a54e51d..e15d7d3 100644
--- a/app/Forms/MylogForm.php
+++ b/app/Forms/MylogForm.php
@@ -12,6 +12,7 @@ class MylogForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = ['title', 'content', 'status'];
$filters = ['user_uid', 'status'];
$indexFilter = $filters;
@@ -26,13 +27,13 @@ class MylogForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "user_uid":
@@ -45,7 +46,7 @@ class MylogForm extends CommonForm
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/CPUForm.php b/app/Forms/Part/CPUForm.php
index bb81097..5e8c731 100644
--- a/app/Forms/Part/CPUForm.php
+++ b/app/Forms/Part/CPUForm.php
@@ -10,6 +10,7 @@ class CPUForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"title",
"price",
@@ -32,20 +33,20 @@ class CPUForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "used":
$formRules[$field] = "required|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/CSForm.php b/app/Forms/Part/CSForm.php
index 34c528a..360550c 100644
--- a/app/Forms/Part/CSForm.php
+++ b/app/Forms/Part/CSForm.php
@@ -10,6 +10,7 @@ class CSForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"type",
"ip",
@@ -58,27 +59,27 @@ class CSForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "type":
$formRules[$field] = "required|trim|string";
break;
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
- $formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "accountid":
case "domain":
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/DISKForm.php b/app/Forms/Part/DISKForm.php
index 5537ba0..17cb0c7 100644
--- a/app/Forms/Part/DISKForm.php
+++ b/app/Forms/Part/DISKForm.php
@@ -10,6 +10,7 @@ class DISKForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"title",
"price",
@@ -33,13 +34,13 @@ class DISKForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "used":
@@ -49,7 +50,7 @@ class DISKForm extends PartForm
$formRules[$field] = "required|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/IPForm.php b/app/Forms/Part/IPForm.php
index a273723..bae6dce 100644
--- a/app/Forms/Part/IPForm.php
+++ b/app/Forms/Part/IPForm.php
@@ -10,6 +10,7 @@ class IPForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"lineinfo_uid",
"ip",
@@ -69,15 +70,15 @@ class IPForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "lineinfo_uid":
@@ -90,27 +91,27 @@ class IPForm extends PartForm
$formRules[$field] = "permit_empty|numeric";
break;
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
- $formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|valid_ip[both]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'lineinfo_uid':
- foreach ($this->getFormOption_process(service('equipment_lineservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('equipment_lineservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case 'old_clientinfo_uid':
- foreach ($this->getFormOption_process(service('customer_clientservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('customer_clientservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
@@ -118,7 +119,7 @@ class IPForm extends PartForm
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/Part/PartForm.php b/app/Forms/Part/PartForm.php
index 9dc380d..956eb46 100644
--- a/app/Forms/Part/PartForm.php
+++ b/app/Forms/Part/PartForm.php
@@ -10,11 +10,11 @@ abstract class PartForm extends CommonForm
{
parent::__construct();
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "title":
- $formRules[$field] = sprintf("required|trim|string%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|string%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "clientinfo_uid":
case "serviceinfo_uid":
@@ -27,31 +27,31 @@ abstract class PartForm extends CommonForm
$formRules[$field] = "required|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serviceinfo_uid':
- foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
case 'serverinfo_uid':
- foreach ($this->getFormOption_process(service('equipment_serverservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('equipment_serverservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/Part/RAMForm.php b/app/Forms/Part/RAMForm.php
index 9ce2bf6..083b229 100644
--- a/app/Forms/Part/RAMForm.php
+++ b/app/Forms/Part/RAMForm.php
@@ -10,6 +10,7 @@ class RAMForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"title",
"price",
@@ -32,20 +33,20 @@ class RAMForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "used":
$formRules[$field] = "required|numeric";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/SOFTWAREForm.php b/app/Forms/Part/SOFTWAREForm.php
index 79b7f4e..f856c6b 100644
--- a/app/Forms/Part/SOFTWAREForm.php
+++ b/app/Forms/Part/SOFTWAREForm.php
@@ -10,6 +10,7 @@ class SOFTWAREForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"title",
"price",
@@ -32,17 +33,17 @@ class SOFTWAREForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/Part/SWITCHForm.php b/app/Forms/Part/SWITCHForm.php
index aa458fc..da8d52b 100644
--- a/app/Forms/Part/SWITCHForm.php
+++ b/app/Forms/Part/SWITCHForm.php
@@ -10,6 +10,7 @@ class SWITCHForm extends PartForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"code",
"price",
@@ -49,19 +50,19 @@ class SWITCHForm extends PartForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Forms/PaymentForm.php b/app/Forms/PaymentForm.php
index 1819aeb..115ec30 100644
--- a/app/Forms/PaymentForm.php
+++ b/app/Forms/PaymentForm.php
@@ -12,6 +12,7 @@ class PaymentForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
"serviceinfo_uid",
"title",
@@ -63,15 +64,15 @@ class PaymentForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
$this->setActionButtons($actionButtons);
$this->setBatchjobButtons($batchjobButtons);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "user_uid":
@@ -96,25 +97,25 @@ class PaymentForm extends CommonForm
$formRules[$field] = "permit_empty|trim|string";
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
}
- public function getFormOption(string $action, string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
+ public function getFormOption(string $field, array $formDatas = [], array $options = ['options' => [], 'atttributes' => []]): array
{
$tempOptions = ['' => lang("{$this->getAttribute('class_path')}.label.{$field}") . " 선택"];
switch ($field) {
case 'serviceinfo_uid':
- foreach ($this->getFormOption_process(service('customer_serviceservice'), $action, $field, $formDatas) as $tempEntity) {
+ foreach ($this->getFormOption_process(service('customer_serviceservice'), $field, $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getPK()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_COMMA'], $tempEntity->getRole())];
}
$options['options'] = $tempOptions;
break;
default:
- $options = parent::getFormOption($action, $field, $formDatas, $options);
+ $options = parent::getFormOption($field, $formDatas, $options);
break;
}
return $options;
diff --git a/app/Forms/UserForm.php b/app/Forms/UserForm.php
index a8ab106..e06b93b 100644
--- a/app/Forms/UserForm.php
+++ b/app/Forms/UserForm.php
@@ -12,6 +12,7 @@ class UserForm extends CommonForm
}
public function action_init_process(string $action, array &$formDatas = []): void
{
+ parent::action_init_process($action, $formDatas);
$fields = [
'id',
'passwd',
@@ -35,33 +36,33 @@ class UserForm extends CommonForm
break;
}
$this->setFormFields($fields);
- $this->setFormRules($action, $fields);
+ $this->setFormRules($fields);
$this->setFormFilters($filters);
- $this->setFormOptions($action, $filters, $formDatas);
+ $this->setFormOptions($filters, $formDatas);
$this->setIndexFilters($indexFilter);
$this->setBatchjobFilters($batchjobFilters);
}
- public function getFormRule(string $action, string $field, array $formRules): array
+ public function getFormRule(string $field, array $formRules): array
{
switch ($field) {
case "id":
- $formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|min_length[4]|max_length[20]%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "passwd":
- $formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
+ $formRules[$field] = sprintf("%s|%s", in_array($this->formAction, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string");
break;
case "confirmpassword":
- $formRules[$field] = sprintf("%s|%s", in_array($action, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
+ $formRules[$field] = sprintf("%s|%s", in_array($this->formAction, ["create", "create_form"]) ? "required" : "permit_empty", "trim|string|matches[passwd]");
break;
case "email":
- $formRules[$field] = sprintf("required|trim|valid_email%s", in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
+ $formRules[$field] = sprintf("required|trim|valid_email%s", in_array($this->formAction, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break;
case "role":
$formRules[$field] = 'required|is_array|at_least_one';
$formRules['role.*'] = 'permit_empty|trim|in_list[manager,cloudflare,firewall,security,director,master]';
break;
default:
- $formRules = parent::getFormRule($action, $field, $formRules);
+ $formRules = parent::getFormRule($field, $formRules);
break;
}
return $formRules;
diff --git a/app/Helpers/UserHelper.php b/app/Helpers/UserHelper.php
index 07495ef..e545519 100644
--- a/app/Helpers/UserHelper.php
+++ b/app/Helpers/UserHelper.php
@@ -18,18 +18,35 @@ class UserHelper extends CommonHelper
$form = form_password($field, "", $extras);
break;
case 'role':
+ // ✅ value가 string이면 CSV -> array로 변환
+ if (is_string($value)) {
+ $value = array_values(array_filter(array_map('trim', explode(',', $value))));
+ } elseif ($value === null) {
+ $value = [];
+ }
+
+ // ✅ 현재 role 목록(소문자/trim 정규화)
$currentRoles = is_array($value)
? array_map('strtolower', array_map('trim', $value))
: [];
+
$form = '';
- //Form페이지에서는 맨앞에것 제외하기 위함
- array_shift($viewDatas['formOptions'][$field]['options']);
- foreach ($viewDatas['formOptions'][$field]['options'] as $key => $label) {
- $checked = in_array(strtolower(trim($key)), $currentRoles);
- $form .= '';
+
+ // Form페이지에서는 맨앞에것 제외하기 위함
+ if (isset($viewDatas['formOptions'][$field]['options']) && is_array($viewDatas['formOptions'][$field]['options'])) {
+ $options = $viewDatas['formOptions'][$field]['options'];
+
+ // ✅ 원본을 건드리지 말고 복사본에서 shift (중요)
+ array_shift($options);
+
+ foreach ($options as $key => $label) {
+ $checked = in_array(strtolower(trim((string) $key)), $currentRoles, true);
+
+ $form .= '';
+ }
}
break;
default:
diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php
index 5f0a5bd..a898b62 100644
--- a/app/Services/Auth/AuthService.php
+++ b/app/Services/Auth/AuthService.php
@@ -2,8 +2,6 @@
namespace App\Services\Auth;
-use App\DTOs\Auth\GoogleDTO;
-use App\DTOs\Auth\LocalDTO;
use App\Entities\UserEntity;
use App\Helpers\AuthHelper;
use App\Models\CommonModel;
@@ -24,9 +22,9 @@ abstract class AuthService extends CommonService
}
//로그인
abstract protected function login_process(array $formDatas): UserEntity;
- final public function login(LocalDTO|GoogleDTO $dto): UserEntity
+ final public function login(array $formDatas): UserEntity
{
- $entity = $this->login_process($dto->toArray());
+ $entity = $this->login_process($formDatas);
//인증 세션처리
$this->getAuthContext()->setAuthSession($entity);
return $entity;
diff --git a/app/Services/Auth/GoogleService.php b/app/Services/Auth/GoogleService.php
index ca2b909..1f7db7b 100644
--- a/app/Services/Auth/GoogleService.php
+++ b/app/Services/Auth/GoogleService.php
@@ -2,7 +2,6 @@
namespace App\Services\Auth;
-use App\DTOs\Auth\GoogleDTO;
use App\Entities\UserEntity;
use App\Forms\Auth\GoogleForm;
use App\Libraries\MySocket\GoogleSocket\CURL;
@@ -18,14 +17,6 @@ class GoogleService extends AuthService
parent::__construct($model);
$this->addClassPaths('Google');
}
- public function createDTO(array $formDatas): GoogleDTO
- {
- return new GoogleDTO($formDatas);
- }
- public function getDTOClass(): string
- {
- return GoogleDTO::class;
- }
protected function getEntity_process(mixed $entity): UserEntity
{
return $entity;
diff --git a/app/Services/Auth/LocalService.php b/app/Services/Auth/LocalService.php
index 3beaa3e..e7ecd7d 100644
--- a/app/Services/Auth/LocalService.php
+++ b/app/Services/Auth/LocalService.php
@@ -2,7 +2,6 @@
namespace App\Services\Auth;
-use App\DTOs\Auth\LocalDTO;
use App\Entities\UserEntity;
use App\Forms\Auth\LocalForm;
use App\Models\UserModel;
@@ -17,14 +16,7 @@ class LocalService extends AuthService
parent::__construct($model);
$this->addClassPaths('Local');
}
- public function createDTO(array $formDatas): LocalDTO
- {
- return new LocalDTO($formDatas);
- }
- public function getDTOClass(): string
- {
- return LocalDTO::class;
- }
+
protected function getEntity_process(mixed $entity): UserEntity
{
return $entity;
diff --git a/app/Services/BoardService.php b/app/Services/BoardService.php
index a8c2cd6..0bacf93 100644
--- a/app/Services/BoardService.php
+++ b/app/Services/BoardService.php
@@ -6,7 +6,6 @@ use App\Models\BoardModel;
use App\Helpers\BoardHelper;
use App\Forms\BoardForm;
use App\Entities\BoardEntity;
-use App\DTOs\BoardDTO;
class BoardService extends CommonService
{
@@ -18,14 +17,6 @@ class BoardService extends CommonService
parent::__construct($model);
$this->addClassPaths('Board');
}
- public function getDTOClass(): string
- {
- return BoardDTO::class;
- }
- public function createDTO(array $formDatas): BoardDTO
- {
- return new BoardDTO($formDatas);
- }
public function getEntityClass(): string
{
return BoardEntity::class;
diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php
index 4ef3dac..e856248 100644
--- a/app/Services/CommonService.php
+++ b/app/Services/CommonService.php
@@ -2,13 +2,13 @@
namespace App\Services;
-use App\Forms\CommonForm;
-use App\DTOs\CommonDTO;
-use App\Entities\CommonEntity;
-use App\Models\CommonModel;
-use App\Libraries\AuthContext;
-use CodeIgniter\Database\Exceptions\DatabaseException;
use RuntimeException;
+use App\Forms\CommonForm;
+use App\Models\CommonModel;
+use App\Entities\CommonEntity;
+use App\Libraries\AuthContext;
+use App\Exceptions\FormValidationException;
+use CodeIgniter\Database\Exceptions\DatabaseException;
abstract class CommonService
{
@@ -26,8 +26,6 @@ abstract class CommonService
{
}
- abstract public function getDTOClass(): string;
- abstract public function createDTO(array $formDatas): CommonDTO;
abstract public function getEntityClass(): string;
/**
@@ -236,8 +234,6 @@ abstract class CommonService
// INSERT 시 Entity의 PK는 0 또는 NULL이어야 함 (DB가 ID를 생성하도록)
$initialPK = $entity->getPK();
$result = $this->model->save($entity);
- log_message('debug', __FUNCTION__ . ":" . var_export($entity, true));
- log_message('debug', __FUNCTION__ . ":" . $this->model->getLastQuery());
// 최종적으로 DB에 반영된 PK를 반환받습니다. (UPDATE이면 기존 PK, INSERT이면 새 PK)
$entity->{$this->getPKField()} = $this->handle_save_result($result, $initialPK);
// handle_save_result에서 확인된 최종 PK를 사용하여 DB에서 최신 엔티티를 가져옴
@@ -250,7 +246,7 @@ abstract class CommonService
}
//Action 작업시 field에따른 Hook처리(각 Service에서 override);
- protected function action_process_fieldhook(string $field, $value, array $formDatas): array
+ protected function validation_fieldhook(string $field, $value, array $formDatas): array
{
return $formDatas;
}
@@ -259,25 +255,25 @@ abstract class CommonService
protected function create_process(array $formDatas): CommonEntity
{
try {
- log_message('debug', "*** ENTER" . __METHOD__ . " ***");
$actionForm = $this->getActionForm();
- log_message('debug', 'FORMCLASS=' . $this->formClass . ' / FORMINST=' . (is_object($actionForm) ? get_class($actionForm) : 'NULL'));
- log_message('debug', 'IS_COMMONFORM=' . (is_object($actionForm) && $actionForm instanceof CommonForm ? 'YES' : 'NO'));
if ($actionForm instanceof CommonForm) {
$actionForm->action_init_process('create', $formDatas);
+ // log_message('debug', 'BEFORE hook CREATE FORMDATA:' . print_r($formDatas ?? null, true));
foreach ($formDatas as $field => $value) {
- $formDatas = $this->action_process_fieldhook($field, $value, $formDatas);
+ $formDatas = $this->validation_fieldhook($field, $value, $formDatas);
}
- log_message('debug', '>>> BEFORE validate: ' . get_class($actionForm));
+ // log_message('debug', 'AFTER hook CREATE FORMDATA:' . print_r($formDatas ?? null, true));
$actionForm->validate($formDatas); // ✅ 여기서 검증
- log_message('debug', '>>> AFTER validate');
}
+
$entityClass = $this->getEntityClass();
$entity = new $entityClass($formDatas);
if (!$entity instanceof $entityClass) {
throw new RuntimeException("Return Type은 {$entityClass}만 가능");
}
return $this->save_process($entity);
+ } catch (FormValidationException $e) {
+ throw $e; // ✅ 감싸지 말고 그대로
} catch (\Throwable $e) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage());
}
@@ -292,34 +288,41 @@ abstract class CommonService
}
//수정용
+ protected function modify_process_fieldhook(array $formDatas): array
+ {
+ return $formDatas;
+ }
protected function modify_process($entity, array $formDatas): CommonEntity
{
try {
- log_message('debug', "*** ENTER" . __METHOD__ . " ***");
$actionForm = $this->getActionForm();
- log_message('debug', 'FORMCLASS=' . $this->formClass . ' / FORMINST=' . (is_object($actionForm) ? get_class($actionForm) : 'NULL'));
- log_message('debug', 'IS_COMMONFORM=' . (is_object($actionForm) && $actionForm instanceof CommonForm ? 'YES' : 'NO'));
- if ($actionForm instanceof CommonForm) {
- $actionForm->action_init_process('modify', $formDatas);
- foreach ($formDatas as $field => $value) {
- $formDatas = $this->action_process_fieldhook($field, $value, $formDatas);
- }
- log_message('debug', '>>> BEFORE validate: ' . get_class($actionForm));
- $actionForm->validate($formDatas); // ✅ 여기서 검증
- log_message('debug', '>>> AFTER validate');
+ if (!$actionForm instanceof CommonForm) {
+ throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: actionForm이 정의되지 않았습니다.");
}
+ $actionForm->action_init_process('modify', $formDatas);
+ log_message('debug', 'BEFORE hook MODIFY FORMDATA:' . print_r($formDatas ?? null, true));
+ foreach ($formDatas as $field => $value) {
+ $formDatas = $this->validation_fieldhook($field, $value, $formDatas);
+ }
+ log_message('debug', 'AFTER hook MODIFY FORMDATA:' . print_r($formDatas ?? null, true));
+ $actionForm->validate($formDatas); // ✅ 여기서 검증
// 검증 통과 후 엔티티 반영
+ $formDatas = $this->modify_process_fieldhook($formDatas);
+ log_message('debug', 'BEFORE MODIFY fill Entity:' . print_r($formDatas ?? null, true));
$entity->fill($formDatas);
+ log_message('debug', 'AFTER MODIFY fill Entity:' . print_r($entity ?? null, true));
if (!$entity->hasChanged()) {
return $entity;
}
return $this->save_process($entity);
-
+ } catch (FormValidationException $e) {
+ throw $e; // ✅ 감싸지 말고 그대로
} catch (\Throwable $e) {
- throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage() . "\n" . var_export($entity, true));
+ throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:" . $e->getMessage());
}
}
+
final public function modify(string|int $uid, array $formDatas): CommonEntity
{
return $this->dbTransaction(function () use ($uid, $formDatas) {
diff --git a/app/Services/Customer/ClientService.php b/app/Services/Customer/ClientService.php
index 38c9c36..3af9559 100644
--- a/app/Services/Customer/ClientService.php
+++ b/app/Services/Customer/ClientService.php
@@ -4,8 +4,6 @@ namespace App\Services\Customer;
use RuntimeException;
use App\Entities\CommonEntity;
-use App\Entities\PaymentEntity;
-use App\DTOs\Customer\ClientDTO;
use App\Forms\Customer\ClientForm;
use App\Models\Customer\ClientModel;
use App\Helpers\Customer\ClientHelper;
@@ -21,14 +19,6 @@ class ClientService extends CustomerService
parent::__construct($model);
$this->addClassPaths('Client');
}
- public function getDTOClass(): string
- {
- return ClientDTO::class;
- }
- public function createDTO(array $formDatas): ClientDTO
- {
- return new ClientDTO($formDatas);
- }
public function getEntityClass(): string
{
return ClientEntity::class;
@@ -48,7 +38,7 @@ class ClientService extends CustomerService
parent::setOrderBy($field, $value);
}
- protected function action_process_fieldhook(string $field, $value, array $formDatas): array
+ protected function validation_fieldhook(string $field, $value, array $formDatas): array
{
switch ($field) {
case 'role':
@@ -64,12 +54,34 @@ class ClientService extends CustomerService
$formDatas[$field] = $value;
break;
default:
- $formDatas = parent::action_process_fieldhook($field, $value, $formDatas);
+ $formDatas = parent::validation_fieldhook($field, $value, $formDatas);
break;
}
return $formDatas;
}
+ protected function modify_process_fieldhook(array $formDatas): array
+ {
+ // 1) DB 컬럼 아닌 값 제거
+ unset($formDatas['confirmpassword']);
+ // 2) role은 무조건 문자열로
+ if (array_key_exists('role', $formDatas)) {
+ $arr = is_array($formDatas['role'])
+ ? $formDatas['role']
+ : explode(',', (string) $formDatas['role']);
+
+ $arr = array_values(array_filter(array_map('trim', $arr)));
+ sort($arr);
+ $formDatas['role'] = implode(',', $arr);
+ }
+
+ // 3) passwd는 빈 값이면 업데이트 제외 (원하면)
+ if (array_key_exists('passwd', $formDatas) && $formDatas['passwd'] === '') {
+ unset($formDatas['passwd']);
+ }
+
+ return $formDatas;
+ }
public function history(string|int $uid, string $history): CommonEntity
{
return $this->dbTransaction(function () use ($uid, $history) {
diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php
index de69575..ad2c97f 100644
--- a/app/Services/Customer/ServiceService.php
+++ b/app/Services/Customer/ServiceService.php
@@ -6,7 +6,6 @@ use DateTimeZone;
use RuntimeException;
use DateTimeImmutable;
use App\Entities\CommonEntity;
-use App\DTOs\Customer\ServiceDTO;
use App\Forms\Customer\ServiceForm;
use App\Models\Customer\ServiceModel;
use App\Helpers\Customer\ServiceHelper;
@@ -23,16 +22,6 @@ class ServiceService extends CustomerService
$this->addClassPaths('Service');
}
- public function getDTOClass(): string
- {
- return ServiceDTO::class;
- }
-
- public function createDTO(array $formDatas): ServiceDTO
- {
- return new ServiceDTO($formDatas);
- }
-
public function getEntityClass(): string
{
return ServiceEntity::class;
diff --git a/app/Services/Customer/Wallet/AccountService.php b/app/Services/Customer/Wallet/AccountService.php
index ee3a2ed..98c2d6e 100644
--- a/app/Services/Customer/Wallet/AccountService.php
+++ b/app/Services/Customer/Wallet/AccountService.php
@@ -2,7 +2,6 @@
namespace App\Services\Customer\Wallet;
-use App\DTOs\Customer\Wallet\AccountDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\Wallet\AccountEntity;
@@ -22,14 +21,6 @@ class AccountService extends WalletService
parent::__construct($model);
$this->addClassPaths('Account');
}
- public function getDTOClass(): string
- {
- return AccountDTO::class;
- }
- public function createDTO(array $formDatas): AccountDTO
- {
- return new AccountDTO($formDatas);
- }
public function getEntityClass(): string
{
return AccountEntity::class;
diff --git a/app/Services/Customer/Wallet/CouponService.php b/app/Services/Customer/Wallet/CouponService.php
index b7653a9..332528a 100644
--- a/app/Services/Customer/Wallet/CouponService.php
+++ b/app/Services/Customer/Wallet/CouponService.php
@@ -2,7 +2,6 @@
namespace App\Services\Customer\Wallet;
-use App\DTOs\Customer\Wallet\CouponDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\Wallet\CouponEntity;
@@ -22,14 +21,6 @@ class CouponService extends WalletService
parent::__construct($model);
$this->addClassPaths('Coupon');
}
- public function getDTOClass(): string
- {
- return CouponDTO::class;
- }
- public function createDTO(array $formDatas): CouponDTO
- {
- return new CouponDTO($formDatas);
- }
public function getEntityClass(): string
{
return CouponEntity::class;
diff --git a/app/Services/Customer/Wallet/PointService.php b/app/Services/Customer/Wallet/PointService.php
index 572aa54..f3cd6ac 100644
--- a/app/Services/Customer/Wallet/PointService.php
+++ b/app/Services/Customer/Wallet/PointService.php
@@ -2,7 +2,6 @@
namespace App\Services\Customer\Wallet;
-use App\DTOs\Customer\Wallet\PointDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\Wallet\PointEntity;
@@ -22,14 +21,6 @@ class PointService extends WalletService
parent::__construct($model);
$this->addClassPaths('Point');
}
- public function getDTOClass(): string
- {
- return PointDTO::class;
- }
- public function createDTO(array $formDatas): PointDTO
- {
- return new PointDTO($formDatas);
- }
public function getEntityClass(): string
{
return PointEntity::class;
diff --git a/app/Services/Equipment/CHASSISService.php b/app/Services/Equipment/CHASSISService.php
index a7fd59a..72beecf 100644
--- a/app/Services/Equipment/CHASSISService.php
+++ b/app/Services/Equipment/CHASSISService.php
@@ -2,7 +2,6 @@
namespace App\Services\Equipment;
-use App\DTOs\Equipment\CHASSISDTO;
use App\Entities\CommonEntity;
use App\Entities\Equipment\CHASSISEntity;
use App\Entities\Equipment\ServerEntity;
@@ -21,14 +20,6 @@ class CHASSISService extends EquipmentService
parent::__construct($model);
$this->addClassPaths('CHASSIS');
}
- public function getDTOClass(): string
- {
- return CHASSISDTO::class;
- }
- public function createDTO(array $formDatas): CHASSISDTO
- {
- return new CHASSISDTO($formDatas);
- }
public function getEntityClass(): string
{
return CHASSISEntity::class;
diff --git a/app/Services/Equipment/LineService.php b/app/Services/Equipment/LineService.php
index f79e26a..aebfd55 100644
--- a/app/Services/Equipment/LineService.php
+++ b/app/Services/Equipment/LineService.php
@@ -2,7 +2,6 @@
namespace App\Services\Equipment;
-use App\DTOs\Equipment\LineDTO;
use App\Entities\Equipment\LineEntity;
use App\Forms\Equipment\LineForm;
use App\Helpers\Equipment\LineHelper;
@@ -21,14 +20,6 @@ class LineService extends EquipmentService
parent::__construct($model);
$this->addClassPaths('Line');
}
- public function getDTOClass(): string
- {
- return LineDTO::class;
- }
- public function createDTO(array $formDatas): LineDTO
- {
- return new LineDTO($formDatas);
- }
public function getEntityClass(): string
{
return LineEntity::class;
diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php
index 703b0fd..d246c44 100644
--- a/app/Services/Equipment/ServerPartService.php
+++ b/app/Services/Equipment/ServerPartService.php
@@ -2,7 +2,6 @@
namespace App\Services\Equipment;
-use App\DTOs\Equipment\ServerPartDTO;
use App\Entities\CommonEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
@@ -25,16 +24,6 @@ class ServerPartService extends EquipmentService
$this->addClassPaths('ServerPart');
}
- public function getDTOClass(): string
- {
- return ServerPartDTO::class;
- }
-
- public function createDTO(array $formDatas): ServerPartDTO
- {
- return new ServerPartDTO($formDatas);
- }
-
public function getEntityClass(): string
{
return ServerPartEntity::class;
diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php
index aebb520..a183228 100644
--- a/app/Services/Equipment/ServerService.php
+++ b/app/Services/Equipment/ServerService.php
@@ -2,7 +2,6 @@
namespace App\Services\Equipment;
-use App\DTOs\Equipment\ServerDTO;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Forms\Equipment\ServerForm;
@@ -21,16 +20,6 @@ class ServerService extends EquipmentService
$this->addClassPaths('Server');
}
- public function getDTOClass(): string
- {
- return ServerDTO::class;
- }
-
- public function createDTO(array $formDatas): ServerDTO
- {
- return new ServerDTO($formDatas);
- }
-
public function getEntityClass(): string
{
return ServerEntity::class;
diff --git a/app/Services/MylogService.php b/app/Services/MylogService.php
index 14ef72c..8682bb9 100644
--- a/app/Services/MylogService.php
+++ b/app/Services/MylogService.php
@@ -8,7 +8,6 @@ use App\Libraries\OperationContext;
use App\Helpers\MylogHelper;
use App\Forms\MylogForm;
use App\Entities\MylogEntity;
-use App\DTOs\MylogDTO;
class MylogService extends CommonService implements PipelineStepInterface
{
@@ -20,14 +19,6 @@ class MylogService extends CommonService implements PipelineStepInterface
parent::__construct($model);
$this->addClassPaths('Mylog');
}
- public function getDTOClass(): string
- {
- return MylogDTO::class;
- }
- public function createDTO(array $formDatas): MylogDTO
- {
- return new MylogDTO($formDatas);
- }
public function getEntityClass(): string
{
return MylogEntity::class;
diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php
index abc20a4..e4e7d30 100644
--- a/app/Services/Part/CPUService.php
+++ b/app/Services/Part/CPUService.php
@@ -2,7 +2,6 @@
namespace App\Services\Part;
-use App\DTOs\Part\CPUDTO;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Part\CPUEntity;
use App\Forms\Part\CPUForm;
@@ -20,14 +19,6 @@ class CPUService extends PartType1Service
parent::__construct($model);
$this->addClassPaths('CPU');
}
- public function getDTOClass(): string
- {
- return CPUDTO::class;
- }
- public function createDTO(array $formDatas): CPUDTO
- {
- return new CPUDTO($formDatas);
- }
public function getEntityClass(): string
{
return CPUEntity::class;
diff --git a/app/Services/Part/CSService.php b/app/Services/Part/CSService.php
index 4c67a35..7d87595 100644
--- a/app/Services/Part/CSService.php
+++ b/app/Services/Part/CSService.php
@@ -8,7 +8,6 @@ use App\Helpers\Part\CSHelper;
use App\Forms\Part\CSForm;
use App\Entities\Part\CSEntity;
use App\Entities\Equipment\ServerPartEntity;
-use App\DTOs\Part\CSDTO;
class CSService extends PartType2Service
{
@@ -20,14 +19,6 @@ class CSService extends PartType2Service
parent::__construct($model);
$this->addClassPaths('CS');
}
- public function getDTOClass(): string
- {
- return CSDTO::class;
- }
- public function createDTO(array $formDatas): CSDTO
- {
- return new CSDTO($formDatas);
- }
public function getEntityClass(): string
{
return CSEntity::class;
diff --git a/app/Services/Part/DISKService.php b/app/Services/Part/DISKService.php
index e35e924..0217b6c 100644
--- a/app/Services/Part/DISKService.php
+++ b/app/Services/Part/DISKService.php
@@ -8,8 +8,6 @@ use App\Helpers\Part\DISKHelper;
use App\Forms\Part\DISKForm;
use App\Entities\Part\DISKEntity;
use App\Entities\Equipment\ServerPartEntity;
-use App\Entities\CommonEntity;
-use App\DTOs\Part\DISKDTO;
class DISKService extends PartType1Service
{
@@ -21,14 +19,6 @@ class DISKService extends PartType1Service
parent::__construct($model);
$this->addClassPaths('DISK');
}
- public function getDTOClass(): string
- {
- return DISKDTO::class;
- }
- public function createDTO(array $formDatas): DISKDTO
- {
- return new DISKDTO($formDatas);
- }
public function getEntityClass(): string
{
return DISKEntity::class;
diff --git a/app/Services/Part/IPService.php b/app/Services/Part/IPService.php
index 639d205..79a7fdd 100644
--- a/app/Services/Part/IPService.php
+++ b/app/Services/Part/IPService.php
@@ -2,7 +2,6 @@
namespace App\Services\Part;
-use App\DTOs\Part\IPDTO;
use App\Entities\Equipment\LineEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
@@ -22,14 +21,6 @@ class IPService extends PartType3Service
parent::__construct($model);
$this->addClassPaths('IP');
}
- public function getDTOClass(): string
- {
- return IPDTO::class;
- }
- public function createDTO(array $formDatas): IPDTO
- {
- return new IPDTO($formDatas);
- }
public function getEntityClass(): string
{
return IPEntity::class;
diff --git a/app/Services/Part/RAMService.php b/app/Services/Part/RAMService.php
index 09b5857..66a3d16 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\DTOs\Part\RAMDTO;
class RAMService extends PartType1Service
{
@@ -20,14 +19,6 @@ class RAMService extends PartType1Service
parent::__construct($model);
$this->addClassPaths('RAM');
}
- public function getDTOClass(): string
- {
- return RAMDTO::class;
- }
- public function createDTO(array $formDatas): RAMDTO
- {
- return new RAMDTO($formDatas);
- }
public function getEntityClass(): string
{
return RAMEntity::class;
diff --git a/app/Services/Part/SOFTWAREService.php b/app/Services/Part/SOFTWAREService.php
index 4131c5e..70b286a 100644
--- a/app/Services/Part/SOFTWAREService.php
+++ b/app/Services/Part/SOFTWAREService.php
@@ -8,8 +8,6 @@ use App\Helpers\Part\SOFTWAREHelper;
use App\Forms\Part\SOFTWAREForm;
use App\Entities\Part\SOFTWAREEntity;
use App\Entities\Equipment\ServerPartEntity;
-use App\Entities\CommonEntity;
-use App\DTOs\Part\SOFTWAREDTO;
class SOFTWAREService extends PartType1Service
{
@@ -21,14 +19,6 @@ class SOFTWAREService extends PartType1Service
parent::__construct($model);
$this->addClassPaths('SOFTWARE');
}
- public function getDTOClass(): string
- {
- return SOFTWAREDTO::class;
- }
- public function createDTO(array $formDatas): SOFTWAREDTO
- {
- return new SOFTWAREDTO($formDatas);
- }
public function getEntityClass(): string
{
return SOFTWAREEntity::class;
diff --git a/app/Services/Part/SWITCHService.php b/app/Services/Part/SWITCHService.php
index a8cc87a..ca92add 100644
--- a/app/Services/Part/SWITCHService.php
+++ b/app/Services/Part/SWITCHService.php
@@ -9,8 +9,6 @@ use App\Forms\Part\SWITCHForm;
use App\Entities\Part\SWITCHEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity;
-use App\Entities\CommonEntity;
-use App\DTOs\Part\SWITCHDTO;
class SWITCHService extends PartType3Service
{
@@ -22,14 +20,6 @@ class SWITCHService extends PartType3Service
parent::__construct($model);
$this->addClassPaths('SWITCH');
}
- public function getDTOClass(): string
- {
- return SWITCHDTO::class;
- }
- public function createDTO(array $formDatas): SWITCHDTO
- {
- return new SWITCHDTO($formDatas);
- }
public function getEntityClass(): string
{
return SWITCHEntity::class;
diff --git a/app/Services/PaymentService.php b/app/Services/PaymentService.php
index 0d3abda..7590a24 100644
--- a/app/Services/PaymentService.php
+++ b/app/Services/PaymentService.php
@@ -2,7 +2,6 @@
namespace App\Services;
-use App\DTOs\PaymentDTO;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
@@ -26,21 +25,11 @@ class PaymentService extends CommonService
$this->addClassPaths('Payment');
}
- public function getDTOClass(): string
- {
- return PaymentDTO::class;
- }
-
public function getEntityClass(): string
{
return PaymentEntity::class;
}
- public function createDTO(array $formDatas): PaymentDTO
- {
- return new PaymentDTO($formDatas);
- }
-
//총 미납건수, 금액
final public function getUnPaids(string $group, array $where = []): array
{
diff --git a/app/Services/UserService.php b/app/Services/UserService.php
index d2c738d..2d28161 100644
--- a/app/Services/UserService.php
+++ b/app/Services/UserService.php
@@ -2,13 +2,10 @@
namespace App\Services;
-use RuntimeException;
use App\Models\UserModel;
use App\Helpers\UserHelper;
use App\Forms\UserForm;
use App\Entities\UserEntity;
-use App\Entities\CommonEntity;
-use App\DTOs\UserDTO;
class UserService extends CommonService
{
@@ -20,14 +17,6 @@ class UserService extends CommonService
parent::__construct($model);
$this->addClassPaths('User');
}
- public function getDTOClass(): string
- {
- return UserDTO::class;
- }
- public function createDTO(array $formDatas): UserDTO
- {
- return new UserDTO($formDatas);
- }
public function getEntityClass(): string
{
return UserEntity::class;
@@ -37,6 +26,51 @@ class UserService extends CommonService
{
return $entity;
}
+ protected function validation_fieldhook(string $field, $value, array $formDatas): array
+ {
+ switch ($field) {
+ case 'role':
+ if (is_string($value)) {
+ $value = ($value === '') ? [] : explode(DEFAULTS["DELIMITER_COMMA"], $value);
+ } 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;
+ default:
+ $formDatas = parent::validation_fieldhook($field, $value, $formDatas);
+ break;
+ }
+ return $formDatas;
+ }
+
+ protected function modify_process_fieldhook(array $formDatas): array
+ {
+ // 1) DB 컬럼 아닌 값 제거
+ unset($formDatas['confirmpassword']);
+
+ // 2) role은 무조건 문자열로
+ if (array_key_exists('role', $formDatas)) {
+ $arr = is_array($formDatas['role'])
+ ? $formDatas['role']
+ : explode(',', (string) $formDatas['role']);
+
+ $arr = array_values(array_filter(array_map('trim', $arr)));
+ sort($arr);
+ $formDatas['role'] = implode(',', $arr);
+ }
+
+ // 3) passwd는 빈 값이면 업데이트 제외 (원하면)
+ if (array_key_exists('passwd', $formDatas) && $formDatas['passwd'] === '') {
+ unset($formDatas['passwd']);
+ }
+
+ return $formDatas;
+ }
//List 검색용
//FormFilter 조건절 처리
public function setFilter(string $field, mixed $filter_value): void