dbmsv2_init...1

This commit is contained in:
choi.jh 2025-09-29 18:34:50 +09:00
parent fa700e56c8
commit a68c539ec0
10 changed files with 52 additions and 22 deletions

View File

@ -6,6 +6,7 @@ use App\Entities\Equipment\ServerEntity;
use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\ServerPartEntity;
use App\Entities\PaymentEntity; use App\Entities\PaymentEntity;
use App\Helpers\Equipment\ServerPartHelper; use App\Helpers\Equipment\ServerPartHelper;
use App\Interfaces\Customer\ServiceInterface;
use App\Interfaces\Equipment\ServerInterface; use App\Interfaces\Equipment\ServerInterface;
use App\Models\Equipment\ServerPartModel; use App\Models\Equipment\ServerPartModel;
use App\Services\Customer\ServiceService; use App\Services\Customer\ServiceService;
@ -365,9 +366,27 @@ class ServerPartService extends EquipmentService implements ServerInterface
} }
public function unsetServer(ServerEntity $serverEntity, array $serverDatas): ServerEntity public function unsetServer(ServerEntity $serverEntity, array $serverDatas): ServerEntity
{ {
//기존 ServerPart정보 삭제
//기존 ServerPart정보 삭제(서버파트정보 (월비용,일회성) 상품 회수처리)
foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) { foreach ($this->getEntities(['serverinfo_uid' => $serverEntity->getPK()]) as $serverPartEntity) {
$this->getModel()->delete($serverPartEntity); switch ($serverPartEntity->getType()) {
case 'CPU':
case 'RAM':
case 'DISK':
//기본이 아닌 결제방식의 경우 모두 회수처리
if ($serverPartEntity->getBilling() !== PAYMENT['BILLING']['BASE']) {
//Type에 따른 부품서비스 정의
$this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []);
//서버연결정보 식제
parent::delete($serverPartEntity);
}
break;
default: //IP,SWITCH,CS,SOFTWARE,OS등은 모두 회수처리
$this->getPartService($serverPartEntity->getType())->unSetServerPart($serverPartEntity, []);
//서버연결정보 식제
parent::delete($serverPartEntity);
break;
}
} }
return $serverEntity; return $serverEntity;
} }

View File

@ -183,7 +183,7 @@ class ServerService extends EquipmentService implements ServiceInterface
public function delete(mixed $entity): ServerEntity public function delete(mixed $entity): ServerEntity
{ {
//선처리작업 //선처리작업
$entity = $this->action_process($entity, __FUNCTION__ . 'Server'); $entity = $this->getServerPartService()->unsetServer($entity, []);;
return parent::delete($entity); return parent::delete($entity);
} }
//List 검색용 //List 검색용
@ -217,7 +217,7 @@ class ServerService extends EquipmentService implements ServiceInterface
$formDatas['type'] = $serviceDatas['type']; $formDatas['type'] = $serviceDatas['type'];
} }
//필수정보처리 후 서버정보등록 후 서비스정보 Entity에 서버정보 설정 //필수정보처리 후 서버정보등록 후 서비스정보 Entity에 서버정보 설정
return $serviceEntity->setServerEntity($this->getModel()->modify($entity, $formDatas)); return $serviceEntity->setServerEntity(parent::modify($entity, $formDatas));
} }
public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity public function changeService(ServiceEntity $oldServiceEntity, ServiceEntity $serviceEntity, array $serviceDatas): ServiceEntity
{ {
@ -247,8 +247,9 @@ class ServerService extends EquipmentService implements ServiceInterface
$formDatas['serviceinfo_uid'] = null; $formDatas['serviceinfo_uid'] = null;
$formDatas['format_at'] = date("Y-m-d"); $formDatas['format_at'] = date("Y-m-d");
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = STATUS['AVAILABLE'];
$entity = $this->getModel()->modify($entity, $formDatas); $entity = parent::modify($entity, $formDatas);
//서비스정보 Entity에 서버정보 설정 //서버파트정보 회수처리 호출
$this->getServerPartService()->unsetServer($entity, []);
return $serviceEntity; return $serviceEntity;
} }
//서버파트관련 작업 //서버파트관련 작업

View File

@ -65,7 +65,8 @@ class CPUService extends PartService implements ServerPartInterface
if ($entity->getStock() < $serverPartEntity->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -85,6 +86,7 @@ class CPUService extends PartService implements ServerPartInterface
if (!$entity instanceof CPUEntity) { if (!$entity instanceof CPUEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -122,7 +122,7 @@ class CSService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
} }
//CS정보 수정 //CS정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -150,6 +150,6 @@ class CSService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 CS정보를 찾을수없습니다.");
} }
//CS정보 수정 //CS정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
} }

View File

@ -65,7 +65,8 @@ class DISKService extends PartService implements ServerPartInterface
if ($entity->getStock() < $serverPartEntity->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -85,6 +86,7 @@ class DISKService extends PartService implements ServerPartInterface
if (!$entity instanceof DISKEntity) { if (!$entity instanceof DISKEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -137,7 +137,7 @@ class IPService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
} }
// IP정보 수정 // IP정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -168,6 +168,6 @@ class IPService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 IP정보를 찾을수없습니다.");
} }
// IP정보 수정 // IP정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
} }

View File

@ -65,7 +65,8 @@ class OSService extends PartService implements ServerPartInterface
if ($entity->getStock() < $serverPartEntity->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -85,6 +86,7 @@ class OSService extends PartService implements ServerPartInterface
if (!$entity instanceof OSEntity) { if (!$entity instanceof OSEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -65,7 +65,8 @@ class RAMService extends PartService implements ServerPartInterface
if ($entity->getStock() < $serverPartEntity->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -85,6 +86,7 @@ class RAMService extends PartService implements ServerPartInterface
if (!$entity instanceof RAMEntity) { if (!$entity instanceof RAMEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
return $serverPartEntity;
} }
} }

View File

@ -65,7 +65,8 @@ class SOFTWAREService extends PartService implements ServerPartInterface
if ($entity->getStock() < $serverPartEntity->getCnt()) { if ($entity->getStock() < $serverPartEntity->getCnt()) {
throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() - $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -85,6 +86,7 @@ class SOFTWAREService extends PartService implements ServerPartInterface
if (!$entity instanceof SOFTWAREEntity) { if (!$entity instanceof SOFTWAREEntity) {
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다.");
} }
return $this->getModel()->modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]); $entity = parent::modify($entity, ['stock' => $entity->getStock() + $serverPartEntity->getCnt()]);
return $serverPartEntity->setPartEntity($entity);
} }
} }

View File

@ -107,7 +107,7 @@ class SWITCHService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
} }
//SWITCH정보 수정 //SWITCH정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity public function changeServerPart(ServerPartEntity $oldServerPartEntity, ServerPartEntity $serverPartEntity, array $serverPartDatas): ServerPartEntity
{ {
@ -136,6 +136,6 @@ class SWITCHService extends PartService implements ServerPartInterface
throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다."); throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 SWITCH정보를 찾을수없습니다.");
} }
//SWITCH정보 수정 //SWITCH정보 수정
return $serverPartEntity->setPartEntity($this->getModel()->modify($entity, $formDatas)); return $serverPartEntity->setPartEntity(parent::modify($entity, $formDatas));
} }
} }