dbms_init...1

This commit is contained in:
최준흠 2025-06-03 09:28:00 +09:00
parent 730f478b38
commit 9666de0600
47 changed files with 643 additions and 3638 deletions

View File

@ -93,19 +93,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'PointController::batchjob_delete');
$routes->get('download/(:alpha)', 'PointController::download/$1');
});
$routes->group('domain', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
$routes->get('/', 'DomainController::index', []);
$routes->get('create', 'DomainController::create_form');
$routes->post('create', 'DomainController::create');
$routes->get('modify/(:num)', 'DomainController::modify_form/$1');
$routes->post('modify/(:num)', 'DomainController::modify/$1');
$routes->get('view/(:num)', 'DomainController::view/$1');
$routes->get('delete/(:num)', 'DomainController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'DomainController::toggle/$1/$2');
$routes->post('batchjob', 'DomainController::batchjob');
$routes->post('batchjob_delete', 'DomainController::batchjob_delete');
$routes->get('download/(:alpha)', 'DomainController::download/$1');
});
$routes->group('service', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
$routes->get('/', 'ServiceController::index', []);
$routes->get('create', 'ServiceController::create_form');
@ -119,6 +106,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'ServiceController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServiceController::download/$1');
});
$routes->group('serviceitem', ['namespace' => 'App\Controllers\Admin\Customer'], function ($routes) {
$routes->get('/', 'ServiceItemController::index', []);
$routes->get('create', 'ServiceItemController::create_form');
$routes->post('create', 'ServiceItemController::create');
$routes->get('modify/(:num)', 'ServiceItemController::modify_form/$1');
$routes->post('modify/(:num)', 'ServiceItemController::modify/$1');
$routes->get('view/(:num)', 'ServiceItemController::view/$1');
$routes->get('delete/(:num)', 'ServiceItemController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'ServiceItemController::toggle/$1/$2');
$routes->post('batchjob', 'ServiceItemController::batchjob');
$routes->post('batchjob_delete', 'ServiceItemController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServiceItemController::download/$1');
});
});
$routes->group('equipment', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->group('server', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
@ -134,6 +134,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'ServerController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServerController::download/$1');
});
$routes->group('domain', ['namespace' => 'App\Controllers\Admin\Equipment'], function ($routes) {
$routes->get('/', 'DomainController::index', []);
$routes->get('create', 'DomainController::create_form');
$routes->post('create', 'DomainController::create');
$routes->get('modify/(:num)', 'DomainController::modify_form/$1');
$routes->post('modify/(:num)', 'DomainController::modify/$1');
$routes->get('view/(:num)', 'DomainController::view/$1');
$routes->get('delete/(:num)', 'DomainController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'DomainController::toggle/$1/$2');
$routes->post('batchjob', 'DomainController::batchjob');
$routes->post('batchjob_delete', 'DomainController::batchjob_delete');
$routes->get('download/(:alpha)', 'DomainController::download/$1');
});
$routes->group('part', ['namespace' => 'App\Controllers\Admin\Equipment\Part'], function ($routes) {
$routes->group('line', ['namespace' => 'App\Controllers\Admin\Equipment\Part'], function ($routes) {
$routes->get('/', 'LineController::index', []);
@ -207,15 +220,15 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->get('delete/(:num)', 'RamController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'RamController::toggle/$1/$2');
});
$routes->group('disk', ['namespace' => 'App\Controllers\Admin\Equipment\Part'], function ($routes) {
$routes->get('/', 'DiskController::index', []);
$routes->get('create', 'DiskController::create_form');
$routes->post('create', 'DiskController::create');
$routes->get('modify/(:num)', 'DiskController::modify_form/$1');
$routes->post('modify/(:num)', 'DiskController::modify/$1');
$routes->get('view/(:num)', 'DiskController::view/$1');
$routes->get('delete/(:num)', 'DiskController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'DiskController::toggle/$1/$2');
$routes->group('storage', ['namespace' => 'App\Controllers\Admin\Equipment\Part'], function ($routes) {
$routes->get('/', 'StorageController::index', []);
$routes->get('create', 'StorageController::create_form');
$routes->post('create', 'StorageController::create');
$routes->get('modify/(:num)', 'StorageController::modify_form/$1');
$routes->post('modify/(:num)', 'StorageController::modify/$1');
$routes->get('view/(:num)', 'StorageController::view/$1');
$routes->get('delete/(:num)', 'StorageController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'StorageController::toggle/$1/$2');
});
});
});

View File

@ -4,10 +4,6 @@ namespace App\Controllers\Admin\Customer;
use App\Controllers\Admin\AdminController;
use App\Services\Customer\ClientService;
use App\Services\Customer\ServiceService;
use App\Services\Customer\AccountService;
use App\Services\Customer\CouponService;
use App\Services\Customer\PointService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
@ -15,10 +11,6 @@ use Psr\Log\LoggerInterface;
abstract class CustomerController extends AdminController
{
private ?ClientService $_clientService = null;
private ?ServiceService $_serviceService = null;
private ?AccountService $_accountService = null;
private ?CouponService $_couponService = null;
private ?PointService $_pointService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -31,35 +23,6 @@ abstract class CustomerController extends AdminController
}
return $this->_clientService;
}
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) {
$this->_accountService = new AccountService($this->request);
}
return $this->_accountService;
}
final public function getCouponService(): CouponService
{
if (!$this->_couponService) {
$this->_couponService = new CouponService($this->request);
}
return $this->_couponService;
}
final public function getPointService(): PointService
{
if (!$this->_pointService) {
$this->_pointService = new PointService($this->request);
}
return $this->_pointService;
}
protected function getFormFieldOption(string $field, array $options): array
{
switch ($field) {

View File

@ -4,16 +4,8 @@ namespace App\Controllers\Admin\Customer;
use App\Helpers\Customer\ServiceHelper;
use App\Services\Customer\ServiceService;
use App\Services\Equipment\Part\CpuService;
use App\Services\Customer\ServiceItemService;
use App\Services\Equipment\Part\DefenceService;
use App\Services\Equipment\Part\DiskService;
use App\Services\Equipment\Part\IpService;
use App\Services\Equipment\Part\LINEService;
use App\Services\Equipment\Part\RamService;
use App\Services\Equipment\Part\SoftwareService;
use App\Services\Equipment\ServereService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
@ -21,7 +13,7 @@ use Psr\Log\LoggerInterface;
class ServiceController extends CustomerController
{
private $_adapterService = [];
private ?ServiceItemService $_serviceItemService = null;
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
@ -46,39 +38,12 @@ class ServiceController extends CustomerController
// dd($this->_helper);
return $this->_helper;
}
final public function getAdapterService(string $key): mixed
public function getServiceItemService(): ServiceItemService
{
if (!array_key_exists($key, $this->_adapterService)) {
switch ($key) {
case 'SERVER':
$this->_adapterService[$key] = new ServereService();
break;
case 'CPU':
$this->_adapterService[$key] = new CpuService();
break;
case 'RAM':
$this->_adapterService[$key] = new RamService();
break;
case 'DISK':
$this->_adapterService[$key] = new DiskService();
break;
case 'LINE':
$this->_adapterService[$key] = new LineService();
break;
case 'IP':
$this->_adapterService[$key] = new IpService();
break;
case 'DEFENCE':
$this->_adapterService[$key] = new DefenceService();
break;
case 'SOFTWARE':
$this->_adapterService[$key] = new SoftwareService();
break;
default:
throw new \Exception("Unknown adapter service key: {$key}");
}
if (!$this->_serviceItemService) {
$this->_serviceItemService = new ServiceItemService($this->request);
}
return $this->_adapterService[$key];
return $this->_serviceItemService;
}
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
@ -94,28 +59,23 @@ class ServiceController extends CustomerController
return $result;
}
//Index,FieldForm관련
// protected function create_process(): mixed
// {
// $entity = parent::create_process();
// //사용중인 서버로 변경
// $this->getServerService()->setOccupied($this->getServerService()->getEntity($entity->getServerInfoUID()));
// return $entity;
// }
protected function index_process(): array
{
$fields = [
'fields' => ['clientinfo_uid', 'item_type', 'billing_at', 'rack', 'LINE', 'SERVER', 'IP', 'CPU', 'RAM', 'DISK', 'SOFTWARE', 'DEFENCE', 'start_at', 'status'],
'fields' => ['clientinfo_uid', 'location', 'switch', 'code', 'type', 'raid', 'billing_at', 'start_at', 'status'],
];
$this->init('index', $fields);
$this->adapterFields = ['LINE', 'IP', 'SERVER', 'CPU', 'RAM', 'DISK', 'DEFENCE', 'SOFTWARE'];
$this->item_types = lang($this->getServiceItemService()->getClassName() . '.' . strtoupper('ITEM_TYPE'));
$entities = [];
foreach (parent::index_process() as $entity) {
foreach ($this->adapterFields as $field) {
$entity->setAdaptertEntities($field, $this->getAdapterService($field)->getEntities());
foreach ($this->item_types as $field => $label) {
$itemEntities = $this->getServiceItemService()->getEntities(['item_type' => $field]);
// dd($itemEntities);
$entity->setItemEntities($field, $itemEntities);
}
$entities[] = $entity;
}
// $this->modal_type = 'modal_fetch_v2'; //기본은 modal_iframe임
return $entities;
}
}

View File

@ -0,0 +1,148 @@
<?php
namespace App\Controllers\Admin\Customer;
use App\Helpers\Customer\ServiceItemHelper;
use App\Services\Customer\ServiceItemService;
use App\Services\Customer\ServiceService;
use App\Services\Equipment\Part\CpuService;
use App\Services\Equipment\Part\DefenceService;
use App\Services\Equipment\Part\StorageService;
use App\Services\Equipment\Part\IpService;
use App\Services\Equipment\Part\LINEService;
use App\Services\Equipment\Part\RamService;
use App\Services\Equipment\Part\SoftwareService;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\DomainService;
use CodeIgniter\HTTP\RedirectResponse;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class ServiceItemController extends CustomerController
{
private ?ServiceService $_serviceService = null;
private $_equipmentService = [];
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
parent::initController($request, $response, $logger);
$this->title = lang("{$this->getService()->getClassName()}.title");
$this->class_path .= $this->getService()->getClassName();
$this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/';
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
}
public function getService(): ServiceItemService
{
if (!$this->_service) {
$this->_service = new ServiceItemService($this->request);
}
return $this->_service;
}
public function getHelper(): ServiceItemHelper
{
if (!$this->_helper) {
$this->_helper = new ServiceItemHelper($this->request);
}
// dd($this->_helper);
return $this->_helper;
}
public function getServiceService(): ServiceService
{
if (!$this->_serviceService) {
$this->_serviceService = new ServiceService($this->request);
}
return $this->_serviceService;
}
final public function getEquipmentService(string $key): mixed
{
if (!array_key_exists($key, $this->_equipmentService)) {
switch ($key) {
case 'SERVER':
$this->_equipmentService[$key] = new ServerService();
break;
case 'CPU':
$this->_equipmentService[$key] = new CpuService();
break;
case 'RAM':
$this->_equipmentService[$key] = new RamService();
break;
case 'STORAGE':
$this->_equipmentService[$key] = new StorageService();
break;
case 'LINE':
$this->_equipmentService[$key] = new LineService();
break;
case 'IP':
$this->_equipmentService[$key] = new IpService();
break;
case 'DEFENCE':
$this->_equipmentService[$key] = new DefenceService();
break;
case 'SOFTWARE':
$this->_equipmentService[$key] = new SoftwareService();
break;
case 'DOMAIN':
$this->_equipmentService[$key] = new DomainService();
break;
default:
throw new \Exception(__FUNCTION__ . "에서 사용하지않는 Service를 요청하였습니다.: {$key}");
}
}
return $this->_equipmentService[$key];
}
protected function getFormFieldOption(string $field, array $options): array
{
switch ($field) {
case 'serviceinfo_uid':
$temps = [];
foreach ($this->getServiceService()->getEntities() as $entity) {
$temps[$entity->getPK()] = $entity->getTitle();
}
$options[$field] = $temps;
// dd($options);
break;
case 'item_uid':
$temps = [];
$item_type = $this->request->getVar('item_type');
if (!$item_type) {
throw new \Exception(__FUNCTION__ . "에서 item_type이 지정되지 않았습니다.");
}
// throw new \Exception(__FUNCTION__ . "에서 item_type이 지정되지 않았습니다.->{$item_type}");
foreach ($this->getEquipmentService($item_type)->getEntities() as $entity) {
$temps[$entity->getPK()] = $entity->getTitle();
}
$options[$field] = $temps;
// dd($options);
break;
default:
$options = parent::getFormFieldOption($field, $options);
break;
}
return $options;
}
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
switch ($action) {
case 'index':
$this->getHelper()->setViewDatas($this->getViewDatas());
$result = view($this->view_path . 'popup' . DIRECTORY_SEPARATOR . $action, ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = parent::getResultPageByActon($action, $message);
break;
}
return $result;
}
//Index,FieldForm관련
protected function index_process(): array
{
$fields = [
'fields' => ['serviceinfo_uid', 'item_type', 'item_uid', 'billing_cycle', 'price', 'amount', 'start_at', 'status'],
];
$this->init('index', $fields);
return parent::index_process();
}
}

View File

@ -1,15 +1,15 @@
<?php
namespace App\Controllers\Admin\Customer;
namespace App\Controllers\Admin\Equipment;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
use App\Helpers\Customer\DomainHelper;
use App\Services\Customer\DomainService;
use App\Helpers\Equipment\DomainHelper;
use App\Services\Equipment\DomainService;
class DomainController extends CustomerController
class DomainController extends EquipmentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{

View File

@ -2,14 +2,14 @@
namespace App\Controllers\Admin\Equipment\Part;
use App\Helpers\Equipment\Part\DiskHelper;
use App\Services\Equipment\Part\DiskService;
use App\Helpers\Equipment\Part\StorageHelper;
use App\Services\Equipment\Part\StorageService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class DiskController extends PartController
class StorageController extends PartController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
@ -20,17 +20,17 @@ class DiskController extends PartController
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
}
public function getService(): DiskService
public function getService(): StorageService
{
if (!$this->_service) {
$this->_service = new DiskService($this->request);
$this->_service = new StorageService($this->request);
}
return $this->_service;
}
public function getHelper(): DiskHelper
public function getHelper(): StorageHelper
{
if (!$this->_helper) {
$this->_helper = new DiskHelper($this->request);
$this->_helper = new StorageHelper($this->request);
}
return $this->_helper;
}

View File

@ -40,7 +40,7 @@ class ServerController extends EquipmentController
protected function index_process(): array
{
$fields = [
'fields' => ['code', 'model', 'price', 'status', 'manufactur_at', 'created_at'],
'fields' => ['model', 'price', 'status', 'created_at'],
];
$this->init('index', $fields);
// $this->modal_type = 'modal_fetch_v2'; //기본은 modal_iframe임

View File

@ -168,13 +168,13 @@ LOCK TABLES `defenceinfo` WRITE;
UNLOCK TABLES;
--
-- Table structure for table `diskinfo`
-- Table structure for table `storageinfo`
--
DROP TABLE IF EXISTS `diskinfo`;
DROP TABLE IF EXISTS `storageinfo`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `diskinfo` (
CREATE TABLE `storageinfo` (
`uid` int(11) NOT NULL AUTO_INCREMENT,
`model` varchar(50) NOT NULL,
`price` int(11) NOT NULL DEFAULT 0,
@ -187,12 +187,12 @@ CREATE TABLE `diskinfo` (
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `diskinfo`
-- Dumping data for table `storageinfo`
--
LOCK TABLES `diskinfo` WRITE;
/*!40000 ALTER TABLE `diskinfo` DISABLE KEYS */;
/*!40000 ALTER TABLE `diskinfo` ENABLE KEYS */;
LOCK TABLES `storageinfo` WRITE;
/*!40000 ALTER TABLE `storageinfo` DISABLE KEYS */;
/*!40000 ALTER TABLE `storageinfo` ENABLE KEYS */;
UNLOCK TABLES;
--

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +0,0 @@
<?php
namespace App\Entities\Customer;
use App\Models\Customer\DomainModel;
class DomainEntity extends CustomerEntity
{
const PK = DomainModel::PK;
const TITLE = DomainModel::TITLE;
}

View File

@ -8,12 +8,12 @@ class ServiceEntity extends CustomerEntity
{
const PK = ServiceModel::PK;
const TITLE = ServiceModel::TITLE;
public function getAdapterEntities(string $type): array
public function getItemEntities(string $type): array
{
return $this->attributes[$type] ?? [];
}
public function setAdapterEntities(string $type, array $partEntities): void
public function setItemEntities(string $type, array $partEntities): void
{
if (!isset($this->attributes[$type])) {
$this->attributes[$type] = [];

View File

@ -0,0 +1,16 @@
<?php
namespace App\Entities\Customer;
use App\Models\Customer\ServiceItemModel;
class ServiceItemEntity extends CustomerEntity
{
const PK = ServiceItemModel::PK;
const TITLE = ServiceItemModel::TITLE;
public function getTitle(): string
{
return parent::getTitle() . " [" . number_format($this->attributes['price']) . '/' . number_format($this->attributes['amount']) . "원]";
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment;
use App\Models\Equipment\DomainModel;
class DomainEntity extends EquipmentEntity
{
const PK = DomainModel::PK;
const TITLE = DomainModel::TITLE;
}

View File

@ -10,9 +10,8 @@ abstract class EquipmentEntity extends CommonEntity
{
parent::__construct($data);
}
public function getServerInfoUID()
public function getTitle(): string
{
return $this->attributes['serverinfo_uid'];
return parent::getTitle() . " [" . number_format($this->attributes['price']) . "원]";
}
}

View File

@ -8,8 +8,4 @@ class CpuEntity extends PartEntity
{
const PK = CpuModel::PK;
const TITLE = CpuModel::TITLE;
public function getTitle(): string
{
return parent::getTitle() . " [" . number_format($this->attributes['price']) . "원]";
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace App\Entities\Equipment\Part;
use App\Models\Equipment\Part\DiskModel;
class DiskEntity extends PartEntity
{
const PK = DiskModel::PK;
const TITLE = DiskModel::TITLE;
public function getTitle(): string
{
return parent::getTitle() . " [" . number_format($this->attributes['price']) . "원]";
}
}

View File

@ -8,8 +8,4 @@ class RamEntity extends PartEntity
{
const PK = RamModel::PK;
const TITLE = RamModel::TITLE;
public function getTitle(): string
{
return parent::getTitle() . " [" . number_format($this->attributes['price']) . "원]";
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace App\Entities\Equipment\Part;
use App\Models\Equipment\Part\StorageModel;
class StorageEntity extends PartEntity
{
const PK = StorageModel::PK;
const TITLE = StorageModel::TITLE;
}

View File

@ -8,8 +8,4 @@ class ServerEntity extends EquipmentEntity
{
const PK = ServerModel::PK;
const TITLE = ServerModel::TITLE;
public function getTitle(): string
{
return parent::getTitle() . " [{$this->attributes['model']}]";
}
}

View File

@ -241,7 +241,6 @@ class CommonHelper
$form = form_dropdown($field, $formOptions, $value, ['class' => $extra_class, ...array_diff_key($extras, ['class' => ''])]);
}
break;
case 'manufactur_at':
case 'billing_at':
case 'start_at':
case 'end_at':
@ -282,17 +281,7 @@ class CommonHelper
$value = $viewDatas['entity']->$field ?? "";
switch ($field) {
case $this->getTitleField():
$value = form_label(
$value,
'view',
[
"data-src" => current_url() . '/view/' . $viewDatas['entity']->getPK(),
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
"style" => "color: blue; cursor: pointer; font-weight:bold;",
...$extras,
]
);
$value = $this->getFieldForm($field, $viewDatas['entity']->$field, $viewDatas, $extras);
break;
case 'role':
$roles = [];
@ -301,7 +290,6 @@ class CommonHelper
}
$value = implode(" , ", $roles);
break;
case 'manufactur_at':
case 'billing_at':
case 'start_at':
case 'end_at':
@ -389,6 +377,19 @@ class CommonHelper
]
);
break;
case 'view':
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
$action = form_label(
ICONS['SEARCH'],
$action,
[
"data-src" => current_url() . '/' . $action . '/' . $viewDatas['entity']->getPK(),
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
break;
case 'delete':
$extras = ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self", ...$extras];
$action = anchor(

View File

@ -13,4 +13,60 @@ class ServiceHelper extends CustomerHelper
parent::__construct($request);
$this->setTitleField(field: ServiceModel::TITLE);
}
public function getFieldLabel(string $field, array $viewDatas, array $extras = []): string
{
switch ($field) {
case "LINE":
case "IP":
case "SERVER":
case "CPU":
case "RAM":
case "STORAGE":
case "SOFTWARE":
case "DEFENCE":
case "DOMAIN":
$label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
break;
default:
$label = parent::getFieldLabel($field, $viewDatas, $extras);
break;
}
return $label;
}
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{
$value = $viewDatas['entity']->$field ?? "";
switch ($field) {
case "LINE":
case "IP":
case "SERVER":
case "CPU":
case "RAM":
case "STORAGE":
case "SOFTWARE":
case "DEFENCE":
case "DOMAIN":
$temps = [];
foreach ($viewDatas['entity']->getItemEntities($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/customer/serviceitem?item_type={$field}&serviceinfo_uid={$viewDatas['entity']->getPK()}",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
$value = implode("", $temps);
break;
default:
$value = parent::getFieldView($field, $viewDatas, $extras);
break;
}
return $value;
}
}

View File

@ -0,0 +1,16 @@
<?php
namespace App\Helpers\Customer;
use App\Models\Customer\ServiceItemModel;
use CodeIgniter\HTTP\IncomingRequest;
class ServiceItemHelper extends CustomerHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: ServiceItemModel::TITLE);
}
}

View File

@ -1,11 +1,11 @@
<?php
namespace App\Helpers\Customer;
namespace App\Helpers\Equipment;
use App\Models\Customer\DomainModel;
use App\Models\Equipment\DomainModel;
use CodeIgniter\HTTP\IncomingRequest;
class DomainHelper extends CustomerHelper
class DomainHelper extends EquipmentHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)

View File

@ -2,15 +2,15 @@
namespace App\Helpers\Equipment\Part;
use App\Models\Equipment\Part\DiskModel;
use App\Models\Equipment\Part\StorageModel;
use CodeIgniter\HTTP\IncomingRequest;
class DiskHelper extends PartHelper
class StorageHelper extends PartHelper
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->setTitleField(field: DiskModel::TITLE);
$this->setTitleField(field: StorageModel::TITLE);
}
}

View File

@ -13,80 +13,4 @@ class ServerHelper extends EquipmentHelper
parent::__construct($request);
$this->setTitleField(field: ServerModel::TITLE);
}
public function getFieldLabel(string $field, array $viewDatas, array $extras = []): string
{
switch ($field) {
case "LINE":
case "IP":
case "CPU":
case "RAM":
case "DISK":
case "DEFENCE":
case "SOFTWARE":
case "DOMAIN":
$label = form_label(lang("{$viewDatas['class_path']}.label.{$field}"), $field, $extras);
break;
default:
$label = parent::getFieldLabel($field, $viewDatas, $extras);
break;
}
return $label;
}
// public function getFieldForm(string $field, mixed $value, 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];
// }
// switch ($field) {
// case 'model':
// if (!is_array($viewDatas['field_options'][$field])) {
// throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다.");
// }
// $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' => ''])]);
// break;
// default:
// $form = parent::getFieldForm($field, $value, $viewDatas, $extras);
// break;
// }
// return $form;
// }
public function getFieldView(string $field, array $viewDatas, array $extras = []): string
{
$value = $viewDatas['entity']->$field ?? "";
switch ($field) {
case "LINE":
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/link/" . strtolower($field) . "?&serverinfo_uid={$viewDatas['entity']->getPK()}",
"data-bs-toggle" => "modal",
"data-bs-target" => "#index_action_form",
...$extras
]
);
$value = implode("", $temps);
break;
default:
$value = parent::getFieldView($field, $viewDatas, $extras);
break;
}
return $value;
}
}

View File

@ -3,7 +3,11 @@ return [
'title' => "고객서비스정보",
'label' => [
'clientinfo_uid' => "고객명",
'switch' => "Switch",
'location' => "위치",
'switch' => "스위치코드",
'code' => "서버코드",
'type' => "형식",
'raid' => "RAID",
'billing_at' => "청구일",
'start_at' => "개통일",
'end_at' => "해지일",
@ -14,8 +18,8 @@ return [
'LINE' => "회선",
'IP' => "IP",
'CPU' => "CPU",
'RAM' => "RAM",
'DISK' => "DISK",
'RAM' => "메모리",
'DISK' => "저장장치",
'SOFTWARE' => "SOFTWARE",
'DEFENCE' => "방어(CS)",
'DOMAIN' => "도메인",
@ -26,13 +30,28 @@ return [
'type' => "default",
'status' => 'default'
],
"LOCATION" => [
"default" => "치바",
"tokyo" => "도쿄",
],
"SWITCH" => [
"R35P10" => "R35P10",
"R45P20" => "R45P20",
],
"LOCATION" => [
"default" => "치바",
"tokyo" => "도쿄",
"CODE" => [
"JPN130" => "JPN130",
"JPN140" => "JPN140",
"JPN150" => "JPN138",
"X1508A" => "R45P20",
"X1508C" => "X1508C",
"X1508D" => "X1508D",
"X2001A" => "X2001A",
"X2001B" => "X2001B",
"X2001C" => "X2001C",
"X2001D" => "X2001D",
"X2001E" => "X2001E",
"P2404I510" => "P2404I510",
"P2404I710" => "P2404I710",
],
"TYPE" => [
"default" => "일반",

View File

@ -0,0 +1,44 @@
<?php
return [
'title' => "서비스항목정보",
'label' => [
'serviceinfo_uid' => "서비스명",
'item_type' => "항목형식",
'item_uid' => "항목",
'billing_cycle' => "청구방식",
'price' => "소비자금액",
'amount' => "서비스금액",
'start_at' => "개통일",
'end_at' => "해지일",
'status' => "상태",
'updated_at' => "수정일",
'created_at' => "신청일",
],
'DEFAULTS' => [
'item_type' => "server",
'billing_cycle' => "month",
'type' => "default",
'status' => 'default'
],
"ITEM_TYPE" => [
"LINE" => "라인",
"IP" => "IP주소",
"SERVER" => "서버",
"CPU" => "CPU",
"RAM" => "메모리",
"STORAGE" => "저장장치",
"SOFTWARE" => "소프트웨어",
"DEFENCE" => "방어(CS)",
"DOMAIN" => "도메인",
],
"BILLING_CYCLE" => [
"month" => "매월",
"onetime" => "일회성",
],
"STATUS" => [
'default' => "사용중",
"pause" => "일시정지",
'reservation' => "설치예약",
"terminated" => "해지",
],
];

View File

@ -2,12 +2,10 @@
return [
'title' => "서버장비정보",
'label' => [
'code' => "장비코드",
'model' => "모델",
'price' => "금액",
'description' => "설명",
'status' => "상태",
'manufactur_at' => "입고일",
'updated_at' => "수정일",
'created_at' => "작성일",
],

View File

@ -0,0 +1,60 @@
<?php
namespace App\Models\Customer;
use App\Entities\Customer\ServiceItemEntity;
class ServiceItemModel extends CustomerModel
{
const TABLE = "serviceinfo_items";
const PK = "uid";
const TITLE = "item_type";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = ServiceItemEntity::class;
protected $allowedFields = [
"serviceinfo_uid",
"item_type",
"item_uid",
"billing_cycle",
"price",
"amount",
"start_at",
"end_at",
"status",
"updated_at"
];
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 "item_uid":
case "price":
case "amount":
$rule = "required|numeric";
break;
case "item_type":
case "billing_cycle":
case "status":
$rule = "required|trim|string";
break;
case "start_at":
$rule = "required|valid_date";
break;
case "end_at":
$rule = "if_exist|valid_date";
break;
default:
$rule = parent::getFieldRule($action, $field);
break;
}
return $rule;
}
}

View File

@ -16,6 +16,7 @@ class ServiceModel extends CustomerModel
"clientinfo_uid",
"switch",
"location",
"code",
"type",
"raid",
"billing_at",
@ -37,6 +38,8 @@ class ServiceModel extends CustomerModel
case "clientinfo_uid":
$rule = "required|numeric";
break;
case "switch":
case "code":
case "type":
case "status":
$rule = "required|trim|string";

View File

@ -1,10 +1,10 @@
<?php
namespace App\Models\Customer;
namespace App\Models\Equipment;
use App\Entities\Customer\DomainEntity;
use App\Entities\Equipment\DomainEntity;
class DomainModel extends CustomerModel
class DomainModel extends EquipmentModel
{
const TABLE = "domaininfo";
const PK = "uid";

View File

@ -6,7 +6,7 @@ use App\Entities\Equipment\Part\RamEntity;
class RamModel extends PartModel
{
const TABLE = "diskinfo";
const TABLE = "raminfo";
const PK = "uid";
const TITLE = "model";
protected $table = self::TABLE;

View File

@ -2,16 +2,16 @@
namespace App\Models\Equipment\Part;
use App\Entities\Equipment\Part\DiskEntity;
use App\Entities\Equipment\Part\StorageEntity;
class DiskModel extends PartModel
class StorageModel extends PartModel
{
const TABLE = "raminfo";
const TABLE = "storageinfo";
const PK = "uid";
const TITLE = "model";
protected $table = self::TABLE;
protected $primaryKey = self::PK;
protected $returnType = DiskEntity::class;
protected $returnType = StorageEntity::class;
protected $allowedFields = [
"model",
"price",

View File

@ -13,10 +13,8 @@ class ServerModel extends EquipmentModel
protected $primaryKey = self::PK;
protected $returnType = ServerEntity::class;
protected $allowedFields = [
"code",
"model",
"price",
"manufactur_at",
"description",
"status",
"updated_at"
@ -31,16 +29,12 @@ class ServerModel extends EquipmentModel
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
}
switch ($field) {
case "code":
case "model":
$rule = "required|trim|string";
break;
case "price":
$rule = "required|numeric";
break;
case "manufactur_at":
$rule = "required|valid_date";
break;
default:
$rule = parent::getFieldRule($action, $field);
break;

View File

@ -0,0 +1,46 @@
<?php
namespace App\Services\Customer;
use App\Entities\Customer\ServiceItemEntity;
use App\Models\Customer\ServiceItemModel;
use CodeIgniter\HTTP\IncomingRequest;
class ServiceItemService extends CustomerService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->addClassName('ServiceItem');
}
public function getModelClass(): ServiceItemModel
{
return new ServiceItemModel();
}
public function getEntityClass(): ServiceItemEntity
{
return new ServiceItemEntity();
}
public function getFields(): array
{
return [
"serviceinfo_uid",
"item_type",
"item_uid",
"billing_cycle",
"price",
"amount",
"start_at",
"status",
];
}
public function getFilterFields(): array
{
return ["serviceinfo_uid", 'item_type', 'item_uid', 'billing_cycle', 'status'];
}
public function getBatchJobFields(): array
{
return ['status'];
}
}

View File

@ -28,6 +28,7 @@ class ServiceService extends CustomerService
"clientinfo_uid",
"switch",
"location",
"code",
"type",
"raid",
"billing_at",
@ -38,7 +39,7 @@ class ServiceService extends CustomerService
}
public function getFilterFields(): array
{
return ["clientinfo_uid", 'switch', 'location', 'type', 'raid', 'status'];
return ["clientinfo_uid", 'location', 'switch', 'code', 'type', 'raid', 'status'];
}
public function getBatchJobFields(): array
{

View File

@ -1,12 +1,12 @@
<?php
namespace App\Services\Customer;
namespace App\Services\Equipment;
use App\Entities\Customer\DomainEntity;
use App\Models\Customer\DomainModel;
use App\Entities\Equipment\DomainEntity;
use App\Models\Equipment\DomainModel;
use CodeIgniter\HTTP\IncomingRequest;
class DomainService extends CustomerService
class DomainService extends EquipmentService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)

View File

@ -2,25 +2,25 @@
namespace App\Services\Equipment\Part;
use App\Entities\Equipment\Part\DiskEntity;
use App\Models\Equipment\Part\DiskModel;
use App\Entities\Equipment\Part\StorageEntity;
use App\Models\Equipment\Part\StorageModel;
use CodeIgniter\HTTP\IncomingRequest;
class DiskService extends PartService
class StorageService extends PartService
{
protected ?IncomingRequest $request = null;
public function __construct(?IncomingRequest $request = null)
{
parent::__construct($request);
$this->addClassName('Disk');
$this->addClassName('Storage');
}
public function getModelClass(): DiskModel
public function getModelClass(): StorageModel
{
return new DiskModel();
return new StorageModel();
}
public function getEntityClass(): DiskEntity
public function getEntityClass(): StorageEntity
{
return new DiskEntity();
return new StorageEntity();
}
final public function getFields(): array
{

View File

@ -26,8 +26,6 @@ class ServerService extends EquipmentService
public function getFields(): array
{
return [
"code",
"manufactur_at",
"model",
"price",
"status",
@ -42,9 +40,4 @@ class ServerService extends EquipmentService
{
return ['model', 'status'];
}
//서비스에서 사용중인 서버를 occupied로 변경
public function setOccupied(ServerEntity $entity): ServerEntity
{
return $this->getModel()->modify($entity, ['status' => 'occupied']);
}
}

View File

@ -38,7 +38,10 @@
<?php foreach ($viewDatas['fields'] as $field): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
<td><?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?></td>
<td nowrap>
<?= $viewDatas['helper']->getListButton('view', $viewDatas) ?>&nbsp;
<?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?>
</td>
</tr>
<?php $cnt++ ?>
<?php endforeach ?>

View File

@ -38,18 +38,21 @@
<?php foreach ($viewDatas['fields'] as $field): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
<td><?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?></td>
<td nowrap>
<?= $viewDatas['helper']->getListButton('view', $viewDatas) ?>&nbsp;
<?= $viewDatas['helper']->getListButton('delete', $viewDatas) ?>
</td>
</tr>
<tr>
<td colspan="11">
<table class="table table-bordered table-hover table-striped">
<tr>
<?php foreach ($viewDatas['adapterFields'] as $field): ?>
<th data-rtc-resizable="<?= $field ?>"><?= $viewDatas['helper']->getFieldLabel($field, $viewDatas) ?></th>
<?php foreach ($viewDatas['item_types'] as $field => $label): ?>
<th data-rtc-resizable="<?= $field ?>"><?= $label ?></th>
<?php endforeach ?>
</tr>
<tr>
<?php foreach ($viewDatas['adapterFields'] as $field): ?>
<?php foreach ($viewDatas['item_types'] as $field => $label): ?>
<td><?= $viewDatas['helper']->getFieldView($field, $viewDatas) ?></td>
<?php endforeach ?>
</tr>

View File

@ -17,9 +17,6 @@
<div class="accordion-item">
<a href="/admin/customer/point"><?= ICONS['FLAG'] ?> Point내역</a>
</div>
<div class="accordion-item">
<a href="/admin/customer/domain"><?= ICONS['FLAG'] ?>도메인정보</a>
</div>
<div class="accordion-item">
<a href="/admin/customer/service"><?= ICONS['CARD'] ?> 서비스내역</a>
</div>

View File

@ -17,14 +17,17 @@
<div class="accordion-item">
<a href="/admin/equipment/part/software"><?= ICONS['FLAG'] ?>Software정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/domain"><?= ICONS['FLAG'] ?>도메인정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/part/cpu"><?= ICONS['SETUP'] ?>CPU정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/part/ram"><?= ICONS['SETUP'] ?>RAM정보</a>
<a href="/admin/equipment/part/ram"><?= ICONS['SETUP'] ?>메모리리정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/part/disk"><?= ICONS['SETUP'] ?>DISK정보</a>
<a href="/admin/equipment/part/storage"><?= ICONS['SETUP'] ?>저장장치정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/server"><?= ICONS['DESKTOP'] ?>Server정보</a>