246 lines
11 KiB
PHP
246 lines
11 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers\Admin\Customer;
|
|
|
|
use App\Controllers\CommonController;
|
|
use App\Entities\TrafficEntity;
|
|
use App\Services\PipelineRunnerService;
|
|
use App\Services\TrafficeService;
|
|
use CodeIgniter\HTTP\RedirectResponse;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
use CodeIgniter\HTTP\ResponseInterface;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class TrafficController extends CommonController
|
|
{
|
|
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
|
{
|
|
parent::initController($request, $response, $logger);
|
|
if ($this->service === null) {
|
|
$this->service = service('serviceService');
|
|
}
|
|
$this->content_title = lang("{$this->service->getClassPath()}.title");
|
|
$this->class_path .= $this->service->getClassPath();
|
|
$this->uri_path .= strtolower($this->service->getClassPath('/')) . '/';
|
|
// $this->view_path .= strtolower($this->service->getClassPath()) . DIRECTORY_SEPARATOR;
|
|
}
|
|
//Index,FieldForm관련
|
|
//생성관련
|
|
public function create_form(): string
|
|
{
|
|
//기본값처리
|
|
$formDatas = [];
|
|
$formDatas['location'] = 'chiba';
|
|
$formDatas['rack'] = '100000';
|
|
$formDatas['line'] = '300000';
|
|
$formDatas['type'] = 'normal';
|
|
$formDatas['billing_at'] = date("Y-m-d");
|
|
$formDatas['start_at'] = date("Y-m-d");
|
|
$formDatas['status'] = DEFAULTS['STATUS'];
|
|
//viewData처리
|
|
$this->action = __FUNCTION__;
|
|
$this->formFields = $this->service->getFormFields();
|
|
$this->formFilters = $this->service->getFormFilters();
|
|
$this->formRules = $this->service->getFormRules(__FUNCTION__);
|
|
$this->formOptions = $this->service->getFormOptions(__FUNCTION__);
|
|
$this->formDatas = $formDatas;
|
|
// dd($this->getViewDatas());
|
|
$view_path = implode(DIRECTORY_SEPARATOR, [
|
|
$this->view_path,
|
|
$this->request->getVar('ActionTemplate') ?? 'service',
|
|
__FUNCTION__
|
|
]);
|
|
helper(['form', __FUNCTION__]);
|
|
return view($view_path, ['viewDatas' => [
|
|
'control' => $this->getViewDatas(),
|
|
'service' => $this->service,
|
|
'forms' => ['attributes' => ['method' => "post",], 'hiddens' => []]
|
|
]]);
|
|
}
|
|
// public function create(): RedirectResponse|string
|
|
// {
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields();
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getPost());
|
|
// $this->service->setFormFilters();
|
|
// $this->service->setFormRules();
|
|
// $this->doValidations();
|
|
// $context = $this->service->getFormDatas();
|
|
// $runner = new PipelineRunnerService();
|
|
// $runner->addStep(new ServiceRegistration(service('serviceService')))
|
|
// ->addStep(new PaymentRegistrationStep($services['payment']))
|
|
// ->addStep(new LogFinalizationStep());
|
|
// $this->context = $runner->run($context);
|
|
// return $this->getResultSuccess();
|
|
// } catch (Throwable $e) {
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
// //수정관련
|
|
// protected function modify_form_process(mixed $entity): ServiceEntity
|
|
// {
|
|
// $serverEntity = $this->service->getServerService()->getEntity($entity->getServerInfoUID());
|
|
// if (!$serverEntity instanceof ServerEntity) {
|
|
// throw new \Exception("[{$entity->getServerInfoUID()}]에 대한 서버정보를 찾을 수 없습니다.");
|
|
// }
|
|
// $this->serverEntity = $serverEntity;
|
|
// return parent::modify_form_process($entity);
|
|
// }
|
|
// //View 관련
|
|
// protected function view_process(mixed $entity): ServiceEntity
|
|
// {
|
|
// $serverEntity = $this->service->getServerService()->getEntity($entity->getServerInfoUID());
|
|
// if (!$serverEntity instanceof ServerEntity) {
|
|
// throw new \Exception("[{$entity->getServerInfoUID()}]에 대한 서버정보를 찾을 수 없습니다.");
|
|
// }
|
|
// $this->serverEntity = $serverEntity;
|
|
// return parent::view_process($entity);
|
|
// }
|
|
// //List 관련
|
|
// protected function index_process(array $entities = []): array
|
|
// {
|
|
// //서비스별 미납 Count
|
|
// $this->unPaids = $this->service->getPaymentService()->getUnPaids('serviceinfo_uid');
|
|
// //서비스별 서버리스트
|
|
// $childServers = [];
|
|
// foreach ($this->service->getEntities() as $entity) {
|
|
// $entities[] = $entity;
|
|
// $childServers[$entity->getPK()] = $this->service->getServerService()->getEntities(['serviceinfo_uid' => $entity->getPK()]);
|
|
// }
|
|
// $this->childServers = $childServers;
|
|
// return $entities;
|
|
// }
|
|
// //대체서버선정
|
|
// public function addServer_form(mixed $uid): RedirectResponse|string
|
|
// {
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields(['serverinfo_uid']);
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getGet());
|
|
// $this->service->setFormFilters();
|
|
// $this->service->setFormRules();
|
|
// $this->service->setFormOptions();
|
|
// //기존 Entity 가져오기
|
|
// $entity = $this->service->getEntity($uid);
|
|
// if (!$entity instanceof ServiceEntity) {
|
|
// throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
|
// }
|
|
// $this->entity = $entity;
|
|
// helper(['form']);
|
|
// $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
|
|
// return $this->getResultSuccess();
|
|
// } catch (\Exception $e) {
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
// //대체서버 등록
|
|
// public function addServer(int $uid): RedirectResponse|string
|
|
// {
|
|
// //Transaction Start
|
|
// $db = \Config\Database::connect();
|
|
// $db->transStart();
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields(['serverinfo_uid']);
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getPost());
|
|
// $this->service->setFormFilters();
|
|
// $this->service->setFormRules();
|
|
// $this->doValidations();
|
|
// //기존 Entity 가져오기
|
|
// $entity = $this->service->getEntity($uid);
|
|
// if (!$entity instanceof ServiceEntity) {
|
|
// throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
|
// }
|
|
// $this->entity = $this->service->addeAlternativeServer($entity, $this->service->getFormDatas());
|
|
// $db->transCommit();
|
|
// return $this->getResultSuccess('대체서버 추가가 완료되었습니다.');
|
|
// } catch (\Exception $e) {
|
|
// $db->transRollback();
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
// //대체서버를 MAIN서버로 설정
|
|
// public function changeServer(mixed $uid): RedirectResponse|string
|
|
// {
|
|
// //Transaction Start
|
|
// $db = \Config\Database::connect();
|
|
// $db->transStart();
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields(['serverinfo_uid']);
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getGet());
|
|
// $this->service->setFormFilters();
|
|
// $this->service->setFormRules();
|
|
// $this->doValidations();
|
|
// //기존 Entity 가져오기
|
|
// $entity = $this->service->getEntity($uid);
|
|
// if (!$entity instanceof ServiceEntity) {
|
|
// throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
|
// }
|
|
// //서버정보설정
|
|
// $this->service->replaceMainServer($entity, $this->service->getFormDatas());
|
|
// $db->transCommit();
|
|
// return $this->getResultSuccess('메인서버 설정이 바뀌었습니다.');
|
|
// } catch (\Exception $e) {
|
|
// $db->transRollback();
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
// //서비스 서버해지
|
|
// public function terminateServer(mixed $uid): RedirectResponse|string
|
|
// {
|
|
// //Transaction Start
|
|
// $db = \Config\Database::connect();
|
|
// $db->transStart();
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields(['serverinfo_uid']);
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getGet());
|
|
// //기존 Entity 가져오기
|
|
// $entity = $this->service->getEntity($uid);
|
|
// if (!$entity instanceof ServiceEntity) {
|
|
// throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
|
// }
|
|
// $formDatas = $this->service->getFormDatas();
|
|
// $this->service->terminateServer($entity, $formDatas);
|
|
// $db->transCommit();
|
|
// return $this->getResultSuccess('서버해지가 완료되었습니다.');
|
|
// } catch (\Exception $e) {
|
|
// $db->transRollback();
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
// public function history(int $uid): RedirectResponse|string
|
|
// {
|
|
// //Transaction Start
|
|
// $db = \Config\Database::connect();
|
|
// $db->transStart();
|
|
// try {
|
|
// $this->service->setAction(__FUNCTION__);
|
|
// $this->service->setFormFields(['history']);
|
|
// $this->service->setFormFilters();
|
|
// $this->service->setFormRules();
|
|
// //전달값정의
|
|
// $this->service->setFormDatas($this->request->getPost());
|
|
// $this->doValidations();
|
|
// //기존 Entity 가져오기
|
|
// $entity = $this->service->getEntity($uid);
|
|
// if (!$entity instanceof ServiceEntity) {
|
|
// throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다.");
|
|
// }
|
|
// $this->entity = $this->service->history($entity, $this->service->getFormDatas());
|
|
// $db->transCommit();
|
|
// return $this->getResultSuccess('서비스 비고가 수정되었습니다.');
|
|
// } catch (\Exception $e) {
|
|
// $db->transRollback();
|
|
// return $this->getResultFail($e->getMessage());
|
|
// }
|
|
// }
|
|
}
|