diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php
index 9be70ca..8358093 100644
--- a/app/Services/CommonService.php
+++ b/app/Services/CommonService.php
@@ -6,6 +6,7 @@ use App\DTOs\CommonDTO;
use App\Entities\CommonEntity;
use App\Libraries\AuthContext;
use App\Models\CommonModel;
+use App\Services\Equipment\ServerService;
use CodeIgniter\Database\Exceptions\DatabaseException;
use CodeIgniter\Validation\Exceptions\ValidationException;
use RuntimeException;
@@ -224,6 +225,13 @@ abstract class CommonService
$fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields);
+ // if (static::class === ServerService::class) {
+ // var_dump($this->getFormService()->getFormRules());
+ // echo "
";
+ // var_dump($entity->toArray());
+ // echo "
";
+ // dd($formDatas);
+ // }
// 데이터 검증
if (!$this->getFormService()->validate($formDatas)) {
throw new ValidationException(
diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php
index 9793ff2..4997070 100644
--- a/app/Services/Customer/ServiceService.php
+++ b/app/Services/Customer/ServiceService.php
@@ -233,10 +233,8 @@ class ServiceService extends CustomerService
service('paymentservice')->modifyByService($oldEntity, $entity);
//서버정보 연결 신규서버로 변경
if ($oldEntity->getServerInfoUID() !== $entity->getServerInfoUID()) {
- //기존서버는 대체서버로 변경
+ // throw new RuntimeException("{$oldEntity->getServerInfoUID()} !== {$entity->getServerInfoUID()}");
service('equipment_serverservice')->modifyByService($oldEntity, $entity);
- //신규서버는 메인서버로 추가
- service('equipment_serverservice')->attatchToService($entity, $entity->getServerInfoUID());
}
return $entity;
}
diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php
index 6d8cc3f..40d2577 100644
--- a/app/Services/Equipment/ServerService.php
+++ b/app/Services/Equipment/ServerService.php
@@ -275,23 +275,22 @@ class ServerService extends EquipmentService
$formDatas['status'] = $formDatas['status'] ?? STATUS['OCCUPIED'];
parent::modify_process($entity, $formDatas);
}
- public function modifyByService(ServiceENtity $oldServiceEntity, ServiceEntity $serviceEntity, array $formDatas = []): void
+ public function modifyByService(ServiceENtity $oldServiceEntity, ServiceEntity $serviceEntity): void
{
- //기존 메인서버 정보를 대체서버로 변경
+ //기존 메인서버 정보
$oldEntity = $this->getEntity($oldServiceEntity->getServerInfoUID());
if (!$oldEntity instanceof ServerEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$oldServiceEntity->getServerInfoUID()}에 해당하는 서비스의 기존 메인 서버정보을 찾을수 없습니다.");
}
- //기존서버는 대체서버로 변경
- parent::modify_process($oldEntity, ['type' => 'alternative']);
- //신규 메인서버 설정
+ //신규 메인서버 정보
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
if (!$entity instanceof ServerEntity) {
throw new RuntimeException(static::class . '->' . __FUNCTION__ . "에서 오류발생: {$serviceEntity->getServerInfoUID()}에 해당하는 서비스의 신규 메인 서버정보을 찾을수 없습니다.");
}
- //신규 메인서버는 기존 메인서버의 타입으로 설정
- $formDatas['type'] = $oldEntity->getType();
- parent::modify_process($entity, $formDatas);
+ //신규 메인서버는 기존 메인서버의 타입으로 설정 식뉴규서버는 메인서버로 추가
+ $this->attatchToService($serviceEntity, $entity->getPK(), ['type' => $oldEntity->getType()]);
+ //기존서버는 대체서버로 변경
+ parent::modify_process($oldEntity, ['type' => 'alternative']);
}
//해지처리
public function deatchFromService($uid, array $formDatas = []): void