dbmsv2_init...1

This commit is contained in:
choi.jh 2025-09-25 18:31:14 +09:00
parent 4f99fda98e
commit 2c27bbf09f
28 changed files with 279 additions and 113 deletions

View File

@ -1,10 +1,10 @@
<?php
namespace App\Cells\Equipment;
namespace App\Cells\Part;
use App\Services\Part\DISKService;
class DISKCell extends EquipmentCell
class DISKCell extends PartCell
{
public function __construct()
{

View File

@ -0,0 +1,15 @@
<?php
namespace App\Cells\Part;
use App\Cells\CommonCell;
use App\Services\CommonService;
abstract class PartCell extends CommonCell
{
protected function __construct(CommonService $service)
{
parent::__construct($service);
}
}

View File

@ -1,10 +1,10 @@
<?php
namespace App\Cells\Equipment;
namespace App\Cells\Part;
use App\Services\Part\RAMService;
class RAMCell extends EquipmentCell
class RAMCell extends PartCell
{
public function __construct()
{

View File

@ -234,7 +234,7 @@ define('ICONS', [
'SERVER_ITEM_CPU' => '<i class="bi bi-cpu"></i>',
'SERVER_ITEM_RAM' => '<i class="bi bi-memory"></i>',
'SERVER_ITEM_DISK' => '<i class="bi bi-device-hdd"></i>',
'SERVER_ITEM_Switch' => '<i class="bi bi-diagram-3"></i>',
'SERVER_ITEM_SWITCH' => '<i class="bi bi-diagram-3"></i>',
'SERVER_ITEM_OS' => '<i class="bi bi-microsoft"></i>',
'SERVER_ITEM_DB' => '<i class="bi bi-database"></i>',
'SERVER_ITEM_SOFTWARE' => '<i class="bi bi-window-sidebar"></i>',
@ -406,8 +406,8 @@ define("SERVERPART", [
"CNT_RANGE" => array_combine(range(1, 10), range(1, 10)),
"STOCK_PARTTYPES" => ['RAM', 'DISK'],
"SERVER_PARTTYPES" => ['CPU', 'RAM', 'DISK'],
"SERVICE_PARTTYPES" => ['Switch', 'IP', 'OS', 'SOFTWARE', 'CS'],
"ALL_PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'SOFTWARE', 'Switch', 'IP', 'CS'],
"SERVICE_PARTTYPES" => ['SWITCH', 'IP', 'OS', 'SOFTWARE', 'CS'],
"ALL_PARTTYPES" => ['CPU', 'RAM', 'DISK', 'OS', 'SOFTWARE', 'SWITCH', 'IP', 'CS'],
]);
//결제 관련
define("PAYMENT", [

View File

@ -186,17 +186,17 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
//Part 관련
$routes->group('part', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
$routes->group('switch', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
$routes->get('/', 'SwitchController::index');
$routes->get('create', 'SwitchController::create_form');
$routes->post('create', 'SwitchController::create');
$routes->get('modify/(:alphanum)', 'SwitchController::modify_form/$1');
$routes->post('modify/(:alphanum)', 'SwitchController::modify/$1');
$routes->get('view/(:alphanum)', 'SwitchController::view/$1');
$routes->get('delete/(:alphanum)', 'SwitchController::delete/$1');
$routes->get('toggle/(:alphanum)/(:any)', 'SwitchController::toggle/$1/$2');
$routes->post('batchjob', 'SwitchController::batchjob');
$routes->post('batchjob_delete', 'SwitchController::batchjob_delete');
$routes->get('download/(:alpha)', 'SwitchController::download/$1');
$routes->get('/', 'SWITCHController::index');
$routes->get('create', 'SWITCHController::create_form');
$routes->post('create', 'SWITCHController::create');
$routes->get('modify/(:alphanum)', 'SWITCHController::modify_form/$1');
$routes->post('modify/(:alphanum)', 'SWITCHController::modify/$1');
$routes->get('view/(:alphanum)', 'SWITCHController::view/$1');
$routes->get('delete/(:alphanum)', 'SWITCHController::delete/$1');
$routes->get('toggle/(:alphanum)/(:any)', 'SWITCHController::toggle/$1/$2');
$routes->post('batchjob', 'SWITCHController::batchjob');
$routes->post('batchjob_delete', 'SWITCHController::batchjob_delete');
$routes->get('download/(:alpha)', 'SWITCHController::download/$1');
});
$routes->group('ip', ['namespace' => 'App\Controllers\Admin\Part'], function ($routes) {
$routes->get('/', 'IPController::index');

View File

@ -2,13 +2,13 @@
namespace App\Controllers\Admin\Part;
use App\Services\Part\SwitchService;
use App\Services\Part\SWITCHService;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class SwitchController extends PartController
class SWITCHController extends PartController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{
@ -19,10 +19,10 @@ class SwitchController extends PartController
// $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR;
}
public function getService(): SwitchService
public function getService(): SWITCHService
{
if (!$this->_service) {
$this->_service = new SwitchService();
$this->_service = new SWITCHService();
}
return $this->_service;
}

View File

@ -22,7 +22,7 @@ abstract class DBMigration extends BaseController
abstract protected function getClient(): array;
abstract protected function getLine(): array;
abstract protected function getServerCode(): array;
abstract protected function getSwitchCode(): array;
abstract protected function getSWITCHCode(): array;
abstract protected function getPartCode(): array;
final protected function getTargetDB(): BaseConnection

View File

@ -9,7 +9,7 @@ use Psr\Log\LoggerInterface;
use App\Libraries\DBMigration\Process\ClientProcess;
use App\Libraries\DBMigration\Process\LineProcess;
use App\Libraries\DBMigration\Process\ServerCodeProcess;
use App\Libraries\DBMigration\Process\SwitchCodeProcess;
use App\Libraries\DBMigration\Process\SWITCHCodeProcess;
use App\Libraries\DBMigration\Process\PartCodeProcess;
class SourceDB extends DBMigration
@ -95,7 +95,7 @@ class SourceDB extends DBMigration
return $this->executeQuery(self::SQL_GET_SERVER_CODE, ['%일회성%']);
}
protected function getSwitchCode(): array
protected function getSWITCHCode(): array
{
return $this->executeQuery(self::SQL_GET_SWITCH_CODE, ['%일회성%']);
}
@ -133,8 +133,8 @@ class SourceDB extends DBMigration
final public function switchcode(): void
{
$this->migration(
new SwitchCodeProcess($this->getTargetDB()),
$this->getSwitchCode(),
new SWITCHCodeProcess($this->getTargetDB()),
$this->getSWITCHCode(),
__FUNCTION__
);
}

View File

@ -4,13 +4,13 @@
"settings": {
"width": 3000,
"height": 3000,
"scrollTop": -1894.7873,
"scrollLeft": -297.3986,
"scrollTop": -1298.7873,
"scrollLeft": -287.741,
"zoomLevel": 0.79,
"show": 511,
"database": 4,
"databaseName": "",
"canvasType": "@dineug/erd-editor/builtin-schema-sql",
"canvasType": "ERD",
"language": 1,
"tableNameCase": 4,
"columnNameCase": 2,

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entities\Part;
use App\Models\Part\SWITCHModel;
class SWITCHEntity extends PartEntity
{
const PK = SWITCHModel::PK;
const TITLE = SWITCHModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
}

View File

@ -1,12 +0,0 @@
<?php
namespace App\Entities\Part;
use App\Models\Part\SwitchModel;
class SwitchEntity extends PartEntity
{
const PK = SwitchModel::PK;
const TITLE = SwitchModel::TITLE;
const DEFAULT_STATUS = STATUS['AVAILABLE'];
}

View File

@ -57,18 +57,18 @@ class ServerPartHelper extends EquipmentHelper
$attributes = ['data-title' => 'getTitle', 'data-price' => 'getPrice'];
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break;
case 'billing':
//결제방식이 항상 매월지급으로 설정되는 항목형식(IP,CS)
if (array_key_exists('type', $viewDatas['control']['form_datas'])) {
switch ($viewDatas['control']['form_datas']['type']) {
case 'IP':
case 'CS':
$value = PAYMENT['BILLING']['MONTH'];
break;
}
}
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);;
break;
// case 'billing':
// //결제방식이 항상 매월지급으로 설정되는 항목형식(IP,CS)
// if (array_key_exists('type', $viewDatas['control']['form_datas'])) {
// switch ($viewDatas['control']['form_datas']['type']) {
// case 'IP':
// case 'CS':
// $value = PAYMENT['BILLING']['MONTH'];
// break;
// }
// }
// $form = parent::getFieldForm($field, $value, $viewDatas, $extras);;
// break;
case 'extra':
if (array_key_exists('type', $viewDatas['control']['form_datas']) && $viewDatas['control']['form_datas']['type'] === 'DISK') {
$options = ["" => lang("{$viewDatas['class_path']}.label.{$field}") . " 선택", ...lang("{$viewDatas['class_path']}.EXTRA.{$viewDatas['control']['form_datas']['type']}")];
@ -106,7 +106,7 @@ class ServerPartHelper extends EquipmentHelper
case 'DISK':
case 'OS':
case 'SOFTWARE':
case 'Switch':
case 'SWITCH':
case 'IP':
case 'CS':
//파트 Entity
@ -142,7 +142,7 @@ class ServerPartHelper extends EquipmentHelper
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
{
switch ($action) {
case 'Switch':
case 'SWITCH':
case 'IP':
case 'CS':
case 'CPU':

View File

@ -2,14 +2,14 @@
namespace App\Helpers\Part;
use App\Models\Part\SwitchModel;
use App\Models\Part\SWITCHModel;
class SwitchHelper extends PartHelper
class SWITCHHelper extends PartHelper
{
public function __construct()
{
parent::__construct();
$this->setTitleField(field: SwitchModel::TITLE);
$this->setTitleField(field: SWITCHModel::TITLE);
}
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string

View File

@ -1,6 +1,6 @@
<?php
return [
'title' => "Switch정보",
'title' => "SWITCH정보",
'label' => [
'clientinfo_uid' => "고객",
'serviceinfo_uid' => "서비스",

View File

@ -2,10 +2,10 @@
namespace App\Libraries\DBMigration\Process;
use App\Entities\Equipment\SwitchEntity;
use App\Entities\Part\SWITCHEntity;
use CodeIgniter\Database\BaseConnection;
class SwitchCodeProcess implements MigrationProcessInterface
class SWITCHCodeProcess implements MigrationProcessInterface
{
private $db;
public function __construct(BaseConnection $db)
@ -16,7 +16,7 @@ class SwitchCodeProcess implements MigrationProcessInterface
{
$temps = [];
$temps['code'] = trim($row['service_sw']);
$temps['status'] = SwitchEntity::DEFAULT_STATUS; // Assuming SwitchEntity has a STATUS_DEFAULT constant
$temps['status'] = SWITCHEntity::DEFAULT_STATUS; // Assuming SWITCHEntity has a STATUS_DEFAULT constant
if (!$this->db->table('switchinfo')->insert($temps)) {
throw new \Exception($this->db->error()['message']);
}

View File

@ -37,6 +37,9 @@ class IPModel extends PartModel
$rule = "required|numeric";
break;
case "old_clientinfo_uid":
case "clientinfo_uid":
case "serviceinfo_uid":
case "serverinfo_uid":
$rule = "permit_empty|numeric";
break;
case "ip":

View File

@ -2,9 +2,9 @@
namespace App\Models\Part;
use App\Entities\Part\SwitchEntity;
use App\Entities\Part\SWITCHEntity;
class SwitchModel extends PartModel
class SWITCHModel extends PartModel
{
const TABLE = "switchinfo";
const PK = "uid";
@ -12,7 +12,7 @@ class SwitchModel extends PartModel
protected $table = self::TABLE;
protected $primaryKey = self::PK;
// protected $useAutoIncrement = false;
protected $returnType = SwitchEntity::class;
protected $returnType = SWITCHEntity::class;
protected $allowedFields = [
"clientinfo_uid",
"serviceinfo_uid",

View File

@ -223,6 +223,21 @@ class ServiceService extends CustomerService
}
return $caculatedAmount;
}
//조정된 금액 설정
final public function setAmount(ServiceEntity $entity): ServiceEntity
{
$caculatedAmount = $this->getCaculatedAmount($entity);
if ($entity->getAmount() !== $caculatedAmount) {
$paymentEntity = $entity->getPaymentEntity();
if (!$paymentEntity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 결제정보가 정의되지 않았습니다.");
}
//금액설정
$entity = parent::modify($entity, ['amount' => $caculatedAmount]);
$this->getPaymentService()->setAmount($entity->getPaymentEntity(), $caculatedAmount);
}
return $entity;
}
//기본 기능부분
//FieldForm관련용
public function getFormOption(string $field, array $options = []): array
@ -236,7 +251,7 @@ class ServiceService extends CustomerService
case 'DISK':
case 'OS':
case 'SOFTWARE':
case 'Switch':
case 'SWITCH':
case 'IP':
case 'CS':
$options = $this->getServerService()->getFormOption($field, $options);
@ -252,8 +267,8 @@ class ServiceService extends CustomerService
{
//서버정보수정
$entity = $this->getServerService()->$action($entity);
//결제정보수정 및 결제정보 PK값정의
$entity = $this->getPaymentService()->$action($entity);
//결제정보PK정의
$entity = parent::modify($entity, ['payment_uid' => $entity->getPaymentEntity()->getPK()]);
return $entity;
}

View File

@ -21,8 +21,8 @@ class ServiceService extends ParentService implements ServerInterface
if (!$entity instanceof ServiceEntity) {
throw new \Exception("[{$serverEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
return $this->getModel()->modify($entity, []);
//서비스금액변경 사항이 있는지 확인후 처리
return $this->setAmount($entity);
}
public function createServer(ServerEntity $serverEntity): ServerEntity
{
@ -36,9 +36,11 @@ class ServiceService extends ParentService implements ServerInterface
}
public function deleteServer(ServerEntity $serverEntity): ServerEntity
{
//서비스중인지 확인
if ($serverEntity->getServiceInfoUID() !== null || $serverEntity->getStatus() === STATUS['OCCUPIED']) {
throw new \Exception("서비스중이 서버는 삭제하실수 없습니다.");
}
//아무것도 하지 않음
return $serverEntity;
}
}

View File

@ -4,10 +4,10 @@ namespace App\Services\Equipment\ServerPart;
use App\Entities\Equipment\ServerPartEntity;
use App\Interfaces\Equipment\ServerPartInterface;
use App\Entities\Part\SwitchEntity;
use App\Services\Part\SwitchService as ParentService;
use App\Entities\Part\SWITCHEntity;
use App\Services\Part\SWITCHService as ParentService;
class SwitchService extends ParentService implements ServerPartInterface
class SWITCHService extends ParentService implements ServerPartInterface
{
public function __construct()
{
@ -15,17 +15,17 @@ class SwitchService extends ParentService implements ServerPartInterface
}
//서버연결정보용 등록
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): SwitchEntity
private function action_process(ServerPartEntity $serverPartEntity, array $formDatas = []): SWITCHEntity
{
if (!array_key_exists('status', $formDatas)) {
throw new \Exception(__METHOD__ . "에서 오류발생: Switch상태가 설정되지 않았습니다.");
throw new \Exception(__METHOD__ . "에서 오류발생: SWITCH상태가 설정되지 않았습니다.");
}
//Switch정보가져오기
//SWITCH정보가져오기
$entity = $this->getEntity($serverPartEntity->getPartUID());
if (!$entity instanceof SwitchEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 Switch정보를 찾을수없습니다.");
if (!$entity instanceof SWITCHEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
}
//Switch정보 수정
//SWITCH정보 수정
return $this->getModel()->modify($entity, $formDatas);
}
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity

View File

@ -21,8 +21,8 @@ class ServiceService extends ParentService implements ServerPartInterface
if (!$entity instanceof ServiceEntity) {
throw new \Exception("[{$serverPartEntity->getServiceInfoUID()}]에 대한 서비스정보를 찾을수 없습니다.");
}
//서비스금액은 modify 함수내에서 재계산을 하므로 여기서는 modify만 호출함
return $this->getModel()->modify($entity, []);
//서비스금액변경 사항이 있는지 확인후 처리
return $this->setAmount($entity);
}
public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity
{

View File

@ -25,7 +25,6 @@ class IPService extends PartService
{
return [
"lineinfo_uid",
"serverinfo_uid",
"ip",
"price",
"status",

View File

@ -2,20 +2,20 @@
namespace App\Services\Part;
use App\Helpers\Part\SwitchHelper;
use App\Models\Part\SwitchModel;
use App\Helpers\Part\SWITCHHelper;
use App\Models\Part\SWITCHModel;
use App\Services\Customer\ServiceService;
use App\Services\Equipment\ServerService;
use App\Services\Part\PartService;
class SwitchService extends PartService
class SWITCHService extends PartService
{
private ?ServiceService $_serviceService = null;
private ?ServerService $_serverService = null;
public function __construct()
{
parent::__construct(new SwitchModel(), new SwitchHelper());
$this->addClassName('Switch');
parent::__construct(new SWITCHModel(), new SWITCHHelper());
$this->addClassName('SWITCH');
}
public function getFormFields(): array
{

View File

@ -116,6 +116,16 @@ class PaymentService extends CommonService
}
return $unPaids;
}
final public function setAmount(PaymentEntity $entity, int $amount): PaymentEntity
{
if ($entity->getStatus() !== STATUS['UNPAID']) {
throw new \Exception(__METHOD__ . "에서 오류발생: 지급이 완료된 결제정보는 수정할 수 없습니다.");
}
if ($entity->getAmount() !== $amount) {
$this->getModel()->modify($entity, ['amount' => $amount]);
}
return $entity;
}
//기본 기능부분
//FieldForm관련용
final public function getFormOption(string $field, array $options = []): array

View File

@ -23,6 +23,7 @@ class UserService extends CommonService
'email',
'mobile',
'role',
'status',
];
}
public function getFormFilters(): array

View File

@ -11,7 +11,4 @@
<div class="accordion-item">
<a href="/admin/equipment/server"><?= ICONS['SERVICE_ITEM_SERVER'] ?>Server정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/serverpart"><?= ICONS['SERVICE_ITEM_SERVER'] ?>Server부품연결정보</a>
</div>
</div>

View File

@ -6,7 +6,7 @@
</h2>
<div id="flush-part" class="accordion-collapse collapse" aria-labelledby="flush-part">
<div class="accordion-item">
<a href="/admin/part/switch"><?= ICONS['SETUP'] ?>Switch정보</a>
<a href="/admin/part/switch"><?= ICONS['SETUP'] ?>SWITCH정보</a>
</div>
<div class="accordion-item">
<a href="/admin/part/ip"><?= ICONS['SERVICE_ITEM_IP'] ?>IP정보</a>