dbmsv2 init...1

This commit is contained in:
choi.jh 2025-08-28 17:30:57 +09:00
parent 35c4a86add
commit b113977ec0
7 changed files with 185 additions and 69 deletions

View File

@ -6,6 +6,7 @@ use App\Entities\Equipment\ServerEntity;
use App\Helpers\Equipment\ServerHelper;
use App\Services\Equipment\ServerService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
@ -38,6 +39,28 @@ class ServerController extends EquipmentController
return $this->_helper;
}
//Index,FieldForm관련
protected function getResultSuccess_process(string $message = MESSAGES["SUCCESS"], ?string $actionTemplate = null): RedirectResponse|string
{
switch ($this->getAction()) {
case 'create_form':
case 'modify_form':
case 'index':
$this->control = $this->getControlDatas();
$this->getHelper()->setViewDatas($this->getViewDatas());
$actionTemplate = $this->request->getVar('ActionTemplate') ?? $actionTemplate ?? 'server';
if ($actionTemplate) {
$view_file = $this->view_path . $actionTemplate . DIRECTORY_SEPARATOR . $this->getAction();
} else {
$view_file = $this->view_path . $this->getAction();
}
$result = view($view_file, ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = parent::getResultSuccess_process($message, $actionTemplate);
break;
}
return $result;
}
//생성
protected function create_form_process(): void
{

View File

@ -210,7 +210,7 @@ class CommonHelper
}
// header.php에서 getFieldForm_Helper사용
protected function form_dropdown_custom(string $field, mixed $value, array $viewDatas, array $extras = []): string
public function form_dropdown_custom(string $field, mixed $value, array $viewDatas, array $extras = []): string
{
$extra = "";
foreach ($extras as $extra_tag => $extra_value) {

View File

@ -11,39 +11,21 @@ class ServerHelper extends EquipmentHelper
parent::__construct();
$this->setTitleField(field: ServerModel::TITLE);
}
private function getServerPartForm(string $field, string $type, array $viewDatas, array $extras): string
private function getServerPartForm(string $field, mixed $value, array $viewDatas, array $extras, string $type): string
{
$serverpartEntity = null;
if (array_key_exists('entity', $viewDatas)) {
$serverpartEntity = $viewDatas['entity']->getServerPartEntity($type);
}
$form = "";
if ($serverpartEntity !== null) { //수정시 사용할 uid
if ($serverpartEntity !== null) { //수정시 사용할 hidden 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);
if ($value === null && $serverpartEntity !== null) {
$value = $serverpartEntity->getPartInfoUID();
}
$form .= $this->form_dropdown_custom($field, $value, $viewDatas, $extras);
return $form;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
@ -55,22 +37,22 @@ class ServerHelper extends EquipmentHelper
$form = form_input($field, $value ?? "", $extras);
break;
case 'partinfo_uid_CPU':
$form = $this->getServerPartForm($field, 'CPU', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'CPU');
break;
case 'partinfo_uid_RAM':
$form = $this->getServerPartForm($field, 'RAM', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'RAM',);
break;
case 'partinfo_uid_DISK':
$form = $this->getServerPartForm($field, 'DISK', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DISK');
break;
case 'partinfo_uid_OS':
$form = $this->getServerPartForm($field, 'OS', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'OS');
break;
case 'partinfo_uid_DB':
$form = $this->getServerPartForm($field, 'DB', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'DB');
break;
case 'partinfo_uid_SOFTWARE':
$form = $this->getServerPartForm($field, 'SOFTWARE', $viewDatas, $extras);
$form = $this->getServerPartForm($field, $value, $viewDatas, $extras, 'SOFTWARE');
break;
case 'ipinfo_uid':
case 'csinfo_uid':

View File

@ -22,16 +22,17 @@ class ServerService extends EquipmentService
"code",
"type",
"title",
"partinfo_uid_CPU",
"partinfo_uid_RAM",
"partinfo_uid_DISK",
"partinfo_uid_OS",
"ipinfo_uid",
"price",
"amount",
"manufactur_at",
"format_at",
"status",
"partinfo_uid_CPU",
"partinfo_uid_RAM",
"partinfo_uid_DISK",
"partinfo_uid_OS",
"ipinfo_uid",
"csinfo_uid",
],
'filters' => [
"clientinfo_uid",
@ -43,37 +44,11 @@ class ServerService extends EquipmentService
"partinfo_uid_DISK",
"partinfo_uid_OS",
"ipinfo_uid",
"csinfo_uid",
"status"
],
];
}
public function getViewFields(): array
{
return [
'fields' => [
'clientinfo_uid',
'serviceinfo_uid',
"type",
'title',
'price',
'amount',
"serverpartinfo",
"ipinfo_uid",
"csinfo_uid",
'manufactur_at',
"format_at",
'status'
],
'filters' => [
'clientinfo_uid',
'serviceinfo_uid',
'type',
"ipinfo_uid",
"csinfo_uid",
'status'
],
];
}
public function getIndexFields(): array
{
return [
@ -204,6 +179,7 @@ class ServerService extends EquipmentService
public function create(array $formDatas): ServerEntity
{
$entity = parent::create($formDatas);
dd($entity);
//ServerPart정보 생성
foreach ($this->getServerPartService()->createByServer($entity, $formDatas) as $serverPartEntity) {
$entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
@ -214,13 +190,13 @@ class ServerService extends EquipmentService
}
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));
$entity = parent::modify($entity, $formDatas);
// //ServerPart정보 생성
// foreach ($this->getServerPartService()->modifyByServer($entity, $formDatas) as $serverPartEntity) {
// $entity->addServerPartEntity($serverPartEntity->getType(), $serverPartEntity);
// };
// //IP정보 생성
// $entity->addIPEntity($this->getIPService()->modifyByServer($entity, $formDatas));
return $entity;
}

View File

@ -0,0 +1,37 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<div id="container" class="content">
<div class="form_top"><?= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?></div>
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['control']['field_default_values'][$field] ?? null), $viewDatas) ?>
<span><?= validation_show_error($field); ?></span>
</td>
</tr>
<?php endforeach; ?>
<?php foreach (SERVER['PARTTYPES'] as $type): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['control']['field_default_values']["partinfo_uid_{$type}"] ?? null), $viewDatas) ?>
<?= form_dropdown("partinfo_uid_{$type}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], old("partinfo_uid_{$type}_cnt") ?? 1) . "" ?>
<?php if ($type === "DISK"): ?>
<?= form_dropdown("partinfo_uid_{$type}_extra", $viewDatas['serverinfopartinfo_extra_options'], old("partinfo_uid_{$type}_extra") ?? null) ?>
<?php endif ?>
<span><?= validation_show_error("partinfo_uid_{$type}"); ?></span>
</td>
</tr>
<?php endforeach; ?>
</table>
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
<?= form_close(); ?>
</div>
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
</div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,61 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<div class="layout_top"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/top'); ?></div>
<!-- Layout Middle Start -->
<table class="layout_middle">
<tr>
<td class="layout_left">
<!-- Layout Left Start -->
<?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/left_menu'); ?>
<!-- Layout Left End -->
</td>
<td class="layout_right">
<!-- Layout Right Start -->
<div class="layout_header"><?= $this->include("templates/{$viewDatas['layout']}/index_header"); ?></div>
<div id="container" class="layout_content">
<link href="/css/<?= $viewDatas['layout'] ?>/index.css" media="screen" rel="stylesheet" type="text/css" />
<div class="index_body">
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
<?= form_open(current_url(), ['id' => 'batchjob_form', 'method' => "post"]) ?>
<table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
<thead>
<tr>
<th class="index_head_short_column">번호</th>
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
<th data-rtc-resizable="<?= $field ?>"><?= $viewDatas['helper']->getListLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<?php endforeach ?>
<th class="index_head_short_column">작업</th>
</thead>
<tbody>
<?php $cnt = 0 ?>
<?php foreach ($viewDatas['entities'] as $entity): ?>
<?php $viewDatas['entity'] = $entity; ?>
<tr <?= $viewDatas['entity']->getStatus() === $viewDatas['entity']::DEFAULT_STATUS ? "" : 'class="table-danger"' ?>>
<?php $viewDatas['cnt'] = $viewDatas['total_count'] - (($viewDatas['page'] - 1) * $viewDatas['per_page'] + $cnt); ?>
<td nowrap><?= $viewDatas['helper']->getListButton('modify', '', $viewDatas) ?></td>
<?php foreach ($viewDatas['control']['actionFields'] as $field): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $entity->$field, $viewDatas) ?></td>
<?php endforeach ?>
<td nowrap>
<?= $viewDatas['helper']->getListButton('view', '', $viewDatas) ?>&nbsp;
<?= $viewDatas['helper']->getListButton('history', '', $viewDatas) ?>&nbsp;
<?= $viewDatas['helper']->getListButton('delete', '', $viewDatas) ?>
</td>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>
</tbody>
</table>
<?= $this->include("templates/{$viewDatas['layout']}/index_content_bottom"); ?>
<?= form_close() ?>
</div>
</div>
<div class="layout_footer"><?= $this->include("templates/{$viewDatas['layout']}/index_footer"); ?></div>
<!-- Layout Right End -->
</td>
</tr>
</table>
<!-- Layout Middle End -->
<div class="layout_bottom"><?= $this->include(LAYOUTS[$viewDatas['layout']]['path'] . '/bottom'); ?></div>
<?= $this->endSection() ?>

View File

@ -0,0 +1,37 @@
<?= $this->extend(LAYOUTS[$viewDatas['layout']]['path']) ?>
<?= $this->section('content') ?>
<?php if ($error = session('error')): echo $viewDatas['helper']->alert($error) ?><?php endif ?>
<div id="container" class="content">
<div class="form_top"><?= $this->include("templates/{$viewDatas['layout']}/form_content_top"); ?></div>
<?= form_open(current_url(), $viewDatas['forms']['attributes'], $viewDatas['forms']['hiddens']) ?>
<div class="action_form">
<table class="table table-bordered">
<?php foreach (["code", "type", "title", "price", "amount", "manufactur_at", "format_at", "status",] as $field): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel($field, lang("{$viewDatas['class_path']}.label.{$field}"), $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm($field, old($field) ?? ($viewDatas['entity']->$field ?? null), $viewDatas) ?>
<span><?= validation_show_error($field); ?></span>
</td>
</tr>
<?php endforeach; ?>
<?php foreach (SERVER['PARTTYPES'] as $type): ?>
<tr>
<th nowrap class="text-end"><?= $viewDatas['helper']->getFieldLabel("partinfo_uid_{$type}", lang("{$viewDatas['class_path']}.label.partinfo_uid_{$type}"), $viewDatas) ?></th>
<td nowrap class="text-start">
<?= $viewDatas['helper']->getFieldForm("partinfo_uid_{$type}", old("partinfo_uid_{$type}") ?? ($viewDatas['entity']->getServerPartEntity($type)->getPartInfoUID()), $viewDatas) ?>
<?= form_dropdown("partinfo_uid_{$type}_cnt", $viewDatas['serverinfopartinfo_cnt_range'], old("partinfo_uid_{$type}_cnt") ?? $viewDatas['entity']->getServerPartEntity($type)->getCnt()) . "" ?>
<?php if ($type === "DISK"): ?>
<?= form_dropdown("partinfo_uid_{$type}_extra", $viewDatas['serverinfopartinfo_extra_options'], old("partinfo_uid_{$type}_extra") ?? $viewDatas['entity']->getServerPartEntity($type)->getExtra()) ?>
<?php endif ?>
<span><?= validation_show_error("partinfo_uid_{$type}"); ?></span>
</td>
</tr>
<?php endforeach; ?>
</table>
<div class="text-center"><?= form_submit('', '입력', array("class" => "btn btn-outline btn-primary")); ?></div>
<?= form_close(); ?>
</div>
<div class="form_bottom"><?= $this->include("templates/{$viewDatas['layout']}/form_content_bottom"); ?></div>
</div>
<?= $this->endSection() ?>