dbmsv4 init...2

This commit is contained in:
최준흠 2025-12-04 16:51:08 +09:00
parent e9fafc084f
commit e141e125f7
21 changed files with 156 additions and 81 deletions

View File

@ -1,10 +1,8 @@
<?php
namespace App\Cells\Part;
namespace App\Cells\Equipment;
use App\Services\Part\RAMService;
class CHASSISCell extends PartCell
class CHASSISCell extends EquipmentCell
{
public function __construct()
{
@ -13,8 +11,8 @@ class CHASSISCell extends PartCell
public function stock(array $params): string
{
$template = array_key_exists('template', $params) ? $params['template'] : 'chassis_stock';
return view('cells/part/' . $template, [
$template = array_key_exists('template', $params) ? $params['template'] : 'stock';
return view('cells/chassis/' . $template, [
'partCellDatas' => [
'entities' => $this->getService()->getEntities(),
],

View File

@ -201,6 +201,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'ServerPartController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServerPartController::download/$1');
});
$routes->group('chassis', function ($routes) {
$routes->get('/', 'CHASSISController::index');
$routes->get('create', 'CHASSISController::create_form');
$routes->post('create', 'CHASSISController::create');
$routes->get('modify/(:num)', 'CHASSISController::modify_form/$1');
$routes->post('modify/(:num)', 'CHASSISController::modify/$1');
$routes->get('view/(:num)', 'CHASSISController::view/$1');
$routes->get('delete/(:num)', 'CHASSISController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'CHASSISController::toggle/$1/$2');
$routes->post('batchjob', 'CHASSISController::batchjob');
$routes->post('batchjob_delete', 'CHASSISController::batchjob_delete');
$routes->get('download/(:alpha)', 'CHASSISController::download/$1');
});
});
//Equipment 관련
//Part 관련
@ -244,19 +257,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob_delete', 'CSController::batchjob_delete');
$routes->get('download/(:alpha)', 'CSController::download/$1');
});
$routes->group('chassis', function ($routes) {
$routes->get('/', 'CHASSISController::index');
$routes->get('create', 'CHASSISController::create_form');
$routes->post('create', 'CHASSISController::create');
$routes->get('modify/(:num)', 'CHASSISController::modify_form/$1');
$routes->post('modify/(:num)', 'CHASSISController::modify/$1');
$routes->get('view/(:num)', 'CHASSISController::view/$1');
$routes->get('delete/(:num)', 'CHASSISController::delete/$1');
$routes->get('toggle/(:num)/(:any)', 'CHASSISController::toggle/$1/$2');
$routes->post('batchjob', 'CHASSISController::batchjob');
$routes->post('batchjob_delete', 'CHASSISController::batchjob_delete');
$routes->get('download/(:alpha)', 'CHASSISController::download/$1');
});
$routes->group('cpu', function ($routes) {
$routes->get('/', 'CPUController::index');
$routes->get('create', 'CPUController::create_form');

View File

@ -13,8 +13,8 @@ use App\Services\Customer\ServiceService;
use App\Services\Equipment\LineService;
use App\Services\Equipment\ServerPartService;
use App\Services\Equipment\ServerService;
use App\Services\Equipment\CHASSISService;
use App\Services\MylogService;
use App\Services\Part\CHASSISService;
use App\Services\Part\CPUService;
use App\Services\Part\CSService;
use App\Services\Part\DISKService;
@ -201,7 +201,7 @@ class Services extends BaseService
return static::getSharedInstance(__FUNCTION__);
}
return new CHASSISService(
new \App\Models\Part\CHASSISModel(),
new \App\Models\Equipment\CHASSISModel(),
);
}
public static function part_cpuservice($getShared = true): CPUService

View File

@ -1,13 +1,13 @@
<?php
namespace App\Controllers\Admin\Part;
namespace App\Controllers\Admin\Equipment;
use App\Entities\Part\CHASSISEntity;
use App\Entities\Equipment\CHASSISEntity;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;
class CHASSISController extends PartController
class CHASSISController extends EquipmentController
{
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
{

View File

@ -1,6 +1,6 @@
<?php
namespace App\DTOs\Part;
namespace App\DTOs\Equipment;
use App\DTOs\CommonDTO;

View File

@ -1,14 +1,18 @@
<?php
namespace App\Entities\Part;
namespace App\Entities\Equipment;
use App\Models\Part\CHASSISModel;
use App\Models\Equipment\CHASSISModel;
class CHASSISEntity extends PartEntity
class CHASSISEntity extends EquipmentEntity
{
const PK = CHASSISModel::PK;
const TITLE = CHASSISModel::TITLE;
//기본기능
public function getPrice(): int
{
return $this->attributes['price'];
}
public function getStock(): int
{
return $this->attributes['stock'];

View File

@ -1,8 +1,8 @@
<?php
namespace App\Forms\Part;
namespace App\Forms\Equipment;
class CHASSISForm extends PartForm
class CHASSISForm extends EquipmentForm
{
public function __construct()
{

View File

@ -1,8 +1,8 @@
<?php
namespace App\Helpers\Part;
namespace App\Helpers\Equipment;
class CHASSISHelper extends PartHelper
class CHASSISHelper extends EquipmentHelper
{
public function __construct()
{

View File

@ -1,10 +1,10 @@
<?php
namespace App\Models\Part;
namespace App\Models\Equipment;
use App\Entities\Part\CHASSISEntity;
use App\Entities\Equipment\CHASSISEntity;
class CHASSISModel extends PartModel
class CHASSISModel extends EquipmentModel
{
const TABLE = "chassisinfo";
const PK = "uid";

View File

@ -251,7 +251,7 @@ class ServiceService extends CustomerService
//서비스비용 설정
$entity = $this->updateAmount($entity->getPK());
//결제정보 생성
service('paymentservice')->createByService($entity);
service('paymentservice')->modifyByService($entity);
return $entity;
}
//List 검색용

View File

@ -1,15 +1,15 @@
<?php
namespace App\Services\Part;
namespace App\Services\Equipment;
use App\Models\Part\CHASSISModel;
use App\Helpers\Part\CHASSISHelper;
use App\Forms\Part\CHASSISForm;
use App\Entities\Part\CHASSISEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\DTOs\Part\CHASSISDTO;
use App\DTOs\Equipment\CHASSISDTO;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\CHASSISEntity;
use App\Forms\Equipment\CHASSISForm;
use App\Helpers\Equipment\CHASSISHelper;
use App\Models\Equipment\CHASSISModel;
class CHASSISService extends PartType1Service
class CHASSISService extends EquipmentService
{
private $_form = null;
private $_helper = null;
@ -114,27 +114,40 @@ class CHASSISService extends PartType1Service
$this->model->orderBy('title ASC');
parent::setOrderBy($field, $value);
}
//서버파트관련 작업
//서버관련 작업
//파트정보가져오기
public function getPartEntityByServerPart(ServerPartEntity $serverPartEntity): CHASSISEntity
public function getPartEntityByServer(ServerEntity $serverEntity): CHASSISEntity
{
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUID());
$entity = $this->getEntity($serverEntity->getChassisInfoUID());
if (!$entity instanceof CHASSISEntity) {
throw new \Exception(message: "{$serverPartEntity->getPartUID()}에 해당하는 CHASSISEntity정보를 찾을수없습니다.");
throw new \Exception("{$serverEntity->getChassisInfoUID()}에 해당하는 샷시정보를 찾을수없습니다.");
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity
public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): CHASSISEntity
{
//부품정보가져오기
/** @var CHASSISEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
$entity = $this->getEntity($serverEntity->getChassisInfoUID());
//파트정보의 사용가능한 갯수 , 사용갯수 비교
if ($entity->getAvailable() < 1) {
throw new \Exception("현재 사용가능한 {$serverEntity->getTitle()} 샷시가 없습니다.");
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity
$formDatas['used'] = $entity->getUsed() + 1;
return parent::modify_process($entity, $formDatas);
}
public function detachFromServer(ServerEntity $serverEntity, array $formDatas = []): CHASSISEntity
{
//부품정보가져오기
/** @var CHASSISEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
$entity = $this->getEntity($serverEntity->getChassisInfoUID());
//파트정보의 사용된 갯수 , 회수용 갯수 비교
if ($entity->getUsed() < 1) {
throw new \Exception("현재 사용한 {$serverEntity->getTitle()} 샷시가 없습니다.");
}
$formDatas['used'] = $entity->getUsed() - 1;
return parent::modify_process($entity, $formDatas);
}
}

View File

@ -10,8 +10,6 @@ use App\Forms\Equipment\ServerPartForm;
use App\Entities\Part\PartEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\CommonEntity;
use App\DTOs\Equipment\ServerPartDTO;
class ServerPartService extends EquipmentService
@ -174,11 +172,11 @@ class ServerPartService extends EquipmentService
//검색어조건절처리
//서버추가시 기본파트 자동추가용
public function attachToServer(ServerEntity $serverEntity): void
public function defaultServerPart(ServerEntity $serverEntity): void
{
//*서버의 Title 대소문자구분 필요->서버의 Title로 구분해서 기본부품 추가
foreach (SERVERPART['SERVER_PARTTYPES'] as $parttype) {
//해당 서버의 chassis_uid에 해당하는 상수값이 있는지 체크
//해당 서버의 chassis_uid에 해당하는 Default값이 있는지 체크 후 서버파트 추가
if (array_key_exists($serverEntity->getChassisInfoUID(), SERVERPART[$parttype])) {
foreach (SERVERPART[$parttype][$serverEntity->getChassisInfoUID()] as $part) {
//해당 파트정보 가져오기
@ -202,20 +200,13 @@ class ServerPartService extends EquipmentService
$this->getFormService()->setFormRules('create', $fields);
$this->create_process($formDatas);
}
} else {
log_message("warning", __METHOD__ . "에서 결고발생: {$parttype} 파트 => SERVERPART[{$serverEntity->getChassisInfoUID()}] Default값이 정의되지 않았습니다.");
}
}
}
public function detachFromServer(ServerEntity $serverEntity): void
{
//서버정보에 해당하는 ServerPart정보 상태가 기본인것 제외한 모두 회수처리.
foreach (
$this->getEntities([
'serverinfo_uid' => $serverEntity->getPK(),
"billing !=" => PAYMENT['BILLING']['BASE']
]) as $entity
) {
foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK(), "billing !=" => PAYMENT['BILLING']['BASE']]) as $entity) {
$this->getPartService($entity->getType())->detachFromServerPart($entity);
parent::delete_process($entity);
}

View File

@ -216,21 +216,39 @@ class ServerService extends EquipmentService
//서버추가시 서버파트 자동추가용
service('part_ipservice')->attachToServer($entity);
service('part_switchservice')->attachToServer($entity);
service('equipment_chassisservice')->attachToServer($entity);
service('equipment_serverpartservice')->attachToServer($entity);
//Billing형식이 Month이면 서버쪽 금액설정 호출
if ($entity->getServiceInfoUID() !== null) {
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
}
return $entity;
}
protected function modify_process($entity, array $formDatas): ServerEntity
{
//필수항목검사
if (!array_key_exists('chassisinfo_uid', $formDatas)) {
throw new RuntimeException(__METHOD__ . '에서 오류발생: 샷시정보가 정의되지 않았습니다.');
}
//변경전 정보
$oldEntity = clone $entity;
$entity = parent::modify_process($entity, $formDatas);
if (!$entity instanceof ServerEntity) {
throw new RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
}
//Billing형식이 Month이면 서버쪽 금액설정 호출
if ($entity->getServiceInfoUID() !== null) {
//서버정보변경시 서버파트 정보변경용
//IP변경
if ($oldEntity->getIP() !== $entity->getIP()) {
service('part_ipservice')->detachFromServer($oldEntity);
service('part_ipservice')->attachToServer($entity);
}
//SWITCH변경
if ($oldEntity->getSwitchInfoUID() !== $entity->getSwitchInfoUID()) {
service('part_switchservice')->detachFromServer($oldEntity);
service('part_switchservice')->attachToServer($entity);
}
//샷시변경
if ($oldEntity->getSwitchInfoUID() !== $entity->getSwitchInfoUID()) {
service('equipment_chassisservice')->detachFromServer($oldEntity);
service('equipment_chassisservice')->attachToServer($entity);
}
if ($entity->getServiceInfoUID() !== null) { //서비스가 정의 되어 있으면
service('customer_serviceservice')->updateAmount($entity->getServiceInfoUID());
}
return $entity;
@ -269,6 +287,8 @@ class ServerService extends EquipmentService
}
$formDatas['serviceinfo_uid'] = NULL;
$formDatas["clientinfo_uid"] = NULL;
$formDatas["switchinfo_uid"] = NULL;
$formDatas["ip"] = NULL;
$formDatas['status'] = $formDatas['status'] ?? STATUS['AVAILABLE'];
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);

View File

@ -7,6 +7,7 @@ use App\Entities\CommonEntity;
use App\Entities\Customer\ClientEntity;
use App\Entities\Customer\ServiceEntity;
use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity;
use App\Forms\PaymentForm;
use App\Helpers\PaymentHelper;
@ -262,7 +263,7 @@ class PaymentService extends CommonService
//서비스정보의 지급기한일과 같은 결제정보 가져와서 결제정보 수정
$entity = $this->getEntity(['serviceinfo_uid' => $serviceEntity->getPK(), 'billing_at' => $serviceEntity->getBillingAt()]);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: 해당하는 결제정보을 찾을수 없습니다.");
throw new \Exception(__METHOD__ . "에서 오류발생: [{$serviceEntity->getPK()}]{$serviceEntity->getTitle()}해당하는 결제정보을 찾을수 없습니다.");
}
$formDatas = $this->getFormDatasByService($serviceEntity);
$fields = array_keys($formDatas);
@ -270,4 +271,44 @@ class PaymentService extends CommonService
$this->getFormService()->setFormRules('modify', $fields);
return parent::modify_process($entity, $formDatas);
}
//서버파트별 일회성 관련
private function getFormDatasByServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): array
{
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다.");
}
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID();
$formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUID();
$formDatas['amount'] = $serverPartEntity->getAmount();
$formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME'];
$formDatas['billing_at'] = date('Y-m-d');
$formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT'];
$formDatas['status'] = $formDatas['status'] ?? STATUS['UNPAID'];
$formDatas['title'] = sprintf("%s 일회성비용", $formDatas['title'] ?? $serverPartEntity->getTitle());
return $formDatas;
}
public function createByServerPart(ServerPartEntity $serverPartEntity): PaymentEntity
{
$formDatas = $this->getFormDatasByServerPart($serverPartEntity);
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('create', $fields);
return parent::create_process($formDatas);
}
public function modifyByServerPart(ServerPartEntity $serverPartEntity): PaymentEntity
{
if ($serverPartEntity->getServiceInfoUID() === null) {
throw new RuntimeException(__METHOD__ . "에서 오류발생: 서비스정보가 정의되지 않아 일회성 상품을 설정하실수 없습니다.");
}
//서비스정보의 지급기한일과 같은 결제정보 가져와서 결제정보 수정
$entity = $this->getEntity(['serverpartinfo_uid' => $serverPartEntity->getPK()]);
if (!$entity instanceof PaymentEntity) {
throw new \Exception(__METHOD__ . "에서 오류발생: [{$serverPartEntity->getPK()}]{$serverPartEntity->getTitle()}에 해당하는 결제정보을 찾을수 없습니다.");
}
$formDatas = $this->getFormDatasByServerPart($serverPartEntity);
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
return parent::modify_process($entity, $formDatas);
}
}

View File

@ -15,7 +15,7 @@
<th class="text-center">저장장치 재고</th>
</tr>
<tr>
<td><?= view_cell("\App\Cells\Part\CHASSISCell::stock") ?></td>
<td><?= view_cell("\App\Cells\Equipment\CHASSISCell::stock") ?></td>
<td><?= view_cell("\App\Cells\Part\RAMCell::stock") ?></td>
<td><?= view_cell("\App\Cells\Part\DISKCell::stock") ?></td>
</tr>

View File

@ -14,7 +14,7 @@
$entity->getTitle(),
'disk_modify',
[
"data-src" => "admin/part/chassis/modify/{$entity->getPK()}",
"data-src" => "admin/equipment/chassis/modify/{$entity->getPK()}",
"data-bs-toggle" => "modal",
"data-bs-target" => "#modal_action_form",
"class" => "text-primary form-label-sm",

View File

@ -5,7 +5,7 @@
<th style="width: 250px">
<?= $serverCellDatas['serviceEntity']->getServerInfoUID() == $entity->getPK() ? "📌" : "<a href=\"/admin/customer/service/changeServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">✔️</a>" ?>
<?= $serverCellDatas['serverPartHelper']->getFieldView('SERVER', "", ['serverEntity' => $entity]) ?>
<?= $serverCellDatas['serviceEntity']->getServerInfoUID() != $entity->getPK() ? "<a href=\"/admin/customer/service/terminateServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}\">❌</a>" : "" ?>
<a href="/admin/customer/service/terminateServer/{$serverCellDatas['serviceEntity']->getPK()}?serverinfo_uid={$entity->getPK()}"></a>
</th>
<th style=" width: 250px">
<?= $serverCellDatas['serverPartHelper']->getListButton('CPU', 'CPU', ['serverinfo_uid' => $entity->getPK()]) ?>

View File

@ -11,4 +11,8 @@
<div class="accordion-item">
<a href="/admin/equipment/server"><?= ICONS['SERVICE_ITEM_SERVER'] ?>Server정보</a>
</div>
<div class="accordion-item">
<a href="/admin/equipment/chassis"><?= ICONS['SETUP'] ?>서버샷시정보</a>
</div>
</div>

View File

@ -14,9 +14,6 @@
<div class="accordion-item">
<a href="/admin/part/cs"><?= ICONS['SERVICE_ITEM_DEFENCE'] ?>CS정보</a>
</div>
<div class="accordion-item">
<a href="/admin/part/chassis"><?= ICONS['SETUP'] ?>서버샷시정보</a>
</div>
<div class="accordion-item">
<a href="/admin/part/cpu"><?= ICONS['SERVER_ITEM_CPU'] ?>CPU정보</a>
</div>

View File

@ -1,3 +1,10 @@
<style>
/* .nav-tabs 하위의 모든 a 태그에 폰트 크기를 small로 적용 */
.nav-tabs a {
font-size: 0.875em;
/* Bootstrap .small 크기 */
}
</style>
<ul class="nav nav-tabs">
<li class="nav-item">
<span class="nav-item navbar-brand" aria-current="page">
@ -38,7 +45,7 @@
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/part/cs">CS정보</a></span>
</li>
<li class="nav-item">
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/part/chassis">서버샷시정보</a></span>
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/equipment/chassis">서버샷시정보</a></span>
</li>
<li class="nav-item">
<span class="nav-link active" aria-current="page" style="cursor:pointer;"><a href="/admin/part/cpu">CPU정보</a></span>