diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 319387c..47efb22 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -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'); diff --git a/app/Controllers/AbstractCRUDController.php b/app/Controllers/AbstractCRUDController.php index a380e01..011fa47 100644 --- a/app/Controllers/AbstractCRUDController.php +++ b/app/Controllers/AbstractCRUDController.php @@ -4,7 +4,6 @@ namespace App\Controllers; use App\Entities\CommonEntity; use CodeIgniter\HTTP\RedirectResponse; -use CodeIgniter\Validation\Exceptions\ValidationException; use RuntimeException; /** diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php index 5458020..5caaac8 100644 --- a/app/Controllers/Admin/Equipment/ServerController.php +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -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); + } } diff --git a/app/DTOs/Equipment/ServerDTO.php b/app/DTOs/Equipment/ServerDTO.php index 1d2072f..e3ce604 100644 --- a/app/DTOs/Equipment/ServerDTO.php +++ b/app/DTOs/Equipment/ServerDTO.php @@ -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 = ''; diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index 1566025..5ab98c4 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -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'] ?? ''; diff --git a/app/Forms/Equipment/ServerForm.php b/app/Forms/Equipment/ServerForm.php index 0de5b51..136ec1f 100644 --- a/app/Forms/Equipment/ServerForm.php +++ b/app/Forms/Equipment/ServerForm.php @@ -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())]; } diff --git a/app/Helpers/Equipment/ServerHelper.php b/app/Helpers/Equipment/ServerHelper.php index 7b72bb5..55a6056 100644 --- a/app/Helpers/Equipment/ServerHelper.php +++ b/app/Helpers/Equipment/ServerHelper.php @@ -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; diff --git a/app/Language/ko/Equipment/Server.php b/app/Language/ko/Equipment/Server.php index a61dcdd..e60e98c 100644 --- a/app/Language/ko/Equipment/Server.php +++ b/app/Language/ko/Equipment/Server.php @@ -1,58 +1,59 @@ "서버장비정보", - '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'] => "사용가능", diff --git a/app/Models/Equipment/ServerModel.php b/app/Models/Equipment/ServerModel.php index 9e4d79f..8ce85f1 100644 --- a/app/Models/Equipment/ServerModel.php +++ b/app/Models/Equipment/ServerModel.php @@ -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", diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index ec941a1..0235b3f 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -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) { diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 6b7e20d..0ca5421 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -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 처리 diff --git a/app/Views/admin/server/console.php b/app/Views/admin/server/console.php new file mode 100644 index 0000000..6c18fd1 --- /dev/null +++ b/app/Views/admin/server/console.php @@ -0,0 +1,13 @@ += $this->extend($viewDatas['layout']['layout']) ?> += $this->section('content') ?> += session('message') ? $viewDatas['helper']->alertTrait(session('message')) : ""; ?> +