dbmsv4 init...1

This commit is contained in:
최준흠 2025-12-01 17:46:59 +09:00
parent 76173ac564
commit b6690d72d0
6 changed files with 105 additions and 22 deletions

View File

@ -152,10 +152,10 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
$routes->post('batchjob', 'ServiceController::batchjob'); $routes->post('batchjob', 'ServiceController::batchjob');
$routes->post('batchjob_delete', 'ServiceController::batchjob_delete'); $routes->post('batchjob_delete', 'ServiceController::batchjob_delete');
$routes->get('download/(:alpha)', 'ServiceController::download/$1'); $routes->get('download/(:alpha)', 'ServiceController::download/$1');
$routes->get('addServer/(:num)', 'ServiceController::addServer_form/$1'); $routes->get('addServer/(:num)', 'ServiceController::alternative_create_form/$1');
$routes->post('addServer/(:num)', 'ServiceController::addServer/$1'); $routes->post('addServer/(:num)', 'ServiceController::alternative_create/$1');
$routes->get('changeServer/(:num)', 'ServiceController::changeServer/$1'); $routes->get('changeServer/(:num)', 'ServiceController::alternative_modify/$1');
$routes->get('terminateServer/(:num)', 'ServiceController::terminateServer/$1'); $routes->get('terminateServer/(:num)', 'ServiceController::alternative_delete/$1');
$routes->post('history/(:num)', 'ServiceController::history/$1'); $routes->post('history/(:num)', 'ServiceController::history/$1');
}); });
}); });

View File

@ -47,11 +47,13 @@ abstract class AbstractCRUDController extends AbstractWebController
return $this->service->create($dto); return $this->service->create($dto);
} }
protected function create_result_process(CommonEntity $entity): string|RedirectResponse protected function create_result_process(CommonEntity $entity, ?string $redirect_url = null): string|RedirectResponse
{ {
return redirect()->to( return $this->action_redirect_process(
'/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK() 'info',
)->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다."); "{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다.",
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
);
} }
final public function create(): string|RedirectResponse final public function create(): string|RedirectResponse
@ -107,11 +109,13 @@ abstract class AbstractCRUDController extends AbstractWebController
return $this->service->modify($uid, $dto); return $this->service->modify($uid, $dto);
} }
protected function modify_result_process(CommonEntity $entity): string|RedirectResponse protected function modify_result_process(CommonEntity $entity, ?string $redirect_url = null): string|RedirectResponse
{ {
return redirect()->to( return $this->action_redirect_process(
'/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK() 'info',
)->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다."); "{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다.",
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
);
} }
final public function modify($uid): string|RedirectResponse final public function modify($uid): string|RedirectResponse
{ {
@ -136,9 +140,9 @@ abstract class AbstractCRUDController extends AbstractWebController
return $this->service->delete($uid); return $this->service->delete($uid);
} }
protected function delete_result_process(CommonEntity $entity): string|RedirectResponse protected function delete_result_process(CommonEntity $entity, ?string $redirect_url = null): string|RedirectResponse
{ {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$entity->getTitle()} 삭제가 완료되었습니다."); return $this->action_redirect_process('info', "{$this->getTitle()}에서 {$entity->getTitle()} 삭제가 완료되었습니다.", $redirect_url);
} }
final public function delete($uid): RedirectResponse final public function delete($uid): RedirectResponse
{ {

View File

@ -53,4 +53,70 @@ class ServiceController extends CustomerController
return $this->action_redirect_process('error', "{$this->getTitle()}에서 비고 오류:" . $e->getMessage()); return $this->action_redirect_process('error', "{$this->getTitle()}에서 비고 오류:" . $e->getMessage());
} }
} }
//대체서버 추가
public function alternative_create_form(int $uid): string|RedirectResponse
{
try {
$action = __FUNCTION__;
$fields = ['serverinfo_uid'];
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate'));
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 대체서버추가 오류:" . $e->getMessage());
}
}
public function alternative_create(int $uid): string|RedirectResponse
{
try {
$action = __FUNCTION__;
$fields = ['serverinfo_uid'];
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
//서비스정보 가져오기
$entity = $this->service->getEntity($uid);
//대체서버 추가
service('equipment_server')->attachToService($entity, $this->request->getPost());
return $this->action_redirect_process('info', "{$this->getTitle()}에서 대체서버추가가 완료되었습니다");
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 대체서버추가 오류:" . $e->getMessage());
}
}
//대체서버 -> 메인서버로 바꾼다.
public function alternative_modify(int $uid): string|RedirectResponse
{
try {
$action = __FUNCTION__;
$fields = ['serverinfo_uid'];
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
//서비스정보 가져오기
$entity = $this->service->getEntity($uid);
//메인서버 해지
service('equipment_server')->detachFromService($entity, ['serverinfo_uid' => $entity->getServerInfoUID()]);
//대체서버를 메인서버로 설정
service('equipment_server')->attachToService($entity, $this->request->getGet());
return $this->action_redirect_process('info', "{$this->getTitle()}에서 메인서버설정이 완료되었습니다");
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 메인서버설정 오류:" . $e->getMessage());
}
}
public function alternative_delete(int $uid): string|RedirectResponse
{
try {
$action = __FUNCTION__;
$fields = ['serverinfo_uid'];
$this->service->getFormService()->setFormFields($fields);
$this->service->getFormService()->setFormRules($action, $fields);
//서비스정보 가져오기
$entity = $this->service->getEntity($uid);
//대체서버 해지
service('equipment_server')->attachToService($entity, $this->request->getGet());
return $this->action_redirect_process('info', "{$this->getTitle()}에서 대체서버해지가 완료되었습니다");
} catch (\Throwable $e) {
return $this->action_redirect_process('error', "{$this->getTitle()}에서 대체서버 해지 오류:" . $e->getMessage());
}
}
} }

View File

@ -185,4 +185,17 @@ class ServerPartService extends EquipmentService
} }
} }
} }
public function detachFromServer(ServerEntity $serverEntity): void
{
//서버정보에 해당하는 ServerPart정보 상태가 기본인것 제외한 모두 회수처리.
foreach (
$this->getEntities([
'serverinfo_uid' => $serverEntity->getPK(),
"billing !=" => PAYMENT['BILLING']['BASE']
]) as $entity
) {
$this->getPartService($entity->getType())->detachFromServerPart($entity);
parent::delete($entity->getPK());
}
}
} }

View File

@ -239,30 +239,32 @@ class ServerService extends EquipmentService
//OrderBy 처리 //OrderBy 처리
//서비스관련 //서비스관련
public function attachToService(ServiceEntity $serviceEntity): void public function attachToService(ServiceEntity $serviceEntity, array $formDatas = []): void
{ {
//서버정보 가져오기 //서버정보 가져오기
$entity = $this->getEntity($serviceEntity->getServerInfoUID()); $entity = $this->getEntity($serviceEntity->getServerInfoUID());
$formDatas = [];
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK(); $formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID(); $formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
$formDatas['status'] = STATUS['OCCUPIED']; $formDatas['status'] = $formDatas['status'] ?? STATUS['OCCUPIED'];
$fields = array_keys($formDatas); $fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields); $this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields); $this->getFormService()->setFormRules('modify', $fields);
parent::modify_process($entity, $formDatas); parent::modify_process($entity, $formDatas);
} }
public function detachFromService(ServiceEntity $serviceEntity): void public function detachFromService(ServiceEntity $serviceEntity, array $formDatas = []): void
{ {
//서버정보 가져오기 //서버정보 가져오기
$entity = $this->getEntity($serviceEntity->getServerInfoUID()); $entity = $this->getEntity($serviceEntity->getServerInfoUID());
$formDatas = [];
$formDatas['serviceinfo_uid'] = NULL; $formDatas['serviceinfo_uid'] = NULL;
$formDatas["clientinfo_uid"] = NULL; $formDatas["clientinfo_uid"] = NULL;
$formDatas['status'] = STATUS['AVAILABLE']; $formDatas['status'] = $formDatas['status'] ?? STATUS['AVAILABLE'];
$fields = array_keys($formDatas); $fields = array_keys($formDatas);
$this->getFormService()->setFormFields($fields); $this->getFormService()->setFormFields($fields);
$this->getFormService()->setFormRules('modify', $fields); $this->getFormService()->setFormRules('modify', $fields);
parent::modify_process($entity, $formDatas); parent::modify_process($entity, $formDatas);
//서버파트정보처리
service('part_ipservice')->attachToServer($entity);
service('part_switchservice')->attachToServer($entity);
service('equipment_serverpartservice')->detachFromServer($entity);
} }
} }

View File

@ -2,14 +2,12 @@
namespace App\Services\Part; namespace App\Services\Part;
use RuntimeException;
use App\Models\Part\IPModel; use App\Models\Part\IPModel;
use App\Helpers\Part\IPHelper; use App\Helpers\Part\IPHelper;
use App\Forms\Part\IPForm; use App\Forms\Part\IPForm;
use App\Entities\Part\IPEntity; use App\Entities\Part\IPEntity;
use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\ServerPartEntity;
use App\Entities\Equipment\ServerEntity; use App\Entities\Equipment\ServerEntity;
use App\Entities\CommonEntity;
use App\DTOs\Part\IPDTO; use App\DTOs\Part\IPDTO;
class IPService extends PartType3Service class IPService extends PartType3Service