dbmsv4 init...4

This commit is contained in:
최준흠 2026-01-20 09:24:18 +09:00
parent e8569194e4
commit e767aa1450
12 changed files with 109 additions and 62 deletions

View File

@ -217,6 +217,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob', 'ServerController::batchjob'); $routes->post('batchjob', 'ServerController::batchjob');
$routes->post('batchjob_delete', 'ServerController::batchjob_delete'); $routes->post('batchjob_delete', 'ServerController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServerPartController::download/$1'); $routes->get('download/(:alpha)', 'ServerPartController::download/$1');
$routes->post('console/(:num)', 'ServerController::console/$1');
}); });
$routes->group('serverpart', function ($routes) { $routes->group('serverpart', function ($routes) {
$routes->get('/', 'ServerPartController::index'); $routes->get('/', 'ServerPartController::index');

View File

@ -4,7 +4,6 @@ namespace App\Controllers;
use App\Entities\CommonEntity; use App\Entities\CommonEntity;
use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\Validation\Exceptions\ValidationException;
use RuntimeException; use RuntimeException;
/** /**

View File

@ -6,6 +6,7 @@ use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface; use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use RuntimeException;
class ServerController extends EquipmentController class ServerController extends EquipmentController
{ {
@ -23,7 +24,7 @@ class ServerController extends EquipmentController
public function create_form_process(array $formDatas = []): array public function create_form_process(array $formDatas = []): array
{ {
$formDatas = parent::create_form_process($formDatas); $formDatas = parent::create_form_process($formDatas);
$formDatas['code'] = sprintf("%d%dXX-M%d", date("y"), ceil((int)date("m") / 3), $this->service->getNextPK()); $formDatas['code'] = sprintf("%d%dXX-M%d", date("y"), ceil((int) date("m") / 3), $this->service->getNextPK());
return $formDatas; return $formDatas;
} }
@ -31,4 +32,17 @@ class ServerController extends EquipmentController
{ {
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? 'server'); return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? 'server');
} }
public function console(int $uid): string
{
$entity = $this->service->getEntity($uid);
if (!$entity instanceof ServerEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$uid} 서버 정보를 찾을수 없습니다.");
}
$viewDatas = [
'entity' => $entity,
'title' => $entity->getTitle(),
];
return view('admin/server/console', $viewDatas);
}
} }

View File

@ -13,6 +13,7 @@ class ServerDTO extends CommonDTO
public string $title = ''; public string $title = '';
public string $type = ''; public string $type = '';
public string $ip = ''; public string $ip = '';
public string $ilo_ip = '';
public string $os = ''; public string $os = '';
public int $price = 0; public int $price = 0;
public string $manufactur_at = ''; public string $manufactur_at = '';

View File

@ -6,13 +6,14 @@ use App\Models\Equipment\ServerModel;
class ServerEntity extends EquipmentEntity class ServerEntity extends EquipmentEntity
{ {
const PK = ServerModel::PK; const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE; const TITLE = ServerModel::TITLE;
protected $attributes = [ protected $attributes = [
'code' => '', 'code' => '',
'title' => '', 'title' => '',
'type' => '', 'type' => '',
'ip' => '', 'ip' => '',
'ilo_ip' => '',
'os' => '', 'os' => '',
'price' => 0, 'price' => 0,
'manufactur_at' => '', 'manufactur_at' => '',
@ -23,19 +24,19 @@ class ServerEntity extends EquipmentEntity
{ {
parent::__construct($data); parent::__construct($data);
} }
final public function getClientInfoUid(): int|null final public function getClientInfoUid(): int|null
{ {
return $this->attributes['clientinfo_uid'] ?? null; return $this->attributes['clientinfo_uid'] ?? null;
} }
final public function getServiceInfoUid(): int|null final public function getServiceInfoUid(): int|null
{ {
return $this->attributes['serviceinfo_uid'] ?? null; return $this->attributes['serviceinfo_uid'] ?? null;
} }
final public function getChassisInfoUid(): int|null final public function getChassisInfoUid(): int|null
{ {
return $this->attributes['chassisinfo_uid'] ?? null; return $this->attributes['chassisinfo_uid'] ?? null;
} }
final public function getSwitchInfoUid(): int|null final public function getSwitchInfoUid(): int|null
{ {
return $this->attributes['switchinfo_uid'] ?? null; return $this->attributes['switchinfo_uid'] ?? null;
} }
@ -56,6 +57,10 @@ class ServerEntity extends EquipmentEntity
{ {
return $this->attributes['ip'] ?? ''; return $this->attributes['ip'] ?? '';
} }
public function getIloIP(): string
{
return $this->attributes['ilo_ip'] ?? '';
}
public function getOS(): string public function getOS(): string
{ {
return $this->attributes['os'] ?? ''; return $this->attributes['os'] ?? '';

View File

@ -16,6 +16,7 @@ class ServerForm extends EquipmentForm
"chassisinfo_uid", "chassisinfo_uid",
"switchinfo_uid", "switchinfo_uid",
"ip", "ip",
"ilo_ip",
"title", "title",
"os", "os",
"price", "price",
@ -28,11 +29,12 @@ class ServerForm extends EquipmentForm
"chassisinfo_uid", "chassisinfo_uid",
'switchinfo_uid', 'switchinfo_uid',
'ip', 'ip',
'ilo_ip',
'os', 'os',
"status", "status",
]; ];
$indexFilter = $filters; $indexFilter = $filters;
$batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'os', 'status']; $batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'ilo_ip', 'os', 'status'];
switch ($action) { switch ($action) {
case 'create': case 'create':
case 'create_form': case 'create_form':
@ -51,6 +53,7 @@ class ServerForm extends EquipmentForm
"type", "type",
"switchinfo_uid", "switchinfo_uid",
"ip", "ip",
"ilo_ip",
"title", "title",
"os", "os",
"part", "part",
@ -87,6 +90,7 @@ class ServerForm extends EquipmentForm
$formRules[$field] = "required|trim|string"; $formRules[$field] = "required|trim|string";
break; break;
case "ip": //ipv4 , ipv6 , both(ipv4,ipv6) case "ip": //ipv4 , ipv6 , both(ipv4,ipv6)
case "ilo_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($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "");
break; break;
case "os": case "os":
@ -99,7 +103,7 @@ class ServerForm extends EquipmentForm
$formRules[$field] = "permit_empty|valid_date"; $formRules[$field] = "permit_empty|valid_date";
break; break;
default: default:
$formRules = parent::getFormRule($action, $field, $formRules); $formRules = parent::getFormRule($action, $field, $formRules);
break; break;
} }
return $formRules; return $formRules;
@ -110,9 +114,10 @@ class ServerForm extends EquipmentForm
$entities = []; $entities = [];
switch ($field) { switch ($field) {
case 'ip': case 'ip':
case 'ilo_ip':
if (in_array($action, ['create_form', 'modify_form'])) { if (in_array($action, ['create_form', 'modify_form'])) {
if (array_key_exists($field, $formDatas)) { if (array_key_exists($field, $formDatas)) {
$where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $field, $formDatas[$field]); $where = sprintf("status = '%s' OR %s='%s'", STATUS['AVAILABLE'], $field, $formDatas[$field]);
$entities = $service->getEntities([$where => null]); $entities = $service->getEntities([$where => null]);
} else { } else {
$entities = parent::getFormOption_process($service, $action, $field, $formDatas); $entities = parent::getFormOption_process($service, $action, $field, $formDatas);
@ -166,7 +171,8 @@ class ServerForm extends EquipmentForm
// dd($options); // dd($options);
break; break;
case 'ip': //key=value이 같음주의 case 'ip': //key=value이 같음주의
foreach ($this->getFormOption_process(service('part_ipservice'), $action, $field, $formDatas) as $tempEntity) { case 'ilo_ip': //key=value이 같음주의
foreach ($this->getFormOption_process(service('part_ipservice'), $action, 'ip', $formDatas) as $tempEntity) {
$tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle(); $tempOptions[$tempEntity->getTitle()] = $tempEntity->getTitle();
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())]; // $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
} }

View File

@ -17,7 +17,7 @@ class ServerHelper extends EquipmentHelper
case 'serviceinfo_uid': case 'serviceinfo_uid':
case 'switchinfo_uid': case 'switchinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras); $form = form_dropdown($field, $viewDatas['formOptions'][$field]['options'], $value, $extras);
break; break;
case 'chassisinfo_uid': case 'chassisinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
@ -30,6 +30,7 @@ class ServerHelper extends EquipmentHelper
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
break; break;
case 'ip': case 'ip':
case 'ilo_ip':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = parent::getFieldForm($field, $value, $viewDatas, $extras); $form = parent::getFieldForm($field, $value, $viewDatas, $extras);
break; break;
@ -49,6 +50,7 @@ class ServerHelper extends EquipmentHelper
$value = $viewDatas['formOptions'][$field]['options'][$value]['text']; $value = $viewDatas['formOptions'][$field]['options'][$value]['text'];
break; break;
case 'ip': //값 그대료 표시 case 'ip': //값 그대료 표시
case 'ilo_ip': //값 그대료 표시
break; break;
case 'price': case 'price':
$value = number_format($value) . ""; $value = number_format($value) . "";
@ -56,8 +58,8 @@ class ServerHelper extends EquipmentHelper
case 'part': case 'part':
$value = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [ $value = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
'serverinfo_uid' => $viewDatas['entity']->getPK(), 'serverinfo_uid' => $viewDatas['entity']->getPK(),
'types' => SERVERPART['ALL_PARTTYPES'], 'types' => SERVERPART['ALL_PARTTYPES'],
'template' => 'serverlist', 'template' => 'serverlist',
]); ]);
break; break;
default: default:
@ -75,6 +77,7 @@ class ServerHelper extends EquipmentHelper
switch ($field) { switch ($field) {
case 'switchinfo_uid': case 'switchinfo_uid':
case 'ip': case 'ip':
case 'ilo_ip':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$filter = parent::getListFilter($field, $value, $viewDatas, $extras); $filter = parent::getListFilter($field, $value, $viewDatas, $extras);
break; break;

View File

@ -1,58 +1,59 @@
<?php <?php
return [ return [
'title' => "서버장비정보", 'title' => "서버장비정보",
'label' => [ 'label' => [
'clientinfo_uid' => "고객번호", 'clientinfo_uid' => "고객번호",
'serviceinfo_uid' => "서비스번호", 'serviceinfo_uid' => "서비스번호",
'code' => "장비번호", 'code' => "장비번호",
'type' => "형식", 'type' => "형식",
'chassisinfo_uid' => "샷시명", 'chassisinfo_uid' => "샷시명",
'switchinfo_uid' => "스위치", 'switchinfo_uid' => "스위치",
'ip' => "IP", 'ip' => "IP",
'os' => "OS", 'ilo_ip' => "ILO IP",
'part' => "부품", 'os' => "OS",
'title' => "모델명", 'part' => "부품",
'price' => "기본가", 'title' => "모델명",
'price' => "기본가",
'manufactur_at' => "입고일", 'manufactur_at' => "입고일",
'format_at' => "포맷보류일", 'format_at' => "포맷보류일",
'status' => "상태", 'status' => "상태",
'updated_at' => "수정일", 'updated_at' => "수정일",
'created_at' => "작성일", 'created_at' => "작성일",
'deleted_at' => "삭제일", 'deleted_at' => "삭제일",
"serverpartinfo" => "부품정보", "serverpartinfo" => "부품정보",
], ],
"TYPE" => [ "TYPE" => [
'normal' => "일반", 'normal' => "일반",
'defence' => "방어", 'defence' => "방어",
'dedicated' => "전용", 'dedicated' => "전용",
'vpn' => "VPN", 'vpn' => "VPN",
'event' => "이벤트", 'event' => "이벤트",
'test' => "테스트", 'test' => "테스트",
'alternative' => "대체", 'alternative' => "대체",
'inhouse' => "자사용", 'inhouse' => "자사용",
'colocation' => "코로케이션", 'colocation' => "코로케이션",
], ],
"OS" => [ "OS" => [
"CENTOS7" => "CentOS7", "CENTOS7" => "CentOS7",
"CENTOS8" => "CentOS8", "CENTOS8" => "CentOS8",
"CENTOS9" => "CentOS9", "CENTOS9" => "CentOS9",
"CENTOS10" => "CentOS10", "CENTOS10" => "CentOS10",
"UBUNTU20.04" => "Ubuntu20.04", "UBUNTU20.04" => "Ubuntu20.04",
"UBUNTU22.04" => "Ubuntu22.04", "UBUNTU22.04" => "Ubuntu22.04",
"UBUNTU23.04" => "Ubuntu23.04", "UBUNTU23.04" => "Ubuntu23.04",
"UBUNTU24.04" => "Ubuntu24.04", "UBUNTU24.04" => "Ubuntu24.04",
"UBUNTU25.04" => "Ubuntu25.04", "UBUNTU25.04" => "Ubuntu25.04",
"DEBIAN10" => "Debian10", "DEBIAN10" => "Debian10",
"DEBIAN11" => "Debian11", "DEBIAN11" => "Debian11",
"DEBIAN12" => "Debian12", "DEBIAN12" => "Debian12",
"WINDOWS10" => "Windows10", "WINDOWS10" => "Windows10",
"WINDOWS11" => "Windows11", "WINDOWS11" => "Windows11",
"WINDOWS2008R2" => "Windows2008R2", "WINDOWS2008R2" => "Windows2008R2",
"WINDOWS2012R2" => "Windows2012R2", "WINDOWS2012R2" => "Windows2012R2",
"WINDOWS2016R2" => "Windows2016R2", "WINDOWS2016R2" => "Windows2016R2",
"WINDOWS2019R2" => "Windows2019R2", "WINDOWS2019R2" => "Windows2019R2",
"WINDOWS2022R2" => "Windows2022R2", "WINDOWS2022R2" => "Windows2022R2",
"WINDOWS2024R2" => "Windows2024R2", "WINDOWS2024R2" => "Windows2024R2",
], ],
"STATUS" => [ "STATUS" => [
STATUS['AVAILABLE'] => "사용가능", STATUS['AVAILABLE'] => "사용가능",

View File

@ -9,10 +9,10 @@ class ServerModel extends EquipmentModel
const TABLE = "serverinfo"; const TABLE = "serverinfo";
const PK = "uid"; const PK = "uid";
const TITLE = "title"; const TITLE = "title";
protected $table = self::TABLE; protected $table = self::TABLE;
// protected $useAutoIncrement = false; // protected $useAutoIncrement = false;
protected $primaryKey = self::PK; protected $primaryKey = self::PK;
protected $returnType = ServerEntity::class; protected $returnType = ServerEntity::class;
protected $allowedFields = [ protected $allowedFields = [
"uid", "uid",
"user_uid", "user_uid",
@ -23,6 +23,7 @@ class ServerModel extends EquipmentModel
"chassisinfo_uid", "chassisinfo_uid",
"switchinfo_uid", "switchinfo_uid",
"ip", "ip",
"ilo_ip",
"os", "os",
"title", "title",
"price", "price",

View File

@ -247,7 +247,8 @@ abstract class CommonService
protected function create_process(array $formDatas): CommonEntity protected function create_process(array $formDatas): CommonEntity
{ {
try { try {
if ($formService = $this->getFormService()) { $formService = $this->getFormService();
if ($formService) {
$formService->action_init_process('create', $formDatas); $formService->action_init_process('create', $formDatas);
$formService->validate($formDatas); $formService->validate($formDatas);
} }
@ -281,8 +282,10 @@ abstract class CommonService
if (!$entity->hasChanged()) { if (!$entity->hasChanged()) {
return $entity; return $entity;
} }
if ($formService = $this->getFormService()) { $formService = $this->getFormService();
$formService->validate($entity->toArray()); if ($formService) {
$formDatas = $entity->toArray();
$formService->validate($formDatas);
} }
return $this->save_process($entity); return $this->save_process($entity);
} catch (\Throwable $e) { } catch (\Throwable $e) {

View File

@ -8,7 +8,6 @@ use App\Entities\Equipment\ServerEntity;
use App\Forms\Equipment\ServerForm; use App\Forms\Equipment\ServerForm;
use App\Helpers\Equipment\ServerHelper; use App\Helpers\Equipment\ServerHelper;
use App\Models\Equipment\ServerModel; use App\Models\Equipment\ServerModel;
use CodeIgniter\Database\Exceptions\DatabaseException;
use RuntimeException; use RuntimeException;
class ServerService extends EquipmentService class ServerService extends EquipmentService
@ -177,6 +176,7 @@ class ServerService extends EquipmentService
public function setSearchWord(string $word): void public function setSearchWord(string $word): void
{ {
$this->model->orLike($this->model->getTable() . '.ip', $word, 'both'); $this->model->orLike($this->model->getTable() . '.ip', $word, 'both');
$this->model->orLike($this->model->getTable() . '.ilo_ip', $word, 'both');
parent::setSearchWord($word); parent::setSearchWord($word);
} }
//OrderBy 처리 //OrderBy 처리

View File

@ -0,0 +1,13 @@
<?= $this->extend($viewDatas['layout']['layout']) ?>
<?= $this->section('content') ?>
<?= session('message') ? $viewDatas['helper']->alertTrait(session('message')) : ""; ?>
<div id="container" class="content">
<div class="form_top"><?= $this->include("{$viewDatas['layout']['template']}/form_content_top"); ?></div>
<a href="https://<?= esc($viewDatas['entity']->getIloIP()) ?>" target="_blank">
Open iLO HTML5 Console
</a>
<?php if (session('message')): ?>
<div class="alert alert-danger text-start"><?= nl2br(session('message')) ?></div><?php endif; ?>
<div class="form_bottom"><?= $this->include("{$viewDatas['layout']['template']}/form_content_bottom"); ?></div>
</div>
<?= $this->endSection() ?>