dbmsv4 init...5
This commit is contained in:
parent
fe8b45db35
commit
777ea0f2ff
@ -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' => '',
|
||||
|
||||
@ -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); // ✅ 여기서 검증
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user