dbmsv2 init...1

This commit is contained in:
choi.jh 2025-08-28 15:53:24 +09:00
parent bac640cc08
commit 35c4a86add
6 changed files with 102 additions and 79 deletions

View File

@ -20,8 +20,8 @@ class ServerController extends EquipmentController
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/'; $this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR; // $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
$this->serverpartinfo_cnt_range = array_combine(range(0, 10), range(0, 10)); $this->serverinfopartinfo_cnt_range = array_combine(range(0, 10), range(0, 10));
$this->serverpartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS")); $this->serverinfopartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS"));
} }
public function getService(): ServerService public function getService(): ServerService
{ {
@ -48,8 +48,6 @@ class ServerController extends EquipmentController
$this->setFieldDefaultValue('code', $this->getService()->getLastestCode($format, (int)env("Server.Default.code", 0))); $this->setFieldDefaultValue('code', $this->getService()->getLastestCode($format, (int)env("Server.Default.code", 0)));
parent::create_form_process(); parent::create_form_process();
} }
//추가 파트정보 생성
//생성 //생성
protected function create_process(array $formDatas): ServerEntity protected function create_process(array $formDatas): ServerEntity
{ {

File diff suppressed because one or more lines are too long

View File

@ -11,6 +11,41 @@ class ServerHelper extends EquipmentHelper
parent::__construct(); parent::__construct();
$this->setTitleField(field: ServerModel::TITLE); $this->setTitleField(field: ServerModel::TITLE);
} }
private function getServerPartForm(string $field, string $type, array $viewDatas, array $extras): string
{
$serverpartEntity = null;
if (array_key_exists('entity', $viewDatas)) {
$serverpartEntity = $viewDatas['entity']->getServerPartEntity($type);
}
$form = "";
if ($serverpartEntity !== null) { //수정시 사용할 uid
$form = form_hidden("serverinfopartinfo_uid_{$type}", $serverpartEntity->getPK());
}
//기존 입력화면에서 return 된것인지?
$partInfoUID = old($field);
if ($partInfoUID === null && $serverpartEntity !== null) {
$partInfoUID = $serverpartEntity->getPartInfoUID();
}
$form .= $this->form_dropdown_custom($field, $partInfoUID, $viewDatas, $extras);
$cnt = old("{$field}_cnt");
if ($cnt === null && $serverpartEntity !== null) {
$cnt = $serverpartEntity->getCnt();
} else {
$cnt = 1;
}
$form .= " " . form_dropdown("{$field}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], $cnt) . "";
//Disk인경우만 추가 정보용
if (in_array($field, ['partinfo_uid_DISK'])) {
$extra = old("{$field}_extra");
if ($extra === null && $serverpartEntity !== null) {
$extra = $serverpartEntity->getExtra();
} else {
$extra = "";
}
$form .= form_dropdown("{$field}_extra", $viewDatas['serverinfopartinfo_extra_options'], $extra);
}
return $form;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
switch ($field) { switch ($field) {
@ -19,44 +54,23 @@ class ServerHelper extends EquipmentHelper
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
break; break;
case 'CPU': case 'partinfo_uid_CPU':
case 'RAM': $form = $this->getServerPartForm($field, 'CPU', $viewDatas, $extras);
case 'DISK': break;
case 'OS': case 'partinfo_uid_RAM':
case 'SOFTWARE': $form = $this->getServerPartForm($field, 'RAM', $viewDatas, $extras);
case 'DB': break;
$form = $this->form_dropdown_custom( case 'partinfo_uid_DISK':
$field, $form = $this->getServerPartForm($field, 'DISK', $viewDatas, $extras);
old($field) ?? (array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerPartEntity($field)->getPartInfoUID() : null), break;
$viewDatas, case 'partinfo_uid_OS':
$extras $form = $this->getServerPartForm($field, 'OS', $viewDatas, $extras);
); break;
$cntValue = old("{$field}_cnt"); case 'partinfo_uid_DB':
if ($cntValue === null) { $form = $this->getServerPartForm($field, 'DB', $viewDatas, $extras);
$cntValue = isset($viewDatas['entity']) break;
? ($viewDatas['entity']->getServerPartEntity($field)?->getCnt() ?? 1) case 'partinfo_uid_SOFTWARE':
: 1; $form = $this->getServerPartForm($field, 'SOFTWARE', $viewDatas, $extras);
}
$form .= " " . form_dropdown(
"{$field}_cnt",
$viewDatas['serverpartinfo_cnt_range'],
$cntValue
) . "";
if (in_array($field, ['DISK'])) {
$extraValue = old("{$field}_extra");
if ($extraValue === null) {
$extraValue = isset($viewDatas['entity'])
? ($viewDatas['entity']->getServerPartEntity($field)?->getExtra() ?? 1)
: 1;
}
$form .= form_dropdown(
"{$field}_extra",
$viewDatas['serverpartinfo_extra_options'],
$extraValue
);
}
break; break;
case 'ipinfo_uid': case 'ipinfo_uid':
case 'csinfo_uid': case 'csinfo_uid':

View File

@ -18,12 +18,12 @@ return [
"serverpartinfo" => "부품정보", "serverpartinfo" => "부품정보",
"ipinfo_uid" => "IP정보", "ipinfo_uid" => "IP정보",
"csinfo_uid" => "CS정보", "csinfo_uid" => "CS정보",
'CPU' => "CPU", 'partinfo_uid_CPU' => "CPU",
'RAM' => "RAM", 'partinfo_uid_RAM' => "RAM",
'DISK' => "DISK", 'partinfo_uid_DISK' => "DISK",
'OS' => "OS", 'partinfo_uid_OS' => "OS",
'DB' => "DB", 'partinfo_uid_DB' => "DB",
'SOFTWARE' => "기타SW", 'partinfo_uid_SOFTWARE' => "기타SW",
], ],
"TITLE" => [ "TITLE" => [
'HP DL360 Gen6' => "HP DL360 Gen6", 'HP DL360 Gen6' => "HP DL360 Gen6",

View File

@ -58,26 +58,26 @@ class ServerPartService extends EquipmentService
return $entity; return $entity;
} }
//기본 기능부분 //기본 기능부분
//FieldForm관련용 // FieldForm관련용
public function getFormFieldOption(string $field, array $options = []): array public function getFormFieldOption(string $field, array $options = []): array
{ {
switch ($field) { switch ($field) {
case 'partinfo_CPU_uid': case 'partinfo_uid_CPU':
$options = $this->getPartService()->getEntities(['type' => 'CPU']); $options = $this->getPartService()->getEntities(['type' => 'CPU']);
break; break;
case 'partinfo_RAM_uid': case 'partinfo_uid_RAM':
$options = $this->getPartService()->getEntities(['type' => 'RAM']); $options = $this->getPartService()->getEntities(['type' => 'RAM']);
break; break;
case 'partinfo_DISK_uid': case 'partinfo_uid_DISK':
$options = $this->getPartService()->getEntities(['type' => 'DISK']); $options = $this->getPartService()->getEntities(['type' => 'DISK']);
break; break;
case 'partinfo_OS_uid': case 'partinfo_uid_OS':
$options = $this->getPartService()->getEntities(['type' => 'OS']); $options = $this->getPartService()->getEntities(['type' => 'OS']);
break; break;
case 'partinfo_DB_uid': case 'partinfo_uid_DB':
$options = $this->getPartService()->getEntities(['type' => 'DB']); $options = $this->getPartService()->getEntities(['type' => 'DB']);
break; break;
case 'partinfo_SOFTWARE_uid': case 'partinfo_uid_SOFTWARE':
$options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']); $options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']);
break; break;
case 'partinfo_uid': //수정때문에 전체가 필요 case 'partinfo_uid': //수정때문에 전체가 필요
@ -93,14 +93,14 @@ class ServerPartService extends EquipmentService
private function getFormDatasByServer(ServerEntity $serverEntity, string $partType, array $formDatas): array private function getFormDatasByServer(ServerEntity $serverEntity, string $partType, array $formDatas): array
{ {
$temps = [ $temps = [
"partinfo_uid" => $formDatas(["serverpartinfo_{$partType}_uid"]), "partinfo_uid" => $formDatas["partinfo_uid_{$partType}"],
"serverinfo_uid" => $serverEntity->getPK(), "serverinfo_uid" => $serverEntity->getPK(),
"serviceinfo_uid" => $serverEntity->getServiceInfoUID(), "serviceinfo_uid" => $serverEntity->getServiceInfoUID(),
"type" => $partType, "type" => $partType,
"billing" => $formDatas['billing'] ?? ServerPartENtity::DEFAULT_BILLING, "billing" => $formDatas['billing'] ?? ServerPartENtity::DEFAULT_BILLING,
"amount" => $formDatas["amount"] ?? 0, "amount" => $formDatas["amount"] ?? 0,
"cnt" => $formDatas["serverpartinfo_{$partType}_uid_cnt"] ?? 1, "cnt" => $formDatas["serverinfopartinfo_uid_{$partType}_cnt"] ?? 1,
"extra" => $formDatas["serverpartinfo_{$partType}_uid_extra"] ?? "" "extra" => $formDatas["serverinfopartinfo_uid_{$partType}_extra"] ?? ""
]; ];
return $temps; return $temps;
} }

View File

@ -22,10 +22,10 @@ class ServerService extends EquipmentService
"code", "code",
"type", "type",
"title", "title",
"CPU", "partinfo_uid_CPU",
"RAM", "partinfo_uid_RAM",
"DISK", "partinfo_uid_DISK",
"OS", "partinfo_uid_OS",
"ipinfo_uid", "ipinfo_uid",
"price", "price",
"amount", "amount",
@ -38,10 +38,10 @@ class ServerService extends EquipmentService
"serviceinfo_uid", "serviceinfo_uid",
"type", "type",
"title", "title",
"CPU", "partinfo_uid_CPU",
"RAM", "partinfo_uid_RAM",
"DISK", "partinfo_uid_DISK",
"OS", "partinfo_uid_OS",
"ipinfo_uid", "ipinfo_uid",
"status" "status"
], ],
@ -150,23 +150,23 @@ class ServerService extends EquipmentService
public function getFormFieldOption(string $field, array $options = []): array public function getFormFieldOption(string $field, array $options = []): array
{ {
switch ($field) { switch ($field) {
case 'CPU': case 'partinfo_uid_CPU':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_CPU_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_CPU');
break; break;
case 'RAM': case 'partinfo_uid_RAM':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_RAM_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_RAM');
break; break;
case 'DISK': case 'partinfo_uid_DISK':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_DISK_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_DISK');
break; break;
case 'OS': case 'partinfo_uid_OS':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_OS_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_OS');
break; break;
case 'DB': case 'partinfo_uid_DB':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_DB_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_DB');
break; break;
case 'SOFTWARE': case 'partinfo_uid_SOFTWARE':
$options = $this->getServerPartService()->getFormFieldOption('partinfo_SOFTWARE_uid'); $options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_SOFTWARE');
break; break;
case 'ipinfo_uid': //수정때문에 전체가 필요 case 'ipinfo_uid': //수정때문에 전체가 필요
$options = $this->getIPService()->getEntities(); $options = $this->getIPService()->getEntities();
@ -212,6 +212,17 @@ class ServerService extends EquipmentService
$entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas)); $entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas));
return $entity; return $entity;
} }
public function modify(mixed $entity, array $formDatas): ServerEntity
{
$entity = parent::create($formDatas);
//ServerPart정보 생성
foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) {
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
};
//IP정보 생성
$entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas));
return $entity;
}
//List 검색용 //List 검색용
//OrderBy 처리 //OrderBy 처리