dbmsv4 init...3

This commit is contained in:
최준흠 2025-12-19 14:54:06 +09:00
parent 2558691116
commit 8c72f8dc10
32 changed files with 152 additions and 187 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,32 +4,13 @@ namespace App\Entities\Part;
use App\Models\Part\CPUModel;
class CPUEntity extends PartEntity
class CPUEntity extends PartType1Entity
{
const PK = CPUModel::PK;
const TITLE = CPUModel::TITLE;
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'status' => '',
];
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
public function getStock(): int
{
return $this->attributes['stock'] ?? 0;
}
public function getUsed(): int
{
return $this->attributes['used'] ?? 0;
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}
}

View File

@ -4,7 +4,7 @@ namespace App\Entities\Part;
use App\Models\Part\CSModel;
class CSEntity extends PartEntity
class CSEntity extends PartType2Entity
{
const PK = CSModel::PK;
const TITLE = CSModel::TITLE;

View File

@ -4,7 +4,7 @@ namespace App\Entities\Part;
use App\Models\Part\DISKModel;
class DISKEntity extends PartEntity
class DISKEntity extends PartType1Entity
{
const PK = DISKModel::PK;
const TITLE = DISKModel::TITLE;
@ -21,20 +21,9 @@ class DISKEntity extends PartEntity
parent::__construct($data);
}
//기본기능
public function getStock(): int
{
return $this->attributes['stock'] ?? 0;
}
public function getFormat(): int
{
return $this->attributes['format'] ?? 0;
}
public function getUsed(): int
{
return $this->attributes['used'] ?? 0;
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed() - $this->getFormat();
}
}

View File

@ -4,7 +4,7 @@ namespace App\Entities\Part;
use App\Models\Part\IPModel;
class IPEntity extends PartEntity
class IPEntity extends PartType3Entity
{
const PK = IPModel::PK;
const TITLE = IPModel::TITLE;

View File

@ -10,6 +10,8 @@ abstract class PartEntity extends CommonEntity
{
parent::__construct($data);
}
abstract public function getAvailable(): int;
abstract public function getUsed(): int;
//기본기능용
public function getCustomTitle(mixed $title = null): string
{

View File

@ -0,0 +1,33 @@
<?php
namespace App\Entities\Part;
use App\Models\Part\CPUModel;
class PartType1Entity extends PartEntity
{
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'status' => '',
];
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
final public function getStock(): int
{
return $this->attributes['stock'] ?? 0;
}
final public function getUsed(): int
{
return $this->attributes['used'] ?? 0;
}
final public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}
}

View File

@ -0,0 +1,24 @@
<?php
namespace App\Entities\Part;
class PartType2Entity extends PartEntity
{
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
final public function getStock(): int
{
return 0;
}
final public function getUsed(): int
{
return 0;
}
final public function getAvailable(): int
{
return 0;
}
}

View File

@ -0,0 +1,12 @@
<?php
namespace App\Entities\Part;
class PartType3Entity extends PartType2Entity
{
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
}

View File

@ -4,7 +4,7 @@ namespace App\Entities\Part;
use App\Models\Part\RAMModel;
class RAMEntity extends PartEntity
class RAMEntity extends PartType1Entity
{
const PK = RAMModel::PK;
const TITLE = RAMModel::TITLE;
@ -20,16 +20,4 @@ class RAMEntity extends PartEntity
parent::__construct($data);
}
//기본기능
public function getStock(): int
{
return $this->attributes['stock'] ?? 0;
}
public function getUsed(): int
{
return $this->attributes['used'] ?? 0;
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}
}

View File

@ -4,32 +4,8 @@ namespace App\Entities\Part;
use App\Models\Part\SOFTWAREModel;
class SOFTWAREEntity extends PartEntity
class SOFTWAREEntity extends PartType1Entity
{
const PK = SOFTWAREModel::PK;
const TITLE = SOFTWAREModel::TITLE;
protected $attributes = [
'title' => '',
'used' => 0,
'price' => 0,
'stock' => 0,
'status' => '',
];
public function __construct(array|null $data = null)
{
parent::__construct($data);
}
//기본기능
public function getStock(): int
{
return $this->attributes['stock'] ?? 0;
}
public function getUsed(): int
{
return $this->attributes['used'] ?? 0;
}
public function getAvailable(): int
{
return $this->getStock() - $this->getUsed();
}
}

View File

@ -4,7 +4,7 @@ namespace App\Entities\Part;
use App\Models\Part\SWITCHModel;
class SWITCHEntity extends PartEntity
class SWITCHEntity extends PartType3Entity
{
const PK = SWITCHModel::PK;
const TITLE = SWITCHModel::TITLE;

View File

@ -13,6 +13,7 @@ class CPUForm extends PartForm
$fields = [
"title",
"price",
"used",
"stock",
];
$filters = [

View File

@ -13,6 +13,7 @@ class DISKForm extends PartForm
$fields = [
"title",
"price",
"used",
"stock",
];
$filters = [

View File

@ -13,6 +13,7 @@ class RAMForm extends PartForm
$fields = [
"title",
"price",
"used",
"stock",
];
$filters = [

View File

@ -13,6 +13,7 @@ class SOFTWAREForm extends PartForm
$fields = [
"title",
"price",
"used",
"stock",
];
$filters = [

View File

@ -84,7 +84,7 @@ class PaymentHelper extends CommonHelper
{
switch ($field) {
case "countdown": //결제일Countdown
$value = $viewDatas['entity']->getCountDueAt();
$value = $viewDatas['entity']->getStatus() === STATUS['PAID'] ? $viewDatas['entity']->getUpdatedAT() : $viewDatas['entity']->getCountDueAt();
break;
case 'amount':
$value = sprintf("%s%s", number_format($value), $viewDatas['entity']->getPay() == 'coupon' ? "" : "");

View File

@ -15,7 +15,7 @@ return [
'updated_at' => "변경일",
'created_at' => "생성일",
'deleted_at' => "삭제일",
'countdown' => "납부기한",
'countdown' => "납부기한/완료",
],
"BILLING" => [
PAYMENT['BILLING']['MONTH'] => "매월",

View File

@ -151,10 +151,7 @@ class ServerPartService extends EquipmentService
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생:Return Type은 PaymentEntity만 가능");
}
//해당 파트정보가 변경
if ($oldEntity->getPartUid() != $entity->getPartUid()) {
$this->getPartService($entity->getType())->detachFromServerPart($oldEntity);
$this->getPartService($entity->getType())->attachToServerPart($entity);
}
$this->getPartService($entity->getType())->modifyServerPart($oldEntity, $entity);
//서비스가 정의 되어 있으면
if ($serviceEntity instanceof ServiceEntity) {
//Billing형식이 Month이면 서비스 금액설정 호출

View File

@ -84,16 +84,4 @@ class CPUService extends PartType1Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CPUEntity
{
/** @var CPUEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CPUEntity
{
/** @var CPUEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -8,7 +8,6 @@ use App\Helpers\Part\CSHelper;
use App\Forms\Part\CSForm;
use App\Entities\Part\CSEntity;
use App\Entities\Equipment\ServerPartEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\CSDTO;
class CSService extends PartType2Service
@ -86,16 +85,4 @@ class CSService extends PartType2Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
{
/** @var CSEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CSEntity
{
/** @var CSEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -82,21 +82,19 @@ class DISKService extends PartType1Service
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity($serverPartEntity->getPartUid());
if (!$entity instanceof DISKEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverPartEntity->getPartUid()}에 해당하는 DISKEntity정보를 찾을수없습니다.");
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverPartEntity->getPartUid()}에 해당하는 디스크정보를 찾을수없습니다.");
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): DISKEntity
{
/** @var DISKEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): DiskEntity
{
/** @var DiskEntity $entity IDE에 entity type알려주기*/
$entity = $this->getPartEntityByServerPart($serverPartEntity);
$formDatas['format'] = $entity->getFormat() + $serverPartEntity->getCnt();
return parent::detachFromServerPart($serverPartEntity, $formDatas);
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
if (!$entity instanceof DiskEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverPartEntity->getPartUid()}에 해당하는 디스크정보를 찾을수없습니다.");
}
return $entity;
}
}

View File

@ -77,7 +77,7 @@ class IPService extends PartType3Service
//서버관련 작업
//파트정보가져오기
public function getPartEntityByServer(ServerEntity $serverEntity): IPEntity
public function getPartEntityByServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity
{
//IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정
$entity = $this->getEntity(['ip' => $serverEntity->getIP()]);
@ -86,18 +86,15 @@ class IPService extends PartType3Service
}
return $entity;
}
public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity
{
/** @var IPEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServer($serverEntity, $formDatas);
return $entity;
}
public function detachFromServer(ServerEntity $serverEntity, array $formDatas = []): IPEntity
{
/** @var IPEntity $entity IDE에 entity type알려주기*/
$entity = $this->getPartEntityByServer($serverEntity);
$formDatas['old_clientinfo_uid'] = $entity->getClientInfoUid() ?? $serverEntity->getClientInfoUid();
$entity = parent::detachFromServer($serverEntity, $formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverEntity->getIP()}에 해당하는 IP정보를 찾을수없습니다.");
}
return $entity;
}
//서버파트관련 작업
@ -111,12 +108,6 @@ class IPService extends PartType3Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): IPEntity
{
/** @var IPEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
//사용했던 고객정보 남기기위해 추가
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): IPEntity
{
@ -124,6 +115,9 @@ class IPService extends PartType3Service
$entity = $this->getPartEntityByServerPart($serverPartEntity);
$formDatas['old_clientinfo_uid'] = $entity->getClientInfoUid();
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
if (!$entity instanceof IPEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 {$serverPartEntity->getPartUid()}에 해당하는 IP정보를 찾을수없습니다.");
}
return $entity;
}
}

View File

@ -14,6 +14,7 @@ abstract class PartService extends CommonService
parent::__construct($model);
$this->addClassPaths('Part');
}
abstract public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): PartEntity;
abstract public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): PartEntity;
abstract public function attachToServerPart(ServerPartEntity $serverPartEntity): PartEntity;
abstract public function modifyServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PartEntity;
abstract public function detachFromServerPart(ServerPartEntity $serverPartEntity): PartEntity;
}

View File

@ -25,9 +25,29 @@ abstract class PartType1Service extends PartService
if ($entity->getAvailable() < $serverPartEntity->getCnt()) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 {$entity->getTitle()}는 사용가능 갯수[{$entity->getAvailable()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
}
$formDatas = [];
$formDatas['used'] = $entity->getUsed() + $serverPartEntity->getCnt();
return parent::modify_process($entity, $formDatas);
}
public function modifyServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity): PartEntity
{
if ($oldServerPartEntity->getPartUid() != $serverPartEntity->getPartUid()) {
$this->detachFromServerPart($oldServerPartEntity);
$this->attachToServerPart($serverPartEntity);
}
// PartUID가 바뀌지 않고 다른 값만 바뀐경우
//부품정보가져오기
/** @var PartEntity $entity IDE에 entity type알려주기*/
$entity = $this->getPartEntityByServerPart($serverPartEntity);
//기존 파트 정보와 신규 파트정보의 사용한 갯수 비교
$formDatas = [];
if ($oldServerPartEntity->getCnt() < $serverPartEntity->getCnt()) {
$formDatas['used'] = $entity->getUsed() + ($serverPartEntity->getCnt() - $oldServerPartEntity->getCnt());
} else {
$formDatas['used'] = $entity->getUsed() + ($oldServerPartEntity->getCnt() - $serverPartEntity->getCnt());
}
return parent::modify_process($entity, $formDatas);
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): PartEntity
{
//부품정보가져오기
@ -37,6 +57,7 @@ abstract class PartType1Service extends PartService
if ($entity->getUsed() < $serverPartEntity->getCnt()) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 현재 {$entity->getTitle()}는 사용된 갯수[{$entity->getUsed()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
}
$formDatas = [];
$formDatas['used'] = $entity->getUsed() - $serverPartEntity->getCnt();
return parent::modify_process($entity, $formDatas);
}

View File

@ -29,6 +29,15 @@ abstract class PartType2Service extends PartService
//파트정보 수정
return parent::modify_process($entity, $formDatas);
}
public function modifyServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $formDatas = []): PartEntity
{
// 파트정보가 변경되었으면
if ($oldServerPartEntity->getPartUid() != $serverPartEntity->getPartUid()) {
$this->detachFromServerPart($oldServerPartEntity);
$this->attachToServerPart($serverPartEntity);
}
return $this->getPartEntityByServerPart($serverPartEntity);
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): PartEntity
{
$formDatas['clientinfo_uid'] = null;

View File

@ -16,6 +16,7 @@ abstract class PartType3Service extends PartType2Service
//서버관련 작업
public function attachToServer(ServerEntity $serverEntity, array $formDatas = []): PartEntity
{
$formDatas = [];
$formDatas['clientinfo_uid'] = $serverEntity->getClientInfoUid();
$formDatas['serviceinfo_uid'] = $serverEntity->getServiceInfoUid();
$formDatas['serverinfo_uid'] = $serverEntity->getPK();

View File

@ -84,16 +84,4 @@ class RAMService extends PartType1Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): RAMEntity
{
/** @var RAMEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): RAMEntity
{
/** @var RAMEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -85,16 +85,4 @@ class SOFTWAREService extends PartType1Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): SOFTWAREEntity
{
/** @var SOFTWAREEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): SOFTWAREEntity
{
/** @var SOFTWAREEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -110,16 +110,4 @@ class SWITCHService extends PartType3Service
}
return $entity;
}
public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): SWITCHEntity
{
/** @var SWITCHEntity $entity IDE에 entity type알려주기*/
$entity = parent::attachToServerPart($serverPartEntity, $formDatas);
return $entity;
}
public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): SWITCHEntity
{
/** @var SWITCHEntity $entity IDE에 entity type알려주기*/
$entity = parent::detachFromServerPart($serverPartEntity, $formDatas);
return $entity;
}
}

View File

@ -160,14 +160,10 @@ class PaymentService extends CommonService
if ($entity->getStatus() === STATUS['PAID']) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 이미 지불된 결제정보는 수정이 불가합니다.");
}
if (!array_key_exists('serviceinfo_uid', $formDatas)) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: 서비스가 정의되지 않았습니다.");
}
$serviceEntity = service('customer_serviceservice')->getEntity($formDatas['serviceinfo_uid']);
$serviceEntity = service('customer_serviceservice')->getEntity($entity->getServiceInfoUid());
if (!$serviceEntity instanceof ServiceEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$formDatas['serviceinfo_uid']}에 해당하는 서비스정보를 찾을 수 없습니다.");
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$entity->getServiceInfoUid()}에 해당하는 서비스정보를 찾을 수 없습니다.");
}
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUid();
//수정된 결제정보
$entity = parent::modify_process($entity, $formDatas);
if (!$entity instanceof PaymentEntity) {
@ -276,7 +272,7 @@ class PaymentService extends CommonService
$formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUid();
$formDatas["clientinfo_uid"] = $serverPartEntity->getClientInfoUid();
$formDatas["serverpartinfo_uid"] = $serverPartEntity->getPK();
$formDatas['amount'] = $serverPartEntity->getAmount();
$formDatas['amount'] = $serverPartEntity->getCalculatedAmount();
$formDatas['billing'] = $formDatas['billing'] ?? PAYMENT['BILLING']['ONETIME'];
$formDatas['billing_at'] = $serverPartEntity->getBillingAt();
$formDatas['pay'] = $formDatas['pay'] ?? PAYMENT['PAY']['ACCOUNT'];