dbmsv4 init...1
This commit is contained in:
parent
76173ac564
commit
b6690d72d0
@ -152,10 +152,10 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au
|
||||
$routes->post('batchjob', 'ServiceController::batchjob');
|
||||
$routes->post('batchjob_delete', 'ServiceController::batchjob_delete');
|
||||
$routes->get('download/(:alpha)', 'ServiceController::download/$1');
|
||||
$routes->get('addServer/(:num)', 'ServiceController::addServer_form/$1');
|
||||
$routes->post('addServer/(:num)', 'ServiceController::addServer/$1');
|
||||
$routes->get('changeServer/(:num)', 'ServiceController::changeServer/$1');
|
||||
$routes->get('terminateServer/(:num)', 'ServiceController::terminateServer/$1');
|
||||
$routes->get('addServer/(:num)', 'ServiceController::alternative_create_form/$1');
|
||||
$routes->post('addServer/(:num)', 'ServiceController::alternative_create/$1');
|
||||
$routes->get('changeServer/(:num)', 'ServiceController::alternative_modify/$1');
|
||||
$routes->get('terminateServer/(:num)', 'ServiceController::alternative_delete/$1');
|
||||
$routes->post('history/(:num)', 'ServiceController::history/$1');
|
||||
});
|
||||
});
|
||||
|
||||
@ -47,11 +47,13 @@ abstract class AbstractCRUDController extends AbstractWebController
|
||||
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(
|
||||
'/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
)->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다.");
|
||||
return $this->action_redirect_process(
|
||||
'info',
|
||||
"{$this->getTitle()}에서 {$entity->getTitle()} 생성이 완료되었습니다.",
|
||||
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
);
|
||||
}
|
||||
|
||||
final public function create(): string|RedirectResponse
|
||||
@ -107,11 +109,13 @@ abstract class AbstractCRUDController extends AbstractWebController
|
||||
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(
|
||||
'/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
)->with('message', "{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다.");
|
||||
return $this->action_redirect_process(
|
||||
'info',
|
||||
"{$this->getTitle()}에서 {$entity->getTitle()} 수정이 완료되었습니다.",
|
||||
$redirect_url ?? '/' . implode('/', [...$this->getActionPaths(), 'view']) . '/' . $entity->getPK()
|
||||
);
|
||||
}
|
||||
final public function modify($uid): string|RedirectResponse
|
||||
{
|
||||
@ -136,9 +140,9 @@ abstract class AbstractCRUDController extends AbstractWebController
|
||||
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
|
||||
{
|
||||
|
||||
@ -53,4 +53,70 @@ class ServiceController extends CustomerController
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -239,30 +239,32 @@ class ServerService extends EquipmentService
|
||||
//OrderBy 처리
|
||||
|
||||
//서비스관련
|
||||
public function attachToService(ServiceEntity $serviceEntity): void
|
||||
public function attachToService(ServiceEntity $serviceEntity, array $formDatas = []): void
|
||||
{
|
||||
//서버정보 가져오기
|
||||
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
|
||||
$formDatas["clientinfo_uid"] = $serviceEntity->getClientInfoUID();
|
||||
$formDatas['status'] = STATUS['OCCUPIED'];
|
||||
$formDatas['status'] = $formDatas['status'] ?? STATUS['OCCUPIED'];
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
parent::modify_process($entity, $formDatas);
|
||||
}
|
||||
public function detachFromService(ServiceEntity $serviceEntity): void
|
||||
public function detachFromService(ServiceEntity $serviceEntity, array $formDatas = []): void
|
||||
{
|
||||
//서버정보 가져오기
|
||||
$entity = $this->getEntity($serviceEntity->getServerInfoUID());
|
||||
$formDatas = [];
|
||||
$formDatas['serviceinfo_uid'] = NULL;
|
||||
$formDatas["clientinfo_uid"] = NULL;
|
||||
$formDatas['status'] = STATUS['AVAILABLE'];
|
||||
$formDatas['status'] = $formDatas['status'] ?? STATUS['AVAILABLE'];
|
||||
$fields = array_keys($formDatas);
|
||||
$this->getFormService()->setFormFields($fields);
|
||||
$this->getFormService()->setFormRules('modify', $fields);
|
||||
parent::modify_process($entity, $formDatas);
|
||||
//서버파트정보처리
|
||||
service('part_ipservice')->attachToServer($entity);
|
||||
service('part_switchservice')->attachToServer($entity);
|
||||
service('equipment_serverpartservice')->detachFromServer($entity);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,14 +2,12 @@
|
||||
|
||||
namespace App\Services\Part;
|
||||
|
||||
use RuntimeException;
|
||||
use App\Models\Part\IPModel;
|
||||
use App\Helpers\Part\IPHelper;
|
||||
use App\Forms\Part\IPForm;
|
||||
use App\Entities\Part\IPEntity;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Entities\CommonEntity;
|
||||
use App\DTOs\Part\IPDTO;
|
||||
|
||||
class IPService extends PartType3Service
|
||||
|
||||
Loading…
Reference in New Issue
Block a user