trafficmonitor init...2
This commit is contained in:
parent
b0e304592a
commit
c18a8bb859
@ -9,6 +9,7 @@ use CodeIgniter\HTTP\RequestInterface;
|
|||||||
use CodeIgniter\HTTP\RedirectResponse;
|
use CodeIgniter\HTTP\RedirectResponse;
|
||||||
use App\Entities\CommonEntity;
|
use App\Entities\CommonEntity;
|
||||||
use App\Controllers\CommonController;
|
use App\Controllers\CommonController;
|
||||||
|
use App\DTOs\CommonDTO;
|
||||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||||
use CodeIgniter\HTTP\DownloadResponse;
|
use CodeIgniter\HTTP\DownloadResponse;
|
||||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||||
@ -18,15 +19,24 @@ use PhpOffice\PhpSpreadsheet\Writer\Pdf\Mpdf;
|
|||||||
abstract class AdminController extends CommonController
|
abstract class AdminController extends CommonController
|
||||||
{
|
{
|
||||||
public const PATH = 'admin';
|
public const PATH = 'admin';
|
||||||
|
private ?string $_title = null;
|
||||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||||
{
|
{
|
||||||
parent::initController($request, $response, $logger);
|
parent::initController($request, $response, $logger);
|
||||||
$this->addActionPaths(self::PATH);
|
$this->addActionPaths(self::PATH);
|
||||||
}
|
}
|
||||||
|
abstract protected function createDTO(array $formDatas): CommonDTO;
|
||||||
final protected function getLayout(): string
|
final protected function getLayout(): string
|
||||||
{
|
{
|
||||||
return 'admin';
|
return 'admin';
|
||||||
}
|
}
|
||||||
|
protected function getTitle(): string
|
||||||
|
{
|
||||||
|
if ($this->_title === null) {
|
||||||
|
$this->_title = lang("{$this->service->getClassPaths()}.title");
|
||||||
|
}
|
||||||
|
return $this->_title;
|
||||||
|
}
|
||||||
protected function action_init_process(string $action): void
|
protected function action_init_process(string $action): void
|
||||||
{
|
{
|
||||||
$this->addViewDatas('layout', $this->getLayout());
|
$this->addViewDatas('layout', $this->getLayout());
|
||||||
@ -39,101 +49,117 @@ abstract class AdminController extends CommonController
|
|||||||
$this->addViewDatas('index_batchjobButtions', $this->service->getFormService()->getBatchjobButtons());
|
$this->addViewDatas('index_batchjobButtions', $this->service->getFormService()->getBatchjobButtons());
|
||||||
parent::action_init_process($action);
|
parent::action_init_process($action);
|
||||||
}
|
}
|
||||||
abstract protected function create_form_process(): void;
|
protected function create_form_process(array $formDatas = []): array
|
||||||
final public function create_form(): string
|
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
//Form Default값 설정
|
||||||
try {
|
return $formDatas;
|
||||||
//초기화
|
}
|
||||||
$this->action_init_process($action);
|
final public function create_form(): string|RedirectResponse
|
||||||
$this->create_form_process();
|
{
|
||||||
} catch (\Exception $e) {
|
try {
|
||||||
log_message('error', $e->getMessage());
|
$action = __FUNCTION__;
|
||||||
session()->setFlashdata('message', $e->getMessage());
|
$this->action_init_process($action);
|
||||||
}
|
$formDatas = $this->create_form_process();
|
||||||
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
$this->addViewDatas('formDatas', $formDatas);
|
||||||
|
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function create_process(): CommonEntity
|
||||||
|
{
|
||||||
|
//요청 데이터를 DTO 객체로 변환
|
||||||
|
$dto = $this->createDTO($this->request->getPost());
|
||||||
|
return $this->service->create($dto);
|
||||||
}
|
}
|
||||||
abstract protected function create_process(): array;
|
|
||||||
final public function create(): string|RedirectResponse
|
final public function create(): string|RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
//초기화
|
$this->action_init_process(__FUNCTION__);
|
||||||
$this->action_init_process($action);
|
$entity = $this->create_process();
|
||||||
list($entity, $message) = $this->create_process();
|
return $this->action_modal_process("{$this->getTitle()}에서 생성이 완료되었습니다.");
|
||||||
return $this->action_modal_process($message);
|
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// 검증 실패 시 폼으로 돌아가서 오류 메시지 표시
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage());
|
||||||
log_message('error', $e->getMessage());
|
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', $e->getMessage());
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage());
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abstract protected function modify_form_process($uid): void;
|
protected function modify_form_process($uid): CommonEntity
|
||||||
final public function modify_form($uid): string
|
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
if (!$uid) {
|
||||||
try {
|
throw new \Exception("{$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||||
//초기화
|
|
||||||
$this->action_init_process($action);
|
|
||||||
$this->modify_form_process($uid);
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
log_message('error', $e->getMessage());
|
|
||||||
session()->setFlashdata('message', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
$entity = $this->service->getEntity($uid);
|
||||||
|
if (!$entity instanceof CommonEntity) {
|
||||||
|
throw new \Exception("{$uid}에 해당하는 {$this->getTitle()}을 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
final public function modify_form($uid): string|RedirectResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$action = __FUNCTION__;
|
||||||
|
$this->action_init_process($action);
|
||||||
|
$entity = $this->modify_form_process($uid);
|
||||||
|
$this->addViewDatas('entity', $entity);
|
||||||
|
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function modify_process($uid): CommonEntity
|
||||||
|
{
|
||||||
|
//요청 데이터를 DTO 객체로 변환
|
||||||
|
$dto = $this->createDTO($this->request->getPost());
|
||||||
|
return $this->service->modify($uid, $dto);
|
||||||
}
|
}
|
||||||
abstract protected function modify_process($uid): array;
|
|
||||||
final public function modify($uid): string|RedirectResponse
|
final public function modify($uid): string|RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
//초기화
|
$this->action_init_process(__FUNCTION__);
|
||||||
$this->action_init_process($action);
|
$entity = $this->modify_process($uid);
|
||||||
list($entity, $message) = $this->modify_process($uid);
|
return $this->action_modal_process("{$this->getTitle()}에서 {$uid} 수정이 완료되었습니다.");
|
||||||
return $this->action_modal_process($message);
|
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
// 검증 실패 시 폼으로 돌아가서 오류 메시지 표시
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||||
log_message('error', $e->getMessage());
|
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', $e->getMessage());
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abstract protected function delete_process($uid): array;
|
protected function delete_process($uid): CommonEntity
|
||||||
|
{
|
||||||
|
return $this->service->delete($uid);
|
||||||
|
}
|
||||||
final public function delete($uid): RedirectResponse
|
final public function delete($uid): RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
list($entity, $message) = $this->delete_process($uid);
|
$entity = $this->delete_process($uid);
|
||||||
$redirect_url = $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
|
return $this->action_redirect_process('info', "{$this->getTitle()}에서 {$entity->getTitle()} 삭제가 완료되었습니다.");
|
||||||
return redirect()->to($redirect_url)->with('message', $message);
|
|
||||||
} catch (ValidationException $e) {
|
|
||||||
// 검증 실패 시 폼으로 돌아가서 오류 메시지 표시
|
|
||||||
log_message('error', $e->getMessage());
|
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', $e->getMessage());
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||||
return redirect()->back()->withInput()->with('message', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
abstract protected function view_process($uid): CommonEntity;
|
protected function view_process($uid): CommonEntity
|
||||||
final public function view($uid): string
|
{
|
||||||
|
if (!$uid) {
|
||||||
|
throw new \Exception("{$this->getTitle()}에 번호가 정의 되지 않았습니다.");
|
||||||
|
}
|
||||||
|
$entity = $this->service->getEntity($uid);
|
||||||
|
if (!$entity instanceof CommonEntity) {
|
||||||
|
throw new \Exception("{$uid}에 해당하는 {$this->getTitle()}을 찾을수 없습니다.");
|
||||||
|
}
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
final public function view($uid): string|RedirectResponse
|
||||||
{
|
{
|
||||||
$action = __FUNCTION__;
|
|
||||||
try {
|
try {
|
||||||
//초기화
|
$action = __FUNCTION__;
|
||||||
$this->action_init_process($action);
|
$this->action_init_process($action);
|
||||||
$entity = $this->view_process($uid);
|
$entity = $this->view_process($uid);
|
||||||
$this->addViewDatas('entity', $entity);
|
$this->addViewDatas('entity', $entity);
|
||||||
|
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
log_message('error', $e->getMessage());
|
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage());
|
||||||
session()->setFlashdata('message', $e->getMessage());
|
|
||||||
}
|
}
|
||||||
return $this->action_render_process($this->getActionPaths(), $action, $this->getViewDatas());
|
|
||||||
}
|
}
|
||||||
//리스트관련
|
//리스트관련
|
||||||
//조건절 처리
|
//조건절 처리
|
||||||
|
|||||||
@ -19,6 +19,10 @@ class CollectorController extends AdminController
|
|||||||
}
|
}
|
||||||
$this->addActionPaths($this::PATH);
|
$this->addActionPaths($this::PATH);
|
||||||
}
|
}
|
||||||
|
protected function createDTO(array $formDatas): CollectorDTO
|
||||||
|
{
|
||||||
|
return parent::createDTO($formDatas);
|
||||||
|
}
|
||||||
protected function action_init_process(string $action): void
|
protected function action_init_process(string $action): void
|
||||||
{
|
{
|
||||||
$fields = ['trafficinfo_uid', 'in', 'out', 'raw_in', 'raw_out',];
|
$fields = ['trafficinfo_uid', 'in', 'out', 'raw_in', 'raw_out',];
|
||||||
@ -47,52 +51,24 @@ class CollectorController extends AdminController
|
|||||||
$this->service->getFormService()->setBatchjobFilters($filters);
|
$this->service->getFormService()->setBatchjobFilters($filters);
|
||||||
parent::action_init_process($action);
|
parent::action_init_process($action);
|
||||||
}
|
}
|
||||||
//Action작업관련
|
protected function create_process(): CollectorEntity
|
||||||
protected function create_form_process(): void
|
|
||||||
{
|
{
|
||||||
//Form Default값 설정
|
return parent::create_process();
|
||||||
$formDatas = [];
|
|
||||||
$this->addViewDatas('formDatas', $formDatas);
|
|
||||||
}
|
}
|
||||||
protected function create_process(): array
|
protected function modify_form_process($uid): CollectorEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::modify_form_process($uid);
|
||||||
$dto = new CollectorDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->create($dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 수집정보 생성이 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function modify_form_process($uid): void
|
protected function modify_process($uid): CollectorEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::modify_process($uid);
|
||||||
throw new \Exception("수집정보 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof CollectorEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 수집정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$this->addViewDatas('entity', $entity);
|
|
||||||
}
|
}
|
||||||
protected function modify_process($uid): array
|
protected function delete_process($uid): CollectorEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::delete_process($uid);
|
||||||
$dto = new CollectorDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->modify($uid, $dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 수집정보 수정이 완료되었습니다.");
|
|
||||||
}
|
|
||||||
protected function delete_process($uid): array
|
|
||||||
{
|
|
||||||
$entity = $this->service->delete($uid);
|
|
||||||
return array($entity, "{$entity->getTitle()} 수집정보 삭제 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function view_process($uid): CollectorEntity
|
protected function view_process($uid): CollectorEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::view_process($uid);
|
||||||
throw new \Exception("수집정보 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof CollectorEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 수집정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,10 @@ class MylogController extends AdminController
|
|||||||
}
|
}
|
||||||
$this->addActionPaths($this::PATH);
|
$this->addActionPaths($this::PATH);
|
||||||
}
|
}
|
||||||
|
protected function createDTO(array $formDatas): MylogDTO
|
||||||
|
{
|
||||||
|
return parent::createDTO($formDatas);
|
||||||
|
}
|
||||||
protected function action_init_process(string $action): void
|
protected function action_init_process(string $action): void
|
||||||
{
|
{
|
||||||
$fields = ['title', 'content'];
|
$fields = ['title', 'content'];
|
||||||
@ -47,52 +51,24 @@ class MylogController extends AdminController
|
|||||||
$this->service->getFormService()->setBatchjobFilters($filters);
|
$this->service->getFormService()->setBatchjobFilters($filters);
|
||||||
parent::action_init_process($action);
|
parent::action_init_process($action);
|
||||||
}
|
}
|
||||||
//Action작업관련
|
protected function create_process(): MylogEntity
|
||||||
protected function create_form_process(): void
|
|
||||||
{
|
{
|
||||||
//Form Default값 설정
|
return parent::create_process();
|
||||||
$formDatas = [];
|
|
||||||
$this->addViewDatas('formDatas', $formDatas);
|
|
||||||
}
|
}
|
||||||
protected function create_process(): array
|
protected function modify_form_process($uid): MylogEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::modify_form_process($uid);
|
||||||
$dto = new MylogDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->create($dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 로그 생성이 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function modify_form_process($uid): void
|
protected function modify_process($uid): MylogEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::modify_process($uid);
|
||||||
throw new \Exception("로그 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof MylogEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 로그를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$this->addViewDatas('entity', $entity);
|
|
||||||
}
|
}
|
||||||
protected function modify_process($uid): array
|
protected function delete_process($uid): MylogEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::delete_process($uid);
|
||||||
$dto = new MylogDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->modify($uid, $dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 로그 수정이 완료되었습니다.");
|
|
||||||
}
|
|
||||||
protected function delete_process($uid): array
|
|
||||||
{
|
|
||||||
$entity = $this->service->delete($uid);
|
|
||||||
return array($entity, "{$entity->getTitle()} 로그정보 삭제 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function view_process($uid): MylogEntity
|
protected function view_process($uid): MylogEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::view_process($uid);
|
||||||
throw new \Exception("로그정보 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof MylogEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 로그정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,10 @@ class TrafficController extends AdminController
|
|||||||
}
|
}
|
||||||
$this->addActionPaths($this::PATH);
|
$this->addActionPaths($this::PATH);
|
||||||
}
|
}
|
||||||
|
protected function createDTO(array $formDatas): TrafficDTO
|
||||||
|
{
|
||||||
|
return parent::createDTO($formDatas);
|
||||||
|
}
|
||||||
protected function action_init_process(string $action): void
|
protected function action_init_process(string $action): void
|
||||||
{
|
{
|
||||||
$fields = ['client', 'switch', 'ip', 'interface', 'status'];
|
$fields = ['client', 'switch', 'ip', 'interface', 'status'];
|
||||||
@ -46,52 +50,24 @@ class TrafficController extends AdminController
|
|||||||
$this->service->getFormService()->setBatchjobFilters($filters);
|
$this->service->getFormService()->setBatchjobFilters($filters);
|
||||||
parent::action_init_process($action);
|
parent::action_init_process($action);
|
||||||
}
|
}
|
||||||
//Action작업관련
|
protected function create_process(): TrafficEntity
|
||||||
protected function create_form_process(): void
|
|
||||||
{
|
{
|
||||||
//Form Default값 설정
|
return parent::create_process();
|
||||||
$formDatas = [];
|
|
||||||
$this->addViewDatas('formDatas', $formDatas);
|
|
||||||
}
|
}
|
||||||
protected function create_process(): array
|
protected function modify_form_process($uid): TrafficEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::modify_form_process($uid);
|
||||||
$dto = new TrafficDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->create($dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 트래픽정보 생성이 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function modify_form_process($uid): void
|
protected function modify_process($uid): TrafficEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::modify_process($uid);
|
||||||
throw new \Exception("트래픽정보 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof TrafficEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 트래픽정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$this->addViewDatas('entity', $entity);
|
|
||||||
}
|
}
|
||||||
protected function modify_process($uid): array
|
protected function delete_process($uid): TrafficEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::delete_process($uid);
|
||||||
$dto = new TrafficDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->modify($uid, $dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 트래픽정보 수정이 완료되었습니다.");
|
|
||||||
}
|
|
||||||
protected function delete_process($uid): array
|
|
||||||
{
|
|
||||||
$entity = $this->service->delete($uid);
|
|
||||||
return array($entity, "{$entity->getTitle()} 트래픽정보 삭제 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function view_process($uid): TrafficEntity
|
protected function view_process($uid): TrafficEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::view_process($uid);
|
||||||
throw new \Exception("트래픽정보 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof TrafficEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 트래픽정보를 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,10 @@ class UserController extends AdminController
|
|||||||
}
|
}
|
||||||
$this->addActionPaths($this::PATH);
|
$this->addActionPaths($this::PATH);
|
||||||
}
|
}
|
||||||
|
protected function createDTO(array $formDatas): UserDTO
|
||||||
|
{
|
||||||
|
return parent::createDTO($formDatas);
|
||||||
|
}
|
||||||
//Action작업관련
|
//Action작업관련
|
||||||
protected function action_init_process(string $action): void
|
protected function action_init_process(string $action): void
|
||||||
{
|
{
|
||||||
@ -47,51 +51,29 @@ class UserController extends AdminController
|
|||||||
$this->service->getFormService()->setBatchjobFilters($filters);
|
$this->service->getFormService()->setBatchjobFilters($filters);
|
||||||
parent::action_init_process($action);
|
parent::action_init_process($action);
|
||||||
}
|
}
|
||||||
protected function create_form_process(): void
|
protected function create_form_process(array $formDatas = []): array
|
||||||
{
|
{
|
||||||
//Form Default값 설정
|
|
||||||
$formDatas = ['role' => [ROLE['USER']['MANAGER']]];
|
$formDatas = ['role' => [ROLE['USER']['MANAGER']]];
|
||||||
$this->addViewDatas('formDatas', $formDatas);
|
return parent::create_form_process($formDatas);
|
||||||
}
|
}
|
||||||
protected function create_process(): array
|
protected function create_process(): UserEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::create_process();
|
||||||
$dto = new UserDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->create($dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 계정 생성이 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function modify_form_process($uid): void
|
protected function modify_form_process($uid): UserEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::modify_form_process($uid);
|
||||||
throw new \Exception("계정 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof UserEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 계정을 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
$this->addViewDatas('entity', $entity);
|
|
||||||
}
|
}
|
||||||
protected function modify_process($uid): array
|
protected function modify_process($uid): UserEntity
|
||||||
{
|
{
|
||||||
//요청 데이터를 DTO 객체로 변환
|
return parent::modify_process($uid);
|
||||||
$dto = new UserDTO($this->request->getPost());
|
|
||||||
$entity = $this->service->modify($uid, $dto);
|
|
||||||
return array($entity, "{$entity->getTitle()} 계정 수정이 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function delete_process($uid): array
|
protected function delete_process($uid): UserEntity
|
||||||
{
|
{
|
||||||
$entity = $this->service->delete($uid);
|
return parent::delete_process($uid);
|
||||||
return array($entity, "{$entity->getTitle()} 계정 삭제 완료되었습니다.");
|
|
||||||
}
|
}
|
||||||
protected function view_process($uid): UserEntity
|
protected function view_process($uid): UserEntity
|
||||||
{
|
{
|
||||||
if (!$uid) {
|
return parent::view_process($uid);
|
||||||
throw new \Exception("계정 번호가 정의 되지 않았습니다.");
|
|
||||||
}
|
|
||||||
$entity = $this->service->getEntity($uid);
|
|
||||||
if (!$entity instanceof UserEntity) {
|
|
||||||
throw new \Exception("{$uid}에 해당하는 계정을 찾을수 없습니다.");
|
|
||||||
}
|
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,9 +80,27 @@ abstract class CommonController extends BaseController
|
|||||||
</script>
|
</script>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
protected function action_redirect_process(string $redirect_url, string $message): RedirectResponse
|
protected function action_redirect_process(string $type, string $message, ?string $redirect_url = null): RedirectResponse
|
||||||
{
|
{
|
||||||
return redirect()->to($redirect_url)->with('message', $message);
|
switch ($type) {
|
||||||
|
case 'warning':
|
||||||
|
case 'error':
|
||||||
|
case 'critical':
|
||||||
|
case 'alert':
|
||||||
|
case 'emergency':
|
||||||
|
log_message($type, $message);
|
||||||
|
$result = $redirect_url ? $result = redirect()->to($redirect_url)->with('message', $message) : redirect()->back()->withInput()->with('message', $message);
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
case 'info':
|
||||||
|
case 'notice':
|
||||||
|
default:
|
||||||
|
log_message($type, $message);
|
||||||
|
$redirect_url = $redirect_url ?? $this->getAuthContext()->popPreviousUrl() ?? implode(DIRECTORY_SEPARATOR, $this->getActionPaths());
|
||||||
|
$result = redirect()->to($redirect_url)->with('message', $message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
protected function action_render_process(array $view_paths, string $view_file, array $viewDatas): string
|
protected function action_render_process(array $view_paths, string $view_file, array $viewDatas): string
|
||||||
{
|
{
|
||||||
|
|||||||
@ -192,7 +192,12 @@ abstract class CommonService
|
|||||||
if (!$entity instanceof CommonEntity) {
|
if (!$entity instanceof CommonEntity) {
|
||||||
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 정보을 찾을수 없습니다.");
|
throw new \Exception(__METHOD__ . "에서 오류발생: {$uid}에 해당하는 정보을 찾을수 없습니다.");
|
||||||
}
|
}
|
||||||
$result = $this->model->delete($uid);
|
return $entity;
|
||||||
|
}
|
||||||
|
final public function delete($uid): CommonEntity
|
||||||
|
{
|
||||||
|
$entity = $this->delete_process($uid);
|
||||||
|
$result = $this->model->delete($entity->getPK());
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$errors = $this->model->errors();
|
$errors = $this->model->errors();
|
||||||
$errorMsg = is_array($errors) ? implode(", ", $errors) : "모델 삭제 작업이 실패했습니다.";
|
$errorMsg = is_array($errors) ? implode(", ", $errors) : "모델 삭제 작업이 실패했습니다.";
|
||||||
@ -200,10 +205,6 @@ abstract class CommonService
|
|||||||
}
|
}
|
||||||
return $entity;
|
return $entity;
|
||||||
}
|
}
|
||||||
final public function delete($uid): CommonEntity
|
|
||||||
{
|
|
||||||
return $this->delete_process($uid);
|
|
||||||
}
|
|
||||||
//Index용
|
//Index용
|
||||||
final public function getTotalCount(): int
|
final public function getTotalCount(): int
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user