dbmsv4 init...4
This commit is contained in:
parent
e8569194e4
commit
e767aa1450
@ -217,6 +217,7 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('batchjob', 'ServerController::batchjob');
|
||||
$routes->post('batchjob_delete', 'ServerController::batchjob_delete');
|
||||
$routes->get('download/(:alpha)', 'ServerPartController::download/$1');
|
||||
$routes->post('console/(:num)', 'ServerController::console/$1');
|
||||
});
|
||||
$routes->group('serverpart', function ($routes) {
|
||||
$routes->get('/', 'ServerPartController::index');
|
||||
|
||||
@ -4,7 +4,6 @@ namespace App\Controllers;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use RuntimeException;
|
||||
|
||||
/**
|
||||
|
||||
@ -6,6 +6,7 @@ use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use RuntimeException;
|
||||
|
||||
class ServerController extends EquipmentController
|
||||
{
|
||||
@ -23,7 +24,7 @@ class ServerController extends EquipmentController
|
||||
public function create_form_process(array $formDatas = []): array
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@ -31,4 +32,17 @@ class ServerController extends EquipmentController
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@ class ServerDTO extends CommonDTO
|
||||
public string $title = '';
|
||||
public string $type = '';
|
||||
public string $ip = '';
|
||||
public string $ilo_ip = '';
|
||||
public string $os = '';
|
||||
public int $price = 0;
|
||||
public string $manufactur_at = '';
|
||||
|
||||
@ -6,13 +6,14 @@ use App\Models\Equipment\ServerModel;
|
||||
|
||||
class ServerEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = ServerModel::PK;
|
||||
const PK = ServerModel::PK;
|
||||
const TITLE = ServerModel::TITLE;
|
||||
protected $attributes = [
|
||||
'code' => '',
|
||||
'title' => '',
|
||||
'type' => '',
|
||||
'ip' => '',
|
||||
'ilo_ip' => '',
|
||||
'os' => '',
|
||||
'price' => 0,
|
||||
'manufactur_at' => '',
|
||||
@ -23,19 +24,19 @@ class ServerEntity extends EquipmentEntity
|
||||
{
|
||||
parent::__construct($data);
|
||||
}
|
||||
final public function getClientInfoUid(): int|null
|
||||
final public function getClientInfoUid(): int|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;
|
||||
}
|
||||
final public function getChassisInfoUid(): int|null
|
||||
final public function getChassisInfoUid(): int|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;
|
||||
}
|
||||
@ -56,6 +57,10 @@ class ServerEntity extends EquipmentEntity
|
||||
{
|
||||
return $this->attributes['ip'] ?? '';
|
||||
}
|
||||
public function getIloIP(): string
|
||||
{
|
||||
return $this->attributes['ilo_ip'] ?? '';
|
||||
}
|
||||
public function getOS(): string
|
||||
{
|
||||
return $this->attributes['os'] ?? '';
|
||||
|
||||
@ -16,6 +16,7 @@ class ServerForm extends EquipmentForm
|
||||
"chassisinfo_uid",
|
||||
"switchinfo_uid",
|
||||
"ip",
|
||||
"ilo_ip",
|
||||
"title",
|
||||
"os",
|
||||
"price",
|
||||
@ -28,11 +29,12 @@ class ServerForm extends EquipmentForm
|
||||
"chassisinfo_uid",
|
||||
'switchinfo_uid',
|
||||
'ip',
|
||||
'ilo_ip',
|
||||
'os',
|
||||
"status",
|
||||
];
|
||||
$indexFilter = $filters;
|
||||
$batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'os', 'status'];
|
||||
$indexFilter = $filters;
|
||||
$batchjobFilters = ['type', 'switchinfo_uid', 'ip', 'ilo_ip', 'os', 'status'];
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
case 'create_form':
|
||||
@ -51,6 +53,7 @@ class ServerForm extends EquipmentForm
|
||||
"type",
|
||||
"switchinfo_uid",
|
||||
"ip",
|
||||
"ilo_ip",
|
||||
"title",
|
||||
"os",
|
||||
"part",
|
||||
@ -87,6 +90,7 @@ class ServerForm extends EquipmentForm
|
||||
$formRules[$field] = "required|trim|string";
|
||||
break;
|
||||
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}]" : "");
|
||||
break;
|
||||
case "os":
|
||||
@ -99,7 +103,7 @@ class ServerForm extends EquipmentForm
|
||||
$formRules[$field] = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
$formRules = parent::getFormRule($action, $field, $formRules);
|
||||
break;
|
||||
}
|
||||
return $formRules;
|
||||
@ -110,9 +114,10 @@ class ServerForm extends EquipmentForm
|
||||
$entities = [];
|
||||
switch ($field) {
|
||||
case 'ip':
|
||||
case 'ilo_ip':
|
||||
if (in_array($action, ['create_form', 'modify_form'])) {
|
||||
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]);
|
||||
} else {
|
||||
$entities = parent::getFormOption_process($service, $action, $field, $formDatas);
|
||||
@ -166,7 +171,8 @@ class ServerForm extends EquipmentForm
|
||||
// dd($options);
|
||||
break;
|
||||
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();
|
||||
// $options['attributes'][$tempEntity->getPK()] = ['data-role' => implode(DEFAULTS['DELIMITER_ROLE'], $tempEntity->getRole())];
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ class ServerHelper extends EquipmentHelper
|
||||
case 'serviceinfo_uid':
|
||||
case 'switchinfo_uid':
|
||||
$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;
|
||||
case 'chassisinfo_uid':
|
||||
$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);
|
||||
break;
|
||||
case 'ip':
|
||||
case 'ilo_ip':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
@ -49,6 +50,7 @@ class ServerHelper extends EquipmentHelper
|
||||
$value = $viewDatas['formOptions'][$field]['options'][$value]['text'];
|
||||
break;
|
||||
case 'ip': //값 그대료 표시
|
||||
case 'ilo_ip': //값 그대료 표시
|
||||
break;
|
||||
case 'price':
|
||||
$value = number_format($value) . "원";
|
||||
@ -56,8 +58,8 @@ class ServerHelper extends EquipmentHelper
|
||||
case 'part':
|
||||
$value = view_cell("\App\Cells\Equipment\ServerPartCell::parttable", [
|
||||
'serverinfo_uid' => $viewDatas['entity']->getPK(),
|
||||
'types' => SERVERPART['ALL_PARTTYPES'],
|
||||
'template' => 'serverlist',
|
||||
'types' => SERVERPART['ALL_PARTTYPES'],
|
||||
'template' => 'serverlist',
|
||||
]);
|
||||
break;
|
||||
default:
|
||||
@ -75,6 +77,7 @@ class ServerHelper extends EquipmentHelper
|
||||
switch ($field) {
|
||||
case 'switchinfo_uid':
|
||||
case 'ip':
|
||||
case 'ilo_ip':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$filter = parent::getListFilter($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
|
||||
@ -1,58 +1,59 @@
|
||||
<?php
|
||||
return [
|
||||
'title' => "서버장비정보",
|
||||
'label' => [
|
||||
'title' => "서버장비정보",
|
||||
'label' => [
|
||||
'clientinfo_uid' => "고객번호",
|
||||
'serviceinfo_uid' => "서비스번호",
|
||||
'code' => "장비번호",
|
||||
'type' => "형식",
|
||||
'code' => "장비번호",
|
||||
'type' => "형식",
|
||||
'chassisinfo_uid' => "샷시명",
|
||||
'switchinfo_uid' => "스위치",
|
||||
'ip' => "IP",
|
||||
'os' => "OS",
|
||||
'part' => "부품",
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'ip' => "IP",
|
||||
'ilo_ip' => "ILO IP",
|
||||
'os' => "OS",
|
||||
'part' => "부품",
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'manufactur_at' => "입고일",
|
||||
'format_at' => "포맷보류일",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일",
|
||||
'format_at' => "포맷보류일",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
'created_at' => "작성일",
|
||||
'deleted_at' => "삭제일",
|
||||
"serverpartinfo" => "부품정보",
|
||||
],
|
||||
"TYPE" => [
|
||||
"TYPE" => [
|
||||
'normal' => "일반",
|
||||
'defence' => "방어",
|
||||
'dedicated' => "전용",
|
||||
'vpn' => "VPN",
|
||||
'event' => "이벤트",
|
||||
'test' => "테스트",
|
||||
'dedicated' => "전용",
|
||||
'vpn' => "VPN",
|
||||
'event' => "이벤트",
|
||||
'test' => "테스트",
|
||||
'alternative' => "대체",
|
||||
'inhouse' => "자사용",
|
||||
'colocation' => "코로케이션",
|
||||
'inhouse' => "자사용",
|
||||
'colocation' => "코로케이션",
|
||||
],
|
||||
"OS" => [
|
||||
"CENTOS7" => "CentOS7",
|
||||
"CENTOS8" => "CentOS8",
|
||||
"CENTOS9" => "CentOS9",
|
||||
"CENTOS10" => "CentOS10",
|
||||
"UBUNTU20.04" => "Ubuntu20.04",
|
||||
"UBUNTU22.04" => "Ubuntu22.04",
|
||||
"UBUNTU23.04" => "Ubuntu23.04",
|
||||
"UBUNTU24.04" => "Ubuntu24.04",
|
||||
"UBUNTU25.04" => "Ubuntu25.04",
|
||||
"DEBIAN10" => "Debian10",
|
||||
"DEBIAN11" => "Debian11",
|
||||
"DEBIAN12" => "Debian12",
|
||||
"WINDOWS10" => "Windows10",
|
||||
"WINDOWS11" => "Windows11",
|
||||
"WINDOWS2008R2" => "Windows2008R2",
|
||||
"WINDOWS2012R2" => "Windows2012R2",
|
||||
"WINDOWS2016R2" => "Windows2016R2",
|
||||
"WINDOWS2019R2" => "Windows2019R2",
|
||||
"WINDOWS2022R2" => "Windows2022R2",
|
||||
"WINDOWS2024R2" => "Windows2024R2",
|
||||
"CENTOS7" => "CentOS7",
|
||||
"CENTOS8" => "CentOS8",
|
||||
"CENTOS9" => "CentOS9",
|
||||
"CENTOS10" => "CentOS10",
|
||||
"UBUNTU20.04" => "Ubuntu20.04",
|
||||
"UBUNTU22.04" => "Ubuntu22.04",
|
||||
"UBUNTU23.04" => "Ubuntu23.04",
|
||||
"UBUNTU24.04" => "Ubuntu24.04",
|
||||
"UBUNTU25.04" => "Ubuntu25.04",
|
||||
"DEBIAN10" => "Debian10",
|
||||
"DEBIAN11" => "Debian11",
|
||||
"DEBIAN12" => "Debian12",
|
||||
"WINDOWS10" => "Windows10",
|
||||
"WINDOWS11" => "Windows11",
|
||||
"WINDOWS2008R2" => "Windows2008R2",
|
||||
"WINDOWS2012R2" => "Windows2012R2",
|
||||
"WINDOWS2016R2" => "Windows2016R2",
|
||||
"WINDOWS2019R2" => "Windows2019R2",
|
||||
"WINDOWS2022R2" => "Windows2022R2",
|
||||
"WINDOWS2024R2" => "Windows2024R2",
|
||||
],
|
||||
"STATUS" => [
|
||||
STATUS['AVAILABLE'] => "사용가능",
|
||||
|
||||
@ -9,10 +9,10 @@ class ServerModel extends EquipmentModel
|
||||
const TABLE = "serverinfo";
|
||||
const PK = "uid";
|
||||
const TITLE = "title";
|
||||
protected $table = self::TABLE;
|
||||
protected $table = self::TABLE;
|
||||
// protected $useAutoIncrement = false;
|
||||
protected $primaryKey = self::PK;
|
||||
protected $returnType = ServerEntity::class;
|
||||
protected $primaryKey = self::PK;
|
||||
protected $returnType = ServerEntity::class;
|
||||
protected $allowedFields = [
|
||||
"uid",
|
||||
"user_uid",
|
||||
@ -23,6 +23,7 @@ class ServerModel extends EquipmentModel
|
||||
"chassisinfo_uid",
|
||||
"switchinfo_uid",
|
||||
"ip",
|
||||
"ilo_ip",
|
||||
"os",
|
||||
"title",
|
||||
"price",
|
||||
|
||||
@ -247,7 +247,8 @@ abstract class CommonService
|
||||
protected function create_process(array $formDatas): CommonEntity
|
||||
{
|
||||
try {
|
||||
if ($formService = $this->getFormService()) {
|
||||
$formService = $this->getFormService();
|
||||
if ($formService) {
|
||||
$formService->action_init_process('create', $formDatas);
|
||||
$formService->validate($formDatas);
|
||||
}
|
||||
@ -281,8 +282,10 @@ abstract class CommonService
|
||||
if (!$entity->hasChanged()) {
|
||||
return $entity;
|
||||
}
|
||||
if ($formService = $this->getFormService()) {
|
||||
$formService->validate($entity->toArray());
|
||||
$formService = $this->getFormService();
|
||||
if ($formService) {
|
||||
$formDatas = $entity->toArray();
|
||||
$formService->validate($formDatas);
|
||||
}
|
||||
return $this->save_process($entity);
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
@ -8,7 +8,6 @@ use App\Entities\Equipment\ServerEntity;
|
||||
use App\Forms\Equipment\ServerForm;
|
||||
use App\Helpers\Equipment\ServerHelper;
|
||||
use App\Models\Equipment\ServerModel;
|
||||
use CodeIgniter\Database\Exceptions\DatabaseException;
|
||||
use RuntimeException;
|
||||
|
||||
class ServerService extends EquipmentService
|
||||
@ -177,6 +176,7 @@ class ServerService extends EquipmentService
|
||||
public function setSearchWord(string $word): void
|
||||
{
|
||||
$this->model->orLike($this->model->getTable() . '.ip', $word, 'both');
|
||||
$this->model->orLike($this->model->getTable() . '.ilo_ip', $word, 'both');
|
||||
parent::setSearchWord($word);
|
||||
}
|
||||
//OrderBy 처리
|
||||
|
||||
13
app/Views/admin/server/console.php
Normal file
13
app/Views/admin/server/console.php
Normal 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() ?>
|
||||
Loading…
Reference in New Issue
Block a user