getEntity($serverPartEntity->getPartUID()); if (!$entity instanceof OSEntity) { throw new \Exception("{$serverPartEntity->getPartUID()}에 해당하는 부품정보를 찾을수없습니다."); } //부품정보에 서버정보 설정 및 서비스,고객정보 정의 $formDatas = []; if ($action === "return") { //해지된 부품 재고 반납 처리 $formDatas['stock'] = $entity->getStock() + $serverPartEntity->getCnt(); } if ($action === "use") { //사용된 부품 재고 사용처리 if ($entity->getStock() < $serverPartEntity->getCnt()) { throw new \Exception("현재 재고수[{$entity->getStock()}]보다 지정하신 갯수({$serverPartEntity->getCnt()})가 더 많습니다."); } $formDatas['stock'] = $entity->getStock() - $serverPartEntity->getCnt(); } return parent::modify($entity, $formDatas); } public function createServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity { $entity = $this->action_process($serverPartEntity, "use"); return $serverPartEntity->setPartEntity($entity); } public function modifyServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity { return $this->createServerPart($serverPartEntity,); } public function deleteServerPart(ServerPartEntity $serverPartEntity): ServerPartEntity { $entity = $this->action_process($serverPartEntity, "return"); return $serverPartEntity->setPartEntity($entity); } }