dbmsv2 init...1
This commit is contained in:
parent
93e82b1104
commit
6889d58063
@ -3,6 +3,7 @@
|
||||
namespace App\Cells\Equipment;
|
||||
|
||||
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Services\Equipment\ServerPartService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
|
||||
@ -24,40 +25,37 @@ class ServerPartCell extends EquipmentCell
|
||||
|
||||
public function parttable(array $params): string
|
||||
{
|
||||
$result = "";
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
$entities = [];
|
||||
$serverEntity = null;
|
||||
if (array_key_exists('serverinfo_uid', $params)) {
|
||||
$this->getService()->setAction(__FUNCTION__);
|
||||
$this->getService()->setFormFields();
|
||||
$this->getService()->setFormFilters();
|
||||
$this->getService()->setFormRules();
|
||||
$this->getService()->setFormOptions();
|
||||
// dd($params);
|
||||
//서버정보
|
||||
$serverEntity = $this->getServerService()->getEntity($params['serverinfo_uid']);
|
||||
if (!$serverEntity) {
|
||||
return "[{$params['serverinfo_uid']}]에 해당하는 서버정보가 지정되지 않았거나 존재하지 않습니다.";
|
||||
}
|
||||
//서버파트정보
|
||||
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $serverEntity->getPK(),]);
|
||||
$entities = [];
|
||||
foreach ($serverPartEntities as $entity) {
|
||||
if (!array_key_exists($entity->getType(), $entities)) {
|
||||
$entities[$entity->getType()] = [];
|
||||
if ($serverEntity instanceof ServerEntity) {
|
||||
//서버파트정보
|
||||
$serverPartEntities = $this->getService()->getEntities(['serverinfo_uid' => $serverEntity->getPK(),]);
|
||||
foreach ($serverPartEntities as $entity) {
|
||||
if (!array_key_exists($entity->getType(), $entities)) {
|
||||
$entities[$entity->getType()] = [];
|
||||
}
|
||||
$entities[$entity->getType()][] = $entity;
|
||||
}
|
||||
$entities[$entity->getType()][] = $entity;
|
||||
}
|
||||
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
|
||||
$result = view('cells/serverpart/' . $template, [
|
||||
'serverPartCellDatas' => [
|
||||
'control' => $this->getService()->getControlDatas(),
|
||||
'service' => $this->getService(),
|
||||
'serverinfo_uid' => $params['serverinfo_uid'],
|
||||
'entities' => $entities,
|
||||
'serverEntity' => $serverEntity,
|
||||
'types' => $params['types'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
return $result;
|
||||
$template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__;
|
||||
return view('cells/serverpart/' . $template, [
|
||||
'serverPartCellDatas' => [
|
||||
'control' => $this->getService()->getControlDatas(),
|
||||
'service' => $this->getService(),
|
||||
'serverinfo_uid' => $params['serverinfo_uid'],
|
||||
'entities' => $entities,
|
||||
'serverEntity' => $serverEntity,
|
||||
'types' => $params['types'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,12 +6,12 @@ use CodeIgniter\Entity\Entity;
|
||||
|
||||
abstract class CommonEntity extends Entity
|
||||
{
|
||||
const DEFAULT_STATUS = "";
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
//사용법 : $client->created_at->format('Y-m-d')
|
||||
//비교방법 : if ($client->created_at < new \DateTime('2024-01-01')) {
|
||||
protected $casts = [];
|
||||
|
||||
public function __construct(array|null $data = null)
|
||||
{
|
||||
parent::__construct($data);
|
||||
|
||||
@ -8,8 +8,6 @@ class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
const PK = ServerPartModel::PK;
|
||||
const TITLE = ServerPartModel::TITLE;
|
||||
const DEFAULT_STATUS = null;
|
||||
|
||||
public function setPartEntity(mixed $entity): ServerPartEntity
|
||||
{
|
||||
$this->attributes['partEntity'] = $entity;
|
||||
@ -56,4 +54,8 @@ class ServerPartEntity extends EquipmentEntity
|
||||
{
|
||||
return $this->attributes['extra'] ?? "";
|
||||
}
|
||||
public function getStatus(): string
|
||||
{
|
||||
return self::DEFAULT_STATUS;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities;
|
||||
|
||||
class FormOptionEntity extends CommonEntity
|
||||
{
|
||||
const PK = "uid";
|
||||
const TITLE = "title";
|
||||
const DEFAULT_STATUS = null;
|
||||
}
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
namespace App\Helpers;
|
||||
|
||||
use App\Entities\CommonEntity;
|
||||
|
||||
class CommonHelper
|
||||
{
|
||||
private $_myAuth = null;
|
||||
@ -231,16 +233,22 @@ class CommonHelper
|
||||
$html = "";
|
||||
switch ($field) {
|
||||
default:
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
||||
$isSelected = $key == $value ? ' selected' : '';
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
|
||||
$isSelected = $option_key == $value ? ' selected' : '';
|
||||
$isDisabled = "";
|
||||
$attribute = "";
|
||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $attribute_value);
|
||||
$label = "";
|
||||
if ($option_value instanceof CommonEntity) {
|
||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
|
||||
$html = " disabled";
|
||||
}
|
||||
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
|
||||
$label .= $option_value->getCustomTitle();
|
||||
} else {
|
||||
$label = $option_value;
|
||||
}
|
||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
||||
$title .= $entity->getCustomTitle();
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -12,34 +12,6 @@ class ServiceHelper extends CustomerHelper
|
||||
parent::__construct();
|
||||
$this->setTitleField(field: ServiceModel::TITLE);
|
||||
}
|
||||
protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
|
||||
{
|
||||
$html = "";
|
||||
switch ($field) {
|
||||
case 'serverinfo_uid':
|
||||
$attribute = "";
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
||||
$isSelected = $key == $value ? ' selected' : '';
|
||||
$isDisabled = "";
|
||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||
if ($entity->getStatus() != $entity::DEFAULT_STATUS)
|
||||
$isDisabled = " disabled";
|
||||
}
|
||||
$attribute = "";
|
||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof ServerEntity ? $entity->$attribute_value() : $attribute_value);
|
||||
}
|
||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
||||
$title .= $entity->getCustomTitle();
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$html = parent::form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes);
|
||||
break;
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Helpers\Equipment;
|
||||
|
||||
use App\Entities\Equipment\PartEntity;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
|
||||
class ServerPartHelper extends EquipmentHelper
|
||||
@ -17,21 +17,22 @@ class ServerPartHelper extends EquipmentHelper
|
||||
$html = "";
|
||||
switch ($field) {
|
||||
case 'part_uid':
|
||||
$attribute = "";
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $key => $entity) {
|
||||
$isSelected = $key == $value ? ' selected' : '';
|
||||
$isDisabled = "";
|
||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||
if ($entity->getStatus() != $entity::DEFAULT_STATUS)
|
||||
$isDisabled = " disabled";
|
||||
foreach ($viewDatas['control']['field_optons'][$field] as $option_key => $option_value) {
|
||||
$isSelected = $option_key == $value ? ' selected' : '';
|
||||
$isDisabled = "";
|
||||
$attribute = "";
|
||||
$label = "";
|
||||
if ($option_value instanceof CommonEntity) {
|
||||
if (in_array($viewDatas['control']['action'], ['create_form', 'index'])) {
|
||||
if ($option_value->getStatus() != $option_value::DEFAULT_STATUS)
|
||||
$html = " disabled";
|
||||
}
|
||||
$label = $option_value->getStatus() != $option_value::DEFAULT_STATUS ? "X." : "";
|
||||
$label .= $option_value->getCustomTitle();
|
||||
} else {
|
||||
$label = $option_value;
|
||||
}
|
||||
$attribute = "";
|
||||
foreach ($attributes as $attribute_tag => $attribute_value) {
|
||||
$attribute .= sprintf(" %s=\"%s\"", $attribute_tag, $entity instanceof PartEntity ? $entity->$attribute_value() : $attribute_value);
|
||||
}
|
||||
$title = $entity->getStatus() != $entity::DEFAULT_STATUS ? "서비스중." : "";
|
||||
$title .= $entity->getCustomTitle();
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $key, $isSelected, $isDisabled, $attribute, $title);
|
||||
$html .= sprintf("<option value=\"%s\"%s%s%s>%s</option>", $option_key, $isSelected, $isDisabled, $attribute, $label);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -65,6 +66,7 @@ class ServerPartHelper extends EquipmentHelper
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
echo "Field:{$field}";
|
||||
return $form;
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
|
||||
@ -235,14 +235,7 @@ abstract class CommonService
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$formOptionDatas = lang($this->getClassName() . '.' . strtoupper($field));
|
||||
if (!is_array($formOptionDatas)) {
|
||||
throw new \Exception(__FUNCTION__ . "에서 {$field}}의 formOptionDatas 값이 array가 아닙니다.\n" . var_export($formOptionDatas, true));
|
||||
}
|
||||
$options = [];
|
||||
foreach ($formOptionDatas as $key => $value) {
|
||||
$options[$key] = new FormOptionEntity(['uid' => $key, 'title' => $value]);
|
||||
}
|
||||
$options = lang($this->getClassName() . '.' . strtoupper($field));
|
||||
break;
|
||||
}
|
||||
if (!is_array($options)) {
|
||||
|
||||
@ -57,8 +57,8 @@ class ServerPartService extends EquipmentService
|
||||
{
|
||||
return [
|
||||
"serverinfo_uid",
|
||||
"type",
|
||||
"part_uid",
|
||||
"type",
|
||||
"billing",
|
||||
];
|
||||
}
|
||||
@ -122,29 +122,30 @@ class ServerPartService extends EquipmentService
|
||||
{
|
||||
switch ($field) {
|
||||
case 'part_uid':
|
||||
$type = $this->getFormDatas()['type'] ?? null;
|
||||
switch ($type) {
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'DB':
|
||||
case 'SOFTWARE':
|
||||
$options = $this->getPartService()->getEntities(['type' => $type]);
|
||||
break;
|
||||
case 'SWITCH':
|
||||
$options = $this->getSwitchService()->getEntities();
|
||||
break;
|
||||
case 'IP':
|
||||
$options = $this->getIPService()->getEntities();
|
||||
break;
|
||||
case 'CS':
|
||||
$options = $this->getCSService()->getEntities();
|
||||
break;
|
||||
default:
|
||||
$options = [];
|
||||
break;
|
||||
$partOptions = [];
|
||||
foreach (SERVERPART['PARTTYPES'] as $partType) {
|
||||
switch ($partType) {
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'OS':
|
||||
case 'DB':
|
||||
case 'SOFTWARE':
|
||||
$partOptions[$partType] = $this->getPartService()->getEntities(['type' => $partType]);
|
||||
break;
|
||||
case 'SWITCH':
|
||||
$partOptions[$partType] = $this->getSwitchService()->getEntities();
|
||||
break;
|
||||
case 'IP':
|
||||
$partOptions[$partType] = $this->getIPService()->getEntities();
|
||||
break;
|
||||
case 'CS':
|
||||
$partOptions[$partType] = $this->getCSService()->getEntities();
|
||||
break;
|
||||
}
|
||||
}
|
||||
$options = $partOptions;
|
||||
// dd($options);
|
||||
break;
|
||||
default:
|
||||
$options = parent::getFormOption($field, $options);
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
<?php $htmls = $texts = [$serverPartCellDatas['serverEntity']->getCode()] ?>
|
||||
<?php $htmls = $texts = [!$serverPartCellDatas['serverEntity'] ? "" : $serverPartCellDatas['serverEntity']->getCode()] ?>
|
||||
<?php foreach (['SWITCH', 'IP', 'OS'] as $type): ?>
|
||||
<?php $texts[] = $serverPartCellDatas['service']->getHelper()->getFieldView($type, '', $serverPartCellDatas, ['return_type' => 'text']); ?>
|
||||
<?php $button = $serverPartCellDatas['service']->getHelper()->getListButton($type, '', $serverPartCellDatas) ?>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user