dbmsv2 init...1
This commit is contained in:
parent
bac640cc08
commit
35c4a86add
@ -20,8 +20,8 @@ class ServerController extends EquipmentController
|
||||
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
|
||||
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->serverpartinfo_cnt_range = array_combine(range(0, 10), range(0, 10));
|
||||
$this->serverpartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS"));
|
||||
$this->serverinfopartinfo_cnt_range = array_combine(range(0, 10), range(0, 10));
|
||||
$this->serverinfopartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS"));
|
||||
}
|
||||
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)));
|
||||
parent::create_form_process();
|
||||
}
|
||||
//추가 파트정보 생성
|
||||
|
||||
//생성
|
||||
protected function create_process(array $formDatas): ServerEntity
|
||||
{
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -11,6 +11,41 @@ class ServerHelper extends EquipmentHelper
|
||||
parent::__construct();
|
||||
$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
|
||||
{
|
||||
switch ($field) {
|
||||
@ -19,44 +54,23 @@ class ServerHelper extends EquipmentHelper
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
break;
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'SOFTWARE':
|
||||
case 'DB':
|
||||
$form = $this->form_dropdown_custom(
|
||||
$field,
|
||||
old($field) ?? (array_key_exists('entity', $viewDatas) ? $viewDatas['entity']->getServerPartEntity($field)->getPartInfoUID() : null),
|
||||
$viewDatas,
|
||||
$extras
|
||||
);
|
||||
$cntValue = old("{$field}_cnt");
|
||||
if ($cntValue === null) {
|
||||
$cntValue = isset($viewDatas['entity'])
|
||||
? ($viewDatas['entity']->getServerPartEntity($field)?->getCnt() ?? 1)
|
||||
: 1;
|
||||
}
|
||||
$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
|
||||
);
|
||||
}
|
||||
case 'partinfo_uid_CPU':
|
||||
$form = $this->getServerPartForm($field, 'CPU', $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_RAM':
|
||||
$form = $this->getServerPartForm($field, 'RAM', $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_DISK':
|
||||
$form = $this->getServerPartForm($field, 'DISK', $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_OS':
|
||||
$form = $this->getServerPartForm($field, 'OS', $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_DB':
|
||||
$form = $this->getServerPartForm($field, 'DB', $viewDatas, $extras);
|
||||
break;
|
||||
case 'partinfo_uid_SOFTWARE':
|
||||
$form = $this->getServerPartForm($field, 'SOFTWARE', $viewDatas, $extras);
|
||||
break;
|
||||
case 'ipinfo_uid':
|
||||
case 'csinfo_uid':
|
||||
|
||||
@ -18,12 +18,12 @@ return [
|
||||
"serverpartinfo" => "부품정보",
|
||||
"ipinfo_uid" => "IP정보",
|
||||
"csinfo_uid" => "CS정보",
|
||||
'CPU' => "CPU",
|
||||
'RAM' => "RAM",
|
||||
'DISK' => "DISK",
|
||||
'OS' => "OS",
|
||||
'DB' => "DB",
|
||||
'SOFTWARE' => "기타SW",
|
||||
'partinfo_uid_CPU' => "CPU",
|
||||
'partinfo_uid_RAM' => "RAM",
|
||||
'partinfo_uid_DISK' => "DISK",
|
||||
'partinfo_uid_OS' => "OS",
|
||||
'partinfo_uid_DB' => "DB",
|
||||
'partinfo_uid_SOFTWARE' => "기타SW",
|
||||
],
|
||||
"TITLE" => [
|
||||
'HP DL360 Gen6' => "HP DL360 Gen6",
|
||||
|
||||
@ -58,26 +58,26 @@ class ServerPartService extends EquipmentService
|
||||
return $entity;
|
||||
}
|
||||
//기본 기능부분
|
||||
//FieldForm관련용
|
||||
// FieldForm관련용
|
||||
public function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'partinfo_CPU_uid':
|
||||
case 'partinfo_uid_CPU':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'CPU']);
|
||||
break;
|
||||
case 'partinfo_RAM_uid':
|
||||
case 'partinfo_uid_RAM':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'RAM']);
|
||||
break;
|
||||
case 'partinfo_DISK_uid':
|
||||
case 'partinfo_uid_DISK':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'DISK']);
|
||||
break;
|
||||
case 'partinfo_OS_uid':
|
||||
case 'partinfo_uid_OS':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'OS']);
|
||||
break;
|
||||
case 'partinfo_DB_uid':
|
||||
case 'partinfo_uid_DB':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'DB']);
|
||||
break;
|
||||
case 'partinfo_SOFTWARE_uid':
|
||||
case 'partinfo_uid_SOFTWARE':
|
||||
$options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']);
|
||||
break;
|
||||
case 'partinfo_uid': //수정때문에 전체가 필요
|
||||
@ -93,14 +93,14 @@ class ServerPartService extends EquipmentService
|
||||
private function getFormDatasByServer(ServerEntity $serverEntity, string $partType, array $formDatas): array
|
||||
{
|
||||
$temps = [
|
||||
"partinfo_uid" => $formDatas(["serverpartinfo_{$partType}_uid"]),
|
||||
"partinfo_uid" => $formDatas["partinfo_uid_{$partType}"],
|
||||
"serverinfo_uid" => $serverEntity->getPK(),
|
||||
"serviceinfo_uid" => $serverEntity->getServiceInfoUID(),
|
||||
"type" => $partType,
|
||||
"billing" => $formDatas['billing'] ?? ServerPartENtity::DEFAULT_BILLING,
|
||||
"amount" => $formDatas["amount"] ?? 0,
|
||||
"cnt" => $formDatas["serverpartinfo_{$partType}_uid_cnt"] ?? 1,
|
||||
"extra" => $formDatas["serverpartinfo_{$partType}_uid_extra"] ?? ""
|
||||
"cnt" => $formDatas["serverinfopartinfo_uid_{$partType}_cnt"] ?? 1,
|
||||
"extra" => $formDatas["serverinfopartinfo_uid_{$partType}_extra"] ?? ""
|
||||
];
|
||||
return $temps;
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ class ServerService extends EquipmentService
|
||||
"code",
|
||||
"type",
|
||||
"title",
|
||||
"CPU",
|
||||
"RAM",
|
||||
"DISK",
|
||||
"OS",
|
||||
"partinfo_uid_CPU",
|
||||
"partinfo_uid_RAM",
|
||||
"partinfo_uid_DISK",
|
||||
"partinfo_uid_OS",
|
||||
"ipinfo_uid",
|
||||
"price",
|
||||
"amount",
|
||||
@ -38,10 +38,10 @@ class ServerService extends EquipmentService
|
||||
"serviceinfo_uid",
|
||||
"type",
|
||||
"title",
|
||||
"CPU",
|
||||
"RAM",
|
||||
"DISK",
|
||||
"OS",
|
||||
"partinfo_uid_CPU",
|
||||
"partinfo_uid_RAM",
|
||||
"partinfo_uid_DISK",
|
||||
"partinfo_uid_OS",
|
||||
"ipinfo_uid",
|
||||
"status"
|
||||
],
|
||||
@ -150,23 +150,23 @@ class ServerService extends EquipmentService
|
||||
public function getFormFieldOption(string $field, array $options = []): array
|
||||
{
|
||||
switch ($field) {
|
||||
case 'CPU':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_CPU_uid');
|
||||
case 'partinfo_uid_CPU':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_CPU');
|
||||
break;
|
||||
case 'RAM':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_RAM_uid');
|
||||
case 'partinfo_uid_RAM':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_RAM');
|
||||
break;
|
||||
case 'DISK':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_DISK_uid');
|
||||
case 'partinfo_uid_DISK':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_DISK');
|
||||
break;
|
||||
case 'OS':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_OS_uid');
|
||||
case 'partinfo_uid_OS':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_OS');
|
||||
break;
|
||||
case 'DB':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_DB_uid');
|
||||
case 'partinfo_uid_DB':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_DB');
|
||||
break;
|
||||
case 'SOFTWARE':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_SOFTWARE_uid');
|
||||
case 'partinfo_uid_SOFTWARE':
|
||||
$options = $this->getServerPartService()->getFormFieldOption('partinfo_uid_SOFTWARE');
|
||||
break;
|
||||
case 'ipinfo_uid': //수정때문에 전체가 필요
|
||||
$options = $this->getIPService()->getEntities();
|
||||
@ -212,6 +212,17 @@ class ServerService extends EquipmentService
|
||||
$entity->addIPEntity($this->getIPService()->createByServer($entity, $formDatas));
|
||||
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 검색용
|
||||
//OrderBy 처리
|
||||
|
||||
Loading…
Reference in New Issue
Block a user