dbms_init...1

This commit is contained in:
최준흠 2025-05-20 18:50:49 +09:00
parent 62883a4321
commit eee680feb0
20 changed files with 335 additions and 127 deletions

View File

@ -7,12 +7,14 @@ use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Services\Customer\ServiceService;
use App\Services\Customer\AccountService;
use App\Services\Customer\CouponService;
use App\Services\Customer\PointService;
abstract class CustomerController extends AdminController
{
private ?ServiceService $_serviceService = null;
private ?AccountService $_accountService = null;
private ?CouponService $_couponService = null;
private ?PointService $_pointService = null;
@ -22,6 +24,14 @@ abstract class CustomerController extends AdminController
$this->uri_path .= 'customer/';
// $this->view_path .= "customer" . DIRECTORY_SEPARATOR;
}
final public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService($this->request);
}
return $this->_serviceService;
}
final public function getAccountService(): AccountService
{
if (!$this->_accountService) {

View File

@ -2,23 +2,28 @@
namespace App\Controllers\Admin\Customer;
use App\Services\Equipment\ServerService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use CodeIgniter\Validation\Validation;
use Psr\Log\LoggerInterface;
use App\Entities\Customer\ServicePartEntity;
use App\Services\Customer\ServicePartService;
use App\Entities\Customer\ServiceEntity;
use App\Helpers\Customer\ServiceHelper;
use App\Services\Customer\ServiceService;
use App\Services\Equipment\ServerService;
use App\Entities\Customer\ServiceServerEntity;
use App\Services\Customer\ServiceServerService;
use App\Services\Equipment\PartService;
use App\Services\Customer\ServicePartService;
use App\Services\Equipment\IpService;
class ServiceController extends CustomerController
{
private ?ServerService $_serverService = null;
private ?ServiceServerService $_serviceServerService = null;
private ?PartService $_partService = null;
private ?ServicePartService $_servicePartService = null;
private ?IpService $_ipService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
@ -28,8 +33,8 @@ class ServiceController extends CustomerController
$this->class_path = $this->getService()->getClassPath();
$this->title = lang("{$this->getService()->getClassPath()}.title");
$this->helper = $this->getHelper();
$this->individualStylesheets = ['server_partinfo.css'];
$this->individualScripts = ['server_partinfo.js'];
// $this->individualStylesheets = ['server_partinfo.css'];
// $this->individualScripts = ['server_partinfo.js'];
}
public function getService(): ServiceService
{
@ -52,6 +57,13 @@ class ServiceController extends CustomerController
}
return $this->_serverService;
}
final public function getServiceServerService(): ServiceServerService
{
if (!$this->_serviceServerService) {
$this->_serviceServerService = new ServiceServerService($this->request);
}
return $this->_serviceServerService;
}
final public function getPartService(): PartService
{
if (!$this->_partService) {
@ -59,6 +71,13 @@ class ServiceController extends CustomerController
}
return $this->_partService;
}
final public function getServicePartService(): ServicePartService
{
if (!$this->_servicePartService) {
$this->_servicePartService = new ServicePartService($this->request);
}
return $this->_servicePartService;
}
final public function getIpService(): IpService
{
if (!$this->_ipService) {
@ -81,7 +100,7 @@ class ServiceController extends CustomerController
protected function index_process(): array
{
$fields = [
'fields' => ['type', 'model', 'IP', 'SERVER', 'CPU', 'RAM', 'DISK', 'status'],
'fields' => ['type', 'billing_at', 'rack', 'SERVER', 'IP', 'CPU', 'RAM', 'DISK', 'SOFTWARE', 'DEFENCE', 'start_at', 'status'],
];
$this->init('index', $fields);
$this->modal_type = 'modal_iframe';

View File

@ -46,7 +46,7 @@ class ServicePartController extends CustomerController
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'serverinfo_uid':
case 'serviceinfo_uid':
$options[$field] = $this->getServiceService()->getFormFieldOption($field);
break;
case 'partinfo_uid':
@ -78,13 +78,13 @@ class ServicePartController extends CustomerController
protected function setOrderByForList()
{
//OrderBy 처리
$this->getService()->getModel()->orderBy('serverinfo_uid', 'ASC', false);
$this->getService()->getModel()->orderBy('serviceinfo_uid', 'ASC', false);
parent::setOrderByForList();
}
protected function index_process(): array
{
$fields = [
'fields' => ['serverinfo_uid', 'type', 'partinfo_uid'],
'fields' => ['serviceinfo_uid', 'type', 'partinfo_uid'],
];
$this->init('index', $fields);
$this->modal_type = 'modal_iframe';

View File

@ -13,7 +13,6 @@ use App\Services\Equipment\ServerService;
abstract class EquipmentController extends AdminController
{
private ?ServerService $_serverService = null;
private ?LineService $_lineService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -27,26 +26,5 @@ abstract class EquipmentController extends AdminController
}
return $this->_serverService;
}
final public function getLineService(): LineService
{
if (!$this->_lineService) {
$this->_lineService = new LineService($this->request);
}
return $this->_lineService;
}
//Index,FieldForm관련
protected function getFormFieldOption(string $field, array $options = []): array
{
switch ($field) {
case 'lineinfo_uid':
$options[$field] = $this->getLineService()->getFormFieldOption($field);
// echo $this->getUserModel()->getLastQuery();
// dd($options);
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
}

View File

@ -6,13 +6,11 @@ use App\Entities\Equipment\ServerEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use CodeIgniter\Validation\Validation;
use App\Helpers\Equipment\ServerHelper;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\PartService;
use App\Services\Equipment\ServerPartService;
use App\Entities\Equipment\ServerPartEntity;
class ServerController extends EquipmentController
{
@ -26,8 +24,8 @@ class ServerController extends EquipmentController
$this->class_path = $this->getService()->getClassPath();
$this->title = lang("{$this->getService()->getClassPath()}.title");
$this->helper = $this->getHelper();
$this->individualStylesheets = ['server_partinfo.css'];
$this->individualScripts = ['server_partinfo.js'];
// $this->individualStylesheets = ['server_partinfo.css'];
// $this->individualScripts = ['server_partinfo.js'];
}
public function getService(): ServerService
{

View File

@ -4,9 +4,9 @@
"settings": {
"width": 4000,
"height": 4000,
"scrollTop": -2252.9128,
"scrollLeft": -992.9859,
"zoomLevel": 0.88,
"scrollTop": -1517.2462,
"scrollLeft": -620.6366,
"zoomLevel": 0.73,
"show": 511,
"database": 4,
"databaseName": "",
@ -385,6 +385,7 @@
"columnIds": [
"nb5CGzskl3_LIRA0yyede",
"sscrxOdwLlx94tx1j_MrH",
"jN2378kieoBKN-G1x8myT",
"iM3NfWTfO6qrXv94EUFgk",
"lwr6RuK8OGKJNLdd70NGS",
"qnVCOfUyejx2ToAQhkmu0",
@ -400,6 +401,7 @@
"JXFtN33CEiVr8DDSQay0k",
"CY-ZAs3Ns1YhoxL9UiCee",
"UKMpq-uPW9JhNhwRMtBmC",
"jN2378kieoBKN-G1x8myT",
"iM3NfWTfO6qrXv94EUFgk",
"CITRNBpXOZqGM6gHy5MlB",
"lwr6RuK8OGKJNLdd70NGS",
@ -421,7 +423,7 @@
"color": ""
},
"meta": {
"updateAt": 1747727821087,
"updateAt": 1747733939677,
"createAt": 1745819764139
}
},
@ -2155,7 +2157,7 @@
"widthDefault": 60
},
"meta": {
"updateAt": 1747125258424,
"updateAt": 1747733895712,
"createAt": 1745819764139
}
},
@ -5006,7 +5008,7 @@
"comment": "종료일",
"dataType": "DATE",
"default": "",
"options": 0,
"options": 5,
"ui": {
"keys": 0,
"widthName": 60,
@ -5015,7 +5017,7 @@
"widthDefault": 60
},
"meta": {
"updateAt": 1747371193639,
"updateAt": 1747733901576,
"createAt": 1747277755303
}
},
@ -6418,6 +6420,26 @@
"updateAt": 1747638862777,
"createAt": 1747632565731
}
},
"jN2378kieoBKN-G1x8myT": {
"id": "jN2378kieoBKN-G1x8myT",
"tableId": "kc1EFvFhlBSc0B0bDgX28",
"name": "rack",
"comment": "Rack번호",
"dataType": "VARCHAR(10)",
"default": "",
"options": 8,
"ui": {
"keys": 0,
"widthName": 60,
"widthComment": 60,
"widthDataType": 75,
"widthDefault": 60
},
"meta": {
"updateAt": 1747733996079,
"createAt": 1747733912998
}
}
},
"relationshipEntities": {
@ -6469,7 +6491,7 @@
"sscrxOdwLlx94tx1j_MrH"
],
"x": 686.1378,
"y": 1674.3461,
"y": 1678.488957142857,
"direction": 2
},
"meta": {
@ -6488,7 +6510,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1810.3461,
"y": 1847.631814285714,
"direction": 2
},
"end": {
@ -6516,7 +6538,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1844.3461,
"y": 1889.9175285714282,
"direction": 2
},
"end": {
@ -6572,7 +6594,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1776.3461,
"y": 1805.3460999999998,
"direction": 2
},
"end": {
@ -6737,9 +6759,9 @@
"columnIds": [
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1912.3461,
"direction": 2
"x": 432.13779999999997,
"y": 1953.3461,
"direction": 8
},
"end": {
"tableId": "gYqhvNLZjWrQk8LNKH3il",
@ -6878,7 +6900,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1742.3461,
"y": 1763.0603857142855,
"direction": 2
},
"end": {
@ -6934,7 +6956,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1708.3461,
"y": 1720.7746714285713,
"direction": 2
},
"end": {
@ -7018,7 +7040,7 @@
"nb5CGzskl3_LIRA0yyede"
],
"x": 686.1378,
"y": 1878.3461,
"y": 1932.2032428571424,
"direction": 2
},
"end": {

View File

@ -2,10 +2,24 @@
namespace App\Entities\Customer;
use App\Entities\Equipment\PartEntity;
use App\Models\Customer\ServiceModel;
class ServiceEntity extends CustomerEntity
{
const PK = ServiceModel::PK;
const TITLE = ServiceModel::TITLE;
public function getPartEntities(string $type): array
{
return $this->attributes[$type] ?? [];
}
public function addPartEntity(string $type, PartEntity $partEntity): void
{
if (!isset($this->attributes[$type])) {
$this->attributes[$type] = [];
}
$this->attributes[$type][] = $partEntity;
// $this->attributes[$type] = array_unique($this->attributes[$type], SORT_REGULAR);
}
}

View File

@ -11,7 +11,7 @@ class ServicePartEntity extends CustomerEntity
public function getServiceInfo()
{
return $this->attributes['erviceinfo_uid'];
return $this->attributes['serviceinfo_uid'];
}
public function getPartInfo()

View File

@ -0,0 +1,21 @@
<?php
namespace App\Entities\Customer;
use App\Models\Customer\ServiceServerModel;
class ServiceServerEntity extends CustomerEntity
{
const PK = ServiceServerModel::PK;
const TITLE = ServiceServerModel::TITLE;
public function getServiceInfo()
{
return $this->attributes['serviceinfo_uid'];
}
public function getServerInfo()
{
return $this->attributes['serverinfo_uid'];
}
}

View File

@ -13,43 +13,38 @@ class ServiceHelper extends CustomerHelper
parent::__construct($request);
$this->setTitleField(field: ServiceModel::TITLE);
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{
if (in_array($viewDatas['action'], ['create', 'modify'])) {
$extras = (strpos($viewDatas['field_rules'][$field], 'required') !== false) ? ["class" => "form-control", "required" => "", ...$extras] : ["class" => "form-control", ...$extras];
}
$value = $viewDatas['entity']->$field ?? "";
switch ($field) {
case 'CPU':
case 'RAM':
case 'DISK':
if (!is_array($viewDatas['field_options'][$field])) {
throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
}
if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) {
$form = " <button type=\"button\" class=\"server_partinfo_layer_btn\" onclick=\"openLayer('{$field}')\">" . lang($viewDatas['class_path'] . '.label.' . $field) . " 추가</button>";
$form .= "<div id=\"{$field}_layer\" class=\"server_partinfo_layer\" style=\"display: none;\">";
$form .= "<div class=\"server_partinfo_layer_inner\">";
$form .= "<ul class=\"server_partinfo_item_list\">";
foreach ($viewDatas['field_options'][$field] as $key => $label) {
$form .= "<li><label onclick=\"addComponentFromLabel('{$field}', {$key},'{$label}')\">{$label}</label></li>";
}
$form .= "</ul>";
$form .= "<button type=\"button\" onclick=\"closeLayer('{$field}')\">닫기</button>";
$form .= "</div></div>";
$form .= "<div id=\"{$field}_list\" class=\"server_partinfo_items\" style=\"border:1px solid silver\"></div>";
} else {
$extra_class = isset($extras['class']) ? $extras['class'] . ' select-field' : 'select-field';
$formOptions = ["" => lang($viewDatas['class_path'] . '.label.' . $field) . ' 선택'];
foreach ($viewDatas['field_options'][$field] as $key => $label) {
$formOptions[$key] = $label;
}
$form = form_dropdown($field, $formOptions, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
case "SERVER":
case "IP":
case "CPU":
case "RAM":
case "DISK":
case "DEFENCE":
case "SOFTWARE":
$temps = [];
foreach ($viewDatas['entity']->getPartEntities($field) as $partEntity) {
$temps[] = "<div>" . $partEntity->getTitle() . "</div>";
}
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$temps[] = form_label(
'변경',
$field,
[
"data-src" => "/admin/equipment/serverpart?type={$field}&serverinfo_uid={$viewDatas['entity']->getPK()}",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
$value = implode("", $temps);
break;
default:
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
$value = parent::getFieldView($field, $viewDatas, $extras);
break;
}
return $form;
} //
return $value;
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Helpers\Customer;
use App\Models\Customer\ServicePartModel;
use CodeIgniter\HTTP\IncomingRequest;
class ServicePartHelper extends CustomerHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: ServicePartModel::TITLE);
}
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string
{
return "";
// return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
}

View File

@ -0,0 +1,22 @@
<?php
namespace App\Helpers\Customer;
use App\Models\Customer\ServiceServerModel;
use CodeIgniter\HTTP\IncomingRequest;
class ServiceServerHelper extends CustomerHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: ServiceServerModel::TITLE);
}
public function getListRowColor(mixed $entity, string $field = 'status', string $value = 'use'): string
{
return "";
// return $entity->isMatched($field, $value) ? "" : 'class="table-danger"';
}
}

View File

@ -3,20 +3,21 @@ return [
'title' => "고객서비스정보",
'label' => [
'clientinfo_uid' => "고객명",
'code' => "Rack코드",
'rack' => "Rack번호",
'type' => "종류",
'title' => "제목",
'billing_at' => "청구일",
'start_at' => "개통일",
'end_at' => "해지일",
'status' => "상태",
'updated_at' => "수정일",
'created_at' => "신청일",
'DEFENCE' => "방어",
'SERVER' => "서버",
'IP' => "IP",
'CPU' => "CPU",
'RAM' => "RAM",
'DISK' => "DISK",
'IP' => "IP",
'SOFTWARE' => "SOFTWARE",
],
'DEFAULTS' => [
'type' => "hosting",

View File

@ -0,0 +1,18 @@
<?php
return [
'title' => "서비스부품연결",
'label' => [
'serviceinfo_uid' => "서비스",
'partinfo_uid' => "장비부품",
'billing_type' => "청구유형",
'amount' => "금액",
'created_at' => "작성일",
],
'DEFAULTS' => [
'billing_type' => 'month',
],
"BILLING_TYPE" => [
"month" => "월별",
"onetime" => "일회성",
],
];

View File

@ -0,0 +1,18 @@
<?php
return [
'title' => "서비스서버연결",
'label' => [
'serviceinfo_uid' => "서비스",
'serverinfo_uid' => "서버",
'billing_type' => "청구유형",
'amount' => "금액",
'created_at' => "작성일",
],
'DEFAULTS' => [
'billing_type' => 'month',
],
"BILLING_TYPE" => [
"month" => "월별",
"onetime" => "일회성",
],
];

View File

@ -8,15 +8,14 @@ class ServiceModel extends CustomerModel
{
const TABLE = "serviceinfo";
const PK = "uid";
const TITLE = "title";
const TITLE = "rack";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServiceEntity::class;
protected $allowedFields = [
"clientinfo_uid",
"code",
"rack",
"type",
"title",
"billing_at",
"start_at",
"end_at",
@ -36,18 +35,17 @@ class ServiceModel extends CustomerModel
case "clientinfo_uid":
$rule = "required|numeric";
break;
case "code":
case "rack":
$rule = "required|trim|min_length[4]|max_length[20]";
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
break;
case "title":
case "type":
$rule = "required|trim|string";
break;
case "billing_at":
case "start_at":
$rule = "required|valid_date";
break;
case "start_at":
case "end_at":
$rule = "if_exist|valid_date";
default:

View File

@ -6,22 +6,17 @@ use App\Entities\Customer\ServicePartEntity;
class ServicePartModel extends CustomerModel
{
const TABLE = "serviceinfo";
const TABLE = "serviceinfos_partinfos";
const PK = "uid";
const TITLE = "title";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServicePartEntity::class;
protected $allowedFields = [
"clientinfo_uid",
"code",
"type",
"title",
"billing_at",
"start_at",
"end_at",
"status",
"updated_at"
"serviceinfo_uid",
"partinfo_uid",
"billing_type",
"amount",
];
public function __construct()
{
@ -33,23 +28,14 @@ class ServicePartModel extends CustomerModel
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
case "clientinfo_uid":
case "serviceinfo_uid":
case "partinfo_uid":
case "amount":
$rule = "required|numeric";
break;
case "code":
$rule = "required|trim|min_length[4]|max_length[20]";
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
break;
case "title":
case "type":
case "billing_type":
$rule = "required|trim|string";
break;
case "billing_at":
$rule = "required|valid_date";
break;
case "start_at":
case "end_at":
$rule = "if_exist|valid_date";
default:
$rule = parent::getFieldRule($action, $field);
break;

View File

@ -0,0 +1,45 @@
<?php
namespace App\Models\Customer;
use App\Entities\Customer\ServiceServerEntity;
class ServiceServerModel extends CustomerModel
{
const TABLE = "serviceinfos_partinfos";
const PK = "uid";
const TITLE = "uid";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServiceServerEntity::class;
protected $allowedFields = [
"serviceinfo_uid",
"partinfo_uid",
"billing_type",
"amount",
];
public function __construct()
{
parent::__construct();
}
public function getFieldRule(string $action, string $field): string
{
if (is_array($field)) {
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
case "serviceinfo_uid":
case "partinfo_uid":
case "amount":
$rule = "required|numeric";
break;
case "billing_type":
$rule = "required|trim|string";
break;
default:
$rule = parent::getFieldRule($action, $field);
break;
}
return $rule;
}
}

View File

@ -0,0 +1,46 @@
<?php
namespace App\Services\Customer;
use CodeIgniter\HTTP\IncomingRequest;
use App\Entities\Customer\ServiceServerEntity;
use App\Models\Customer\ServiceServerModel;
class ServiceServerService extends CustomerService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
}
public function getClassName(): string
{
return parent::getClassName() . DIRECTORY_SEPARATOR . "ServiceServer";
}
public function getModelClass(): ServiceServerModel
{
return new ServiceServerModel();
}
public function getEntityClass(): ServiceServerEntity
{
return new ServiceServerEntity();
}
public function getFields(): array
{
return [
"serviceinfo_uid",
"partinfo_uid",
"billing_type",
"amount",
];
}
public function getFilterFields(): array
{
return ["serviceinfo_uid", "type", "partinfo_uid"];
}
public function getBatchJobFields(): array
{
return ["type", "partinfo_uid"];
}
}

View File

@ -29,22 +29,17 @@ class ServiceService extends CustomerService
{
return [
"clientinfo_uid",
"code",
"type",
"title",
"rack",
"billing_at",
"start_at",
"SERVER",
"CPU",
"RAM",
"DISK",
"IP",
"end_at",
"status",
];
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'type', "SERVER", "CPU", "RAM", "DISK", "IP", 'status'];
return ["clientinfo_uid", 'type', 'status'];
}
public function getBatchJobFields(): array
{