dbmsv4 init...1
This commit is contained in:
parent
13aff6e960
commit
5e47854cbe
@ -4,14 +4,16 @@ namespace Config;
|
||||
|
||||
use App\Services\Auth\GoogleService;
|
||||
use App\Services\Auth\LocalService;
|
||||
use App\Services\CollectorService;
|
||||
use App\Services\Customer\AccountService;
|
||||
use App\Services\Customer\ClientService;
|
||||
use App\Services\Customer\CouponService;
|
||||
use App\Services\Customer\PointService;
|
||||
use App\Services\Equipment\LineService;
|
||||
use App\Services\Equipment\ServerPartService;
|
||||
use App\Services\Equipment\ServerService;
|
||||
use App\Services\MylogService;
|
||||
use App\Services\Part\CPUService;
|
||||
use App\Services\PaymentService;
|
||||
use App\Services\TrafficService;
|
||||
use App\Services\UserService;
|
||||
use CodeIgniter\Config\BaseService;
|
||||
|
||||
@ -147,4 +149,86 @@ class Services extends BaseService
|
||||
new \App\Models\Equipment\LineModel(),
|
||||
);
|
||||
}
|
||||
public static function equipment_serverservice($getShared = true): ServerService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new ServerService(
|
||||
new \App\Models\Equipment\ServerModel(),
|
||||
);
|
||||
}
|
||||
public static function equipment_serverpartservice($getShared = true): ServerPartService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new ServerPartService(
|
||||
new \App\Models\Equipment\ServerPartModel(),
|
||||
);
|
||||
}
|
||||
//Part
|
||||
public static function part_cpuservice($getShared = true): CPUService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new CPUService(
|
||||
new \App\Models\Part\CPUModel(),
|
||||
);
|
||||
}
|
||||
public static function part_ramservice($getShared = true): RAMService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new RAMService(
|
||||
new \App\Models\Part\RAMModel(),
|
||||
);
|
||||
}
|
||||
public static function part_diskservice($getShared = true): DISKService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new DISKService(
|
||||
new \App\Models\Part\DISKModel(),
|
||||
);
|
||||
}
|
||||
public static function part_softwareservice($getShared = true): SOFTWAREService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new SOFTWAREService(
|
||||
new \App\Models\Part\SOFTWAREModel(),
|
||||
);
|
||||
}
|
||||
public static function part_switchservice($getShared = true): SWITCHService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new SWITCHService(
|
||||
new \App\Models\Part\SWITCHModel(),
|
||||
);
|
||||
}
|
||||
public static function part_ipservice($getShared = true): IPervice
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new IPervice(
|
||||
new \App\Models\Part\IPModel(),
|
||||
);
|
||||
}
|
||||
public static function part_csservice($getShared = true): CService
|
||||
{
|
||||
if ($getShared) {
|
||||
return static::getSharedInstance(__FUNCTION__);
|
||||
}
|
||||
return new CService(
|
||||
new \App\Models\Part\CSModel(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ class CouponController extends CustomerController
|
||||
"title",
|
||||
"cnt",
|
||||
"status",
|
||||
"content"
|
||||
"content",
|
||||
];
|
||||
$filters = [
|
||||
"clientinfo_uid",
|
||||
|
||||
@ -22,14 +22,11 @@ class PointController extends CustomerController
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"uid",
|
||||
"user_uid",
|
||||
"clientinfo_uid",
|
||||
"title",
|
||||
"content",
|
||||
"amount",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
$filters = [
|
||||
"clientinfo_uid",
|
||||
|
||||
@ -22,14 +22,11 @@ class LineController extends EquipmentController
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"uid",
|
||||
"type",
|
||||
"title",
|
||||
"bandwith",
|
||||
"start_at",
|
||||
"end_at",
|
||||
"status",
|
||||
"updated_at"
|
||||
];
|
||||
$filters = [
|
||||
"clientinfo_uid",
|
||||
@ -44,13 +41,14 @@ class LineController extends EquipmentController
|
||||
case 'create_form':
|
||||
case 'modify':
|
||||
case 'modify_form':
|
||||
$fields = [...$fields, 'status'];
|
||||
break;
|
||||
case 'view':
|
||||
$fields = [...$fields, 'created_at'];
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = [...$fields, 'created_at'];
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
||||
|
||||
230
app/Controllers/Admin/Equipment/ServerController.php
Normal file
230
app/Controllers/Admin/Equipment/ServerController.php
Normal file
@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ServerController extends EquipmentController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('equipment_serverservice');
|
||||
}
|
||||
}
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"code",
|
||||
"type",
|
||||
"switch",
|
||||
"ip",
|
||||
"os",
|
||||
"title",
|
||||
"price",
|
||||
"manufactur_at",
|
||||
"format_at",
|
||||
];
|
||||
$filters = [
|
||||
"clientinfo_uid",
|
||||
"status",
|
||||
];
|
||||
$batchjobFilters = ['status'];
|
||||
// $actionButtons = ['view' => ICONS['SEARCH']];
|
||||
// $batchjobButtons = [];
|
||||
parent::action_init_process($action);
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
case 'create_form':
|
||||
case 'modify':
|
||||
case 'modify_form':
|
||||
$fields = [...$fields, 'status'];
|
||||
break;
|
||||
case 'view':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
||||
// break;
|
||||
}
|
||||
$this->service->getFormService()->setFormFields($fields);
|
||||
$this->service->getFormService()->setFormRules($action, $fields);
|
||||
$this->service->getFormService()->setFormFilters($filters);
|
||||
$this->service->getFormService()->setFormOptions($filters);
|
||||
$this->service->getFormService()->setBatchjobFilters($batchjobFilters);
|
||||
// $this->service->getFormService()->setActionButtons($actionButtons);
|
||||
// $this->service->getFormService()->setBatchjobButtons($batchjobButtons);
|
||||
parent::action_init_process($action);
|
||||
}
|
||||
|
||||
public function create_form(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->addViewDatas('formDatas', $this->create_form_process());
|
||||
return $this->create_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function create(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->create_process();
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
return $this->create_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify_form($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_form_process($uid);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_process($uid);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function delete($uid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$entity = $this->delete_process($uid);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
return $this->delete_result_process($entity);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function view($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->view_process($uid);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->view_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function batchjob(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
// 사전작업 및 데이터 추출 초기화
|
||||
list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process();
|
||||
$this->service->getFormService()->setFormFields($selectedFields);
|
||||
$this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields);
|
||||
$this->service->getFormService()->setFormFilters($selectedFields);
|
||||
$this->service->getFormService()->setFormOptions($selectedFields);
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_process($uid, $formDatas);
|
||||
} catch (ValidationException $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function batchjob_delete(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$uids = $this->batchjob_delete_pre_process();
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_delete_process($uid);
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_delete_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function index(): string|ResponseInterface
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->index_process($action);
|
||||
$this->index_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
session()->setFlashdata('message', $e->getMessage());
|
||||
}
|
||||
return $this->index_result_process($action);
|
||||
}
|
||||
|
||||
public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
return $this->download_process($action, $output_type, $uid);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
//기본 함수 작업
|
||||
//Custom 추가 함수
|
||||
}
|
||||
231
app/Controllers/Admin/Equipment/ServerPartController.php
Normal file
231
app/Controllers/Admin/Equipment/ServerPartController.php
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin\Equipment;
|
||||
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class ServerPartController extends EquipmentController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('equipment_serverpartservice');
|
||||
}
|
||||
}
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"serverinfo_uid",
|
||||
"type",
|
||||
"billing",
|
||||
"part_uid",
|
||||
"title",
|
||||
"cnt",
|
||||
"extra",
|
||||
"amount",
|
||||
];
|
||||
$filters = [
|
||||
"serverinfo_uid",
|
||||
"type",
|
||||
"part_uid",
|
||||
"billing",
|
||||
];
|
||||
$batchjobFilters = ['billing', 'type'];
|
||||
// $actionButtons = ['view' => ICONS['SEARCH']];
|
||||
// $batchjobButtons = [];
|
||||
parent::action_init_process($action);
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
case 'create_form':
|
||||
case 'modify':
|
||||
case 'modify_form':
|
||||
$fields = [...$fields, 'status'];
|
||||
break;
|
||||
case 'view':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
||||
// break;
|
||||
}
|
||||
$this->service->getFormService()->setFormFields($fields);
|
||||
$this->service->getFormService()->setFormRules($action, $fields);
|
||||
$this->service->getFormService()->setFormFilters($filters);
|
||||
$this->service->getFormService()->setFormOptions($filters);
|
||||
$this->service->getFormService()->setBatchjobFilters($batchjobFilters);
|
||||
// $this->service->getFormService()->setActionButtons($actionButtons);
|
||||
// $this->service->getFormService()->setBatchjobButtons($batchjobButtons);
|
||||
parent::action_init_process($action);
|
||||
}
|
||||
|
||||
public function create_form(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->addViewDatas('formDatas', $this->create_form_process());
|
||||
return $this->create_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function create(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->create_process();
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
return $this->create_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify_form($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_form_process($uid);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_process($uid);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function delete($uid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$entity = $this->delete_process($uid);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
return $this->delete_result_process($entity);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function view($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->view_process($uid);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->view_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function batchjob(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
// 사전작업 및 데이터 추출 초기화
|
||||
list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process();
|
||||
$this->service->getFormService()->setFormFields($selectedFields);
|
||||
$this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields);
|
||||
$this->service->getFormService()->setFormFilters($selectedFields);
|
||||
$this->service->getFormService()->setFormOptions($selectedFields);
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_process($uid, $formDatas);
|
||||
} catch (ValidationException $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function batchjob_delete(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$uids = $this->batchjob_delete_pre_process();
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_delete_process($uid);
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_delete_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function index(): string|ResponseInterface
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->index_process($action);
|
||||
$this->index_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
session()->setFlashdata('message', $e->getMessage());
|
||||
}
|
||||
return $this->index_result_process($action);
|
||||
}
|
||||
|
||||
public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
return $this->download_process($action, $output_type, $uid);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
//기본 함수 작업
|
||||
//Custom 추가 함수
|
||||
}
|
||||
@ -32,11 +32,11 @@ class MylogController extends AdminController
|
||||
case 'modify_form':
|
||||
break;
|
||||
case 'view':
|
||||
$fields = [...$fields, 'created_at'];
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = [...$fields, 'created_at'];
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
||||
|
||||
223
app/Controllers/Admin/Part/CPUController.php
Normal file
223
app/Controllers/Admin/Part/CPUController.php
Normal file
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin\Part;
|
||||
|
||||
use App\Entities\Part\CPUEntity;
|
||||
use CodeIgniter\HTTP\DownloadResponse;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\Validation\Exceptions\ValidationException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class CPUController extends PartController
|
||||
{
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
if ($this->service === null) {
|
||||
$this->service = service('part_cpuservice');
|
||||
}
|
||||
}
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"title",
|
||||
"price",
|
||||
"stock",
|
||||
];
|
||||
$filters = [
|
||||
"status",
|
||||
];
|
||||
$batchjobFilters = ['status'];
|
||||
// $actionButtons = ['view' => ICONS['SEARCH']];
|
||||
// $batchjobButtons = [];
|
||||
parent::action_init_process($action);
|
||||
switch ($action) {
|
||||
case 'create':
|
||||
case 'create_form':
|
||||
case 'modify':
|
||||
case 'modify_form':
|
||||
$fields = [...$fields, 'status'];
|
||||
break;
|
||||
case 'view':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
case 'index':
|
||||
case 'download':
|
||||
$fields = [...$fields, 'status', 'created_at'];
|
||||
break;
|
||||
default:
|
||||
throw new \Exception("[{$action}] 지원하지 않는 action입니다.");
|
||||
// break;
|
||||
}
|
||||
$this->service->getFormService()->setFormFields($fields);
|
||||
$this->service->getFormService()->setFormRules($action, $fields);
|
||||
$this->service->getFormService()->setFormFilters($filters);
|
||||
$this->service->getFormService()->setFormOptions($filters);
|
||||
$this->service->getFormService()->setBatchjobFilters($batchjobFilters);
|
||||
// $this->service->getFormService()->setActionButtons($actionButtons);
|
||||
// $this->service->getFormService()->setBatchjobButtons($batchjobButtons);
|
||||
parent::action_init_process($action);
|
||||
}
|
||||
|
||||
public function create_form(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->addViewDatas('formDatas', $this->create_form_process());
|
||||
return $this->create_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function create(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->create_process();
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
return $this->create_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 생성 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify_form($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_form_process($uid);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_form_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정폼 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function modify($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->modify_process($uid);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->modify_result_process($entity);
|
||||
} catch (ValidationException $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function delete($uid): RedirectResponse
|
||||
{
|
||||
try {
|
||||
$entity = $this->delete_process($uid);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
return $this->delete_result_process($entity);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function view($uid): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$entity = $this->view_process($uid);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
$this->addViewDatas('entity', $entity);
|
||||
return $this->view_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 {$uid} 상세보기 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
public function batchjob(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
// 사전작업 및 데이터 추출 초기화
|
||||
list($uids, $selectedFields, $formDatas) = $this->batchjob_pre_process();
|
||||
$this->service->getFormService()->setFormFields($selectedFields);
|
||||
$this->service->getFormService()->setFormRules(__FUNCTION__, $selectedFields);
|
||||
$this->service->getFormService()->setFormFilters($selectedFields);
|
||||
$this->service->getFormService()->setFormOptions($selectedFields);
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_process($uid, $formDatas);
|
||||
} catch (ValidationException $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 검증오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 수정 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄작업처리 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function batchjob_delete(): string|RedirectResponse
|
||||
{
|
||||
try {
|
||||
$uids = $this->batchjob_delete_pre_process();
|
||||
$entities = [];
|
||||
$errors = [];
|
||||
foreach ($uids as $uid) {
|
||||
try {
|
||||
$entities[] = $this->batchjob_delete_process($uid);
|
||||
} catch (\Exception $e) {
|
||||
log_message('error', "{$this->getTitle()}에서 {$uid} 삭제 오류:" . $e->getMessage());
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
return $this->batchjob_delete_result_process($uids, $entities, $errors);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 일괄삭제 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function index(): string|ResponseInterface
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
$this->index_process($action);
|
||||
$this->index_result_process($action);
|
||||
} catch (\Exception $e) {
|
||||
session()->setFlashdata('message', $e->getMessage());
|
||||
}
|
||||
return $this->index_result_process($action);
|
||||
}
|
||||
|
||||
public function download(string $output_type, mixed $uid = false): DownloadResponse|RedirectResponse|string
|
||||
{
|
||||
try {
|
||||
$action = __FUNCTION__;
|
||||
$this->action_init_process($action);
|
||||
return $this->download_process($action, $output_type, $uid);
|
||||
} catch (\Exception $e) {
|
||||
return $this->action_redirect_process('error', "{$this->getTitle()}에서 오류:" . $e->getMessage());
|
||||
}
|
||||
}
|
||||
//기본 함수 작업
|
||||
//Custom 추가 함수
|
||||
}
|
||||
20
app/Controllers/Admin/Part/PartController.php
Normal file
20
app/Controllers/Admin/Part/PartController.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin\Part;
|
||||
|
||||
use App\Controllers\Admin\AdminController;
|
||||
use CodeIgniter\HTTP\RequestInterface;
|
||||
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
abstract class PartController extends AdminController
|
||||
{
|
||||
public const PATH = 'part';
|
||||
public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
|
||||
{
|
||||
parent::initController($request, $response, $logger);
|
||||
$this->addActionPaths(self::PATH);
|
||||
}
|
||||
//Index,FieldForm관련
|
||||
}
|
||||
@ -23,8 +23,6 @@ class PaymentController extends AdminController
|
||||
protected function action_init_process(string $action): void
|
||||
{
|
||||
$fields = [
|
||||
"uid",
|
||||
"user_uid",
|
||||
"clientinfo_uid",
|
||||
"serviceinfo_uid",
|
||||
"serverpartinfo_uid",
|
||||
|
||||
26
app/DTOs/Equipment/LineDTO.php
Normal file
26
app/DTOs/Equipment/LineDTO.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class LineDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?string $title = null;
|
||||
public ?string $bandwith = null;
|
||||
public ?string $start_at = null;
|
||||
public ?string $end_at = null;
|
||||
public ?string $status = null;
|
||||
public ?string $content = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct();
|
||||
foreach ($datas as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
app/DTOs/Equipment/ServerDTO.php
Normal file
29
app/DTOs/Equipment/ServerDTO.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ServerDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?string $code = null;
|
||||
public ?string $type = null;
|
||||
public ?string $switch = null;
|
||||
public ?string $ip = null;
|
||||
public ?string $os = null;
|
||||
public ?string $title = null;
|
||||
public ?int $price = null;
|
||||
public ?string $manufactur_at = null;
|
||||
public ?string $format_at = null;
|
||||
public ?string $status = null;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct();
|
||||
foreach ($datas as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
app/DTOs/Equipment/ServerPartDTO.php
Normal file
27
app/DTOs/Equipment/ServerPartDTO.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Equipment;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class ServerPartDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?string $serverinfo_uid = null;
|
||||
public ?string $type = null;
|
||||
public ?string $billing = null;
|
||||
public ?int $part_uid = null;
|
||||
public ?string $title = null;
|
||||
public ?int $cnt = null;
|
||||
public ?string $extra = null;
|
||||
public ?string $amount = null;
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct();
|
||||
foreach ($datas as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
app/DTOs/Part/CPUDTO.php
Normal file
25
app/DTOs/Part/CPUDTO.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\DTOs\Part;
|
||||
|
||||
use App\DTOs\CommonDTO;
|
||||
|
||||
class CPUDTO extends CommonDTO
|
||||
{
|
||||
public ?int $uid = null;
|
||||
public ?string $title = null;
|
||||
public ?int $price = null;
|
||||
public ?string $used = null;
|
||||
public ?int $string = null;
|
||||
public ?string $status = null;
|
||||
|
||||
public function __construct(array $datas = [])
|
||||
{
|
||||
parent::__construct();
|
||||
foreach ($datas as $key => $value) {
|
||||
if (property_exists($this, $key)) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -133,6 +133,7 @@ abstract class CommonForm
|
||||
}
|
||||
return $label;
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
@ -152,6 +153,14 @@ abstract class CommonForm
|
||||
$rule = "required|regex_match[/^[a-zA-Z0-9가-힣\-]+$/]|min_length[4]|max_length[20]";
|
||||
$rule .= in_array($action, ["create"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "user_uid":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case 'picture':
|
||||
$rule = "is_image[{$field}]|mime_in[{$field},image/jpg,image/jpeg,image/gif,image/png,image/webp]|max_size[{$field},300]|max_dims[{$field},2048,768]";
|
||||
break;
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Forms\Customer;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class AccountForm extends CommonForm
|
||||
class AccountForm extends CustomerForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Forms\Customer;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class ClientForm extends CommonForm
|
||||
class ClientForm extends CustomerForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Forms\Customer;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class CouponForm extends CommonForm
|
||||
class CouponForm extends CustomerForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
36
app/Forms/Customer/CustomerForm.php
Normal file
36
app/Forms/Customer/CustomerForm.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Customer;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
abstract class CustomerForm extends CommonForm
|
||||
{
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "user_uid":
|
||||
case "clientinfo_uid":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "price":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "status":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Forms\Customer;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class PointForm extends CommonForm
|
||||
class PointForm extends CustomerForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
38
app/Forms/Equipment/EquipmentForm.php
Normal file
38
app/Forms/Equipment/EquipmentForm.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Equipment;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
abstract class EquipmentForm extends CommonForm
|
||||
{
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "user_uid":
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "price":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "status":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
28
app/Forms/Equipment/LineForm.php
Normal file
28
app/Forms/Equipment/LineForm.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Equipment;
|
||||
|
||||
class LineForm extends EquipmentForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "bandwith":
|
||||
case "type":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "start_at":
|
||||
case "end_at":
|
||||
$rule = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
48
app/Forms/Equipment/ServerForm.php
Normal file
48
app/Forms/Equipment/ServerForm.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Equipment;
|
||||
|
||||
class ServerForm extends EquipmentForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "code":
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "price":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "type":
|
||||
case "status":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "manufactur_at":
|
||||
$rule = "required|valid_date";
|
||||
break;
|
||||
case "switch":
|
||||
$rule = "permit_empty|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "ip":
|
||||
$rule = "permit_empty|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "os":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
case "format_at":
|
||||
$rule = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
39
app/Forms/Equipment/ServerPartForm.php
Normal file
39
app/Forms/Equipment/ServerPartForm.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Equipment;
|
||||
|
||||
class ServerPartForm extends EquipmentForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "serverinfo_uid":
|
||||
case "part_uid":
|
||||
case "cnt":
|
||||
case "amount":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "payment_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "title":
|
||||
case "type":
|
||||
case "billing":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "extra":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
22
app/Forms/Part/CPUForm.php
Normal file
22
app/Forms/Part/CPUForm.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Part;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
class CPUForm extends PartForm
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
38
app/Forms/Part/PartForm.php
Normal file
38
app/Forms/Part/PartForm.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Forms\Part;
|
||||
|
||||
use App\Forms\CommonForm;
|
||||
|
||||
abstract class PartForm extends CommonForm
|
||||
{
|
||||
protected function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
switch ($field) {
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->getAttribute('table')}.{$field}]" : "";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
case "price":
|
||||
case "stock":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "status":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
13
app/Helpers/Equipment/LineHelper.php
Normal file
13
app/Helpers/Equipment/LineHelper.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\Equipment;
|
||||
|
||||
use App\Helpers\CommonHelper;
|
||||
|
||||
class LineHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
107
app/Helpers/Equipment/ServerHelper.php
Normal file
107
app/Helpers/Equipment/ServerHelper.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\Equipment;
|
||||
|
||||
use App\Helpers\CommonHelper;
|
||||
|
||||
class ServerHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'clientinfo_uid':
|
||||
case 'serviceinfo_uid':
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
if (in_array($viewDatas['control']['action'], ['modify_form']) && $value) {
|
||||
$form = $this->getFieldView($field, $value, $viewDatas, $extras);
|
||||
$form .= form_hidden($field, (string)$value);
|
||||
}
|
||||
break;
|
||||
case 'ip': //값 그대료 표시
|
||||
$form = "<div class=\"ac-wrap\" style=\"position:relative;\">";
|
||||
$form .= form_input($field, $value ?? "", [
|
||||
'id' => 'ipInput',
|
||||
"list" => "ipList",
|
||||
"placeholder" => "예: 27.125.207.100",
|
||||
"autocomplete" => "off",
|
||||
...$extras
|
||||
]);
|
||||
$form .= "<div id=\"ipPanel\" class=\"ac-panel\" hidden></div>";
|
||||
$form .= "</div>";
|
||||
break;
|
||||
case 'switch': //값 그대료 표시
|
||||
$form = "<div class=\"ac-wrap\" style=\"position:relative;\">";
|
||||
$form .= form_input($field, $value ?? "", [
|
||||
'id' => 'switchInput',
|
||||
"placeholder" => "Switch 코드 입력",
|
||||
"autocomplete" => "off",
|
||||
...$extras
|
||||
]);
|
||||
$form .= "<div id=\"switchPanel\" class=\"ac-panel\" hidden></div>";
|
||||
$form .= "</div>";
|
||||
break;
|
||||
case 'manufactur_at':
|
||||
case 'format_at':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender';
|
||||
$form = form_input($field, $value ?? "", $extras);
|
||||
break;
|
||||
default:
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
{
|
||||
switch ($field) {
|
||||
case 'ip': //값 그대료 표시
|
||||
break;
|
||||
case 'title':
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
case 'price':
|
||||
$value = number_format($value);
|
||||
break;
|
||||
case 'manufactur_at':
|
||||
case 'format_at':
|
||||
$value = $value ? date("Y-m-d", strtotime($value)) : "";
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($action) {
|
||||
case 'modify':
|
||||
$action = parent::getListButton($action, $viewDatas['entity']->getCode(), $viewDatas, $extras);
|
||||
break;
|
||||
case 'history':
|
||||
$action = $label ? $label : form_label(
|
||||
$label ? $label : ICONS['HISTORY'],
|
||||
$action,
|
||||
[
|
||||
"data-src" => "/admin/customer/clienthistory?clientinfo_uid={$viewDatas['entity']->getPK()}",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm btn-primary form-label-sm",
|
||||
...$extras
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
119
app/Helpers/Equipment/ServerPartHelper.php
Normal file
119
app/Helpers/Equipment/ServerPartHelper.php
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\Equipment;
|
||||
|
||||
use App\Helpers\CommonHelper;
|
||||
|
||||
class ServerPartHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($field) {
|
||||
case 'part_uid':
|
||||
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
|
||||
$extras['onChange'] = "document.querySelector('input[name=\'title\']').value = this.options[this.selectedIndex].getAttribute('data-title'); document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
|
||||
$attributes = ['data-title' => 'title', 'data-price' => 'price'];
|
||||
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
|
||||
break;
|
||||
case 'extra':
|
||||
if (array_key_exists('type', $viewDatas['control']['form_datas']) && $viewDatas['control']['form_datas']['type'] === 'DISK') {
|
||||
$options = ["" => lang("{$viewDatas['class_path']}.label.{$field}") . " 선택", ...lang("{$viewDatas['class_path']}.EXTRA.{$viewDatas['control']['form_datas']['type']}")];
|
||||
$form = form_dropdown($field, $options, $value, $extras);
|
||||
} else {
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$form = parent::getFieldForm($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
||||
{
|
||||
switch ($field) {
|
||||
case 'SERVER':
|
||||
$value = form_label(
|
||||
sprintf(
|
||||
"[%s] %s",
|
||||
lang("Equipment/ServerPart.TYPE")[$viewDatas['serverEntity']->getType()],
|
||||
$viewDatas['serverEntity']->getCode(),
|
||||
),
|
||||
$field,
|
||||
[
|
||||
"data-src" => "/admin/equipment/server/modify/{$viewDatas['serverEntity']->getPK()}?ActionTemplate=server",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm form-label-sm text-primary",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'SOFTWARE':
|
||||
case 'IP':
|
||||
case 'CS':
|
||||
//파트 Entity
|
||||
$title = $viewDatas['entity']->getTitle();
|
||||
$title .= $viewDatas['entity']->getCnt() > 1 ? "*" . $viewDatas['entity']->getCnt() . "개" : "";
|
||||
$title .= $viewDatas['entity']->getExtra() ? "[" . $viewDatas['entity']->getExtra() . "]" : "";
|
||||
if (array_key_exists('return', $extras) && $extras['return'] == 'onlyText') {
|
||||
$value = $title;
|
||||
} else {
|
||||
$billing = $viewDatas['entity']->getBilling() === "" ? "" : ($viewDatas['entity']->getBilling() === PAYMENT['BILLING']["ONETIME"] ? ICONS['ONETIME'] : ($viewDatas['entity']->getBilling() === PAYMENT['BILLING']["MONTH"] ? ICONS['MONTH'] : ""));
|
||||
$value = form_label(
|
||||
$billing . $title,
|
||||
$field,
|
||||
[
|
||||
"data-src" => "/admin/equipment/serverpart/modify/{$viewDatas['entity']->getPK()}?type={$viewDatas['entity']->getType()}&ActionTemplate=popup",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm form-label-sm text-primary",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다");
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
|
||||
{
|
||||
switch ($action) {
|
||||
case 'IP':
|
||||
case 'CS':
|
||||
case 'CPU':
|
||||
case 'RAM':
|
||||
case 'DISK':
|
||||
case 'SOFTWARE':
|
||||
$action = form_label(
|
||||
$label ? $label : ICONS["SERVER_ITEM_{$action}"],
|
||||
$action,
|
||||
[
|
||||
"data-src" => "/admin/equipment/serverpart/create?serverinfo_uid={$viewDatas['serverinfo_uid']}&type={$action}&ActionTemplate=popup",
|
||||
"data-bs-toggle" => "modal",
|
||||
"data-bs-target" => "#modal_action_form",
|
||||
"class" => "btn btn-sm form-label-sm text-primary",
|
||||
...$extras,
|
||||
]
|
||||
);
|
||||
break;
|
||||
default:
|
||||
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
||||
break;
|
||||
}
|
||||
return $action;
|
||||
}
|
||||
}
|
||||
13
app/Helpers/Part/CPUHelper.php
Normal file
13
app/Helpers/Part/CPUHelper.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helpers\Part;
|
||||
|
||||
use App\Helpers\CommonHelper;
|
||||
|
||||
class CPUHelper extends CommonHelper
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'label' => [
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'used' => "사용",
|
||||
'used' => "사용갯수",
|
||||
'stock' => "재고",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'label' => [
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'used' => "사용",
|
||||
'used' => "사용갯수",
|
||||
'stock' => "재고",
|
||||
'format' => "포맷",
|
||||
'status' => "상태",
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'label' => [
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'used' => "사용",
|
||||
'used' => "사용갯수",
|
||||
'stock' => "재고",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
|
||||
@ -4,7 +4,7 @@ return [
|
||||
'label' => [
|
||||
'title' => "모델명",
|
||||
'price' => "기본가",
|
||||
'used' => "사용",
|
||||
'used' => "사용갯수",
|
||||
'stock' => "재고",
|
||||
'status' => "상태",
|
||||
'updated_at' => "수정일",
|
||||
|
||||
@ -13,32 +13,4 @@ abstract class CustomerModel extends CommonModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "user_uid":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|trim|numeric";
|
||||
break;
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : "";
|
||||
break;
|
||||
case "status":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,32 +10,4 @@ abstract class EquipmentModel extends CommonModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[" . $this->getTable() . "." . $field . "]" : "";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "serverinfo_uid":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
case "price":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "status":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,24 +26,4 @@ class LineModel extends EquipmentModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "bandwith":
|
||||
case "type":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "start_at":
|
||||
case "end_at":
|
||||
$rule = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,67 +34,4 @@ class ServerModel extends EquipmentModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "user_uid":
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "code":
|
||||
case "title":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "price":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "type":
|
||||
case "status":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "manufactur_at":
|
||||
$rule = "required|valid_date";
|
||||
break;
|
||||
case "switch":
|
||||
$rule = "permit_empty|trim|string";
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "ip":
|
||||
$rule = "permit_empty|trim|valid_ip[both]"; //ipv4 , ipv6 , both(ipv4,ipv6)
|
||||
$rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
|
||||
break;
|
||||
case "os":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
case "format_at":
|
||||
$rule = "permit_empty|valid_date";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
protected function convertFormDatas(string $action, string $field, array $formDatas): mixed
|
||||
{
|
||||
// 필드 값 존재 여부 확인
|
||||
$value = array_key_exists($field, $formDatas) ? $formDatas[$field] : null;
|
||||
switch ($field) {
|
||||
case 'clientinfo_uid':
|
||||
case 'serviceinfo_uid':
|
||||
if ($value === '') {
|
||||
$value = null;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$value = parent::convertFormDatas($action, $field, $formDatas);
|
||||
break;
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
//기본기능
|
||||
}
|
||||
|
||||
@ -31,35 +31,4 @@ class ServerPartModel extends EquipmentModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
final public function getFormRule(string $action, string $field): string
|
||||
{
|
||||
if (is_array($field)) {
|
||||
throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true));
|
||||
}
|
||||
switch ($field) {
|
||||
case "serverinfo_uid":
|
||||
case "part_uid":
|
||||
case "cnt":
|
||||
case "amount":
|
||||
$rule = "required|numeric";
|
||||
break;
|
||||
case "clientinfo_uid":
|
||||
case "serviceinfo_uid":
|
||||
case "payment_uid":
|
||||
$rule = "permit_empty|numeric";
|
||||
break;
|
||||
case "title":
|
||||
case "type":
|
||||
case "billing":
|
||||
$rule = "required|trim|string";
|
||||
break;
|
||||
case "extra":
|
||||
$rule = "permit_empty|trim|string";
|
||||
break;
|
||||
default:
|
||||
$rule = parent::getFormRule($action, $field);
|
||||
break;
|
||||
}
|
||||
return $rule;
|
||||
}
|
||||
}
|
||||
|
||||
15
app/Services/Equipment/EquipmentService.php
Normal file
15
app/Services/Equipment/EquipmentService.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\Models\CommonModel;
|
||||
use App\Services\CommonService;
|
||||
|
||||
abstract class EquipmentService extends CommonService
|
||||
{
|
||||
protected function __construct(CommonModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Equipment');
|
||||
}
|
||||
}
|
||||
95
app/Services/Equipment/LineService.php
Normal file
95
app/Services/Equipment/LineService.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\LineDTO;
|
||||
use App\Entities\Equipment\LineEntity;
|
||||
use App\Forms\Equipment\LineForm;
|
||||
use App\Helpers\Equipment\LineHelper;
|
||||
use App\Models\Equipment\LineModel;
|
||||
use RuntimeException;
|
||||
|
||||
class LineService extends EquipmentService
|
||||
{
|
||||
private $_form = null;
|
||||
private $_helper = null;
|
||||
public function __construct(LineModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Line');
|
||||
}
|
||||
public function createDTO(array $formDatas): LineDTO
|
||||
{
|
||||
return new LineDTO($formDatas);
|
||||
}
|
||||
public function getFormService(): LineForm
|
||||
{
|
||||
if ($this->_form === null) {
|
||||
$this->_form = new LineForm();
|
||||
$this->_form->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_form;
|
||||
}
|
||||
public function getHelper(): LineHelper
|
||||
{
|
||||
if ($this->_helper === null) {
|
||||
$this->_helper = new LineHelper();
|
||||
$this->_helper->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): LineEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): LineEntity
|
||||
{
|
||||
return new LineEntity($formDatas);
|
||||
}
|
||||
public function create(object $dto): LineEntity
|
||||
{
|
||||
if (!$dto instanceof LineDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::create($dto);
|
||||
if (!$entity instanceof LineEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($uid, array $formDatas): LineEntity
|
||||
{
|
||||
$entity = parent::modify_process($uid, $formDatas);
|
||||
if (!$entity instanceof LineEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function modify($uid, object $dto): LineEntity
|
||||
{
|
||||
if (!$dto instanceof LineDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::modify($uid, $dto);
|
||||
if (!$entity instanceof LineEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 LineEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
}
|
||||
95
app/Services/Equipment/ServerPartService.php
Normal file
95
app/Services/Equipment/ServerPartService.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\ServerPartDTO;
|
||||
use App\Entities\Equipment\ServerPartEntity;
|
||||
use App\Forms\Equipment\ServerPartForm;
|
||||
use App\Helpers\Equipment\ServerPartHelper;
|
||||
use App\Models\Equipment\ServerPartModel;
|
||||
use RuntimeException;
|
||||
|
||||
class ServerPartService extends EquipmentService
|
||||
{
|
||||
private $_form = null;
|
||||
private $_helper = null;
|
||||
public function __construct(ServerPartModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('ServerPart');
|
||||
}
|
||||
public function createDTO(array $formDatas): ServerPartDTO
|
||||
{
|
||||
return new ServerPartDTO($formDatas);
|
||||
}
|
||||
public function getFormService(): ServerPartForm
|
||||
{
|
||||
if ($this->_form === null) {
|
||||
$this->_form = new ServerPartForm();
|
||||
$this->_form->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_form;
|
||||
}
|
||||
public function getHelper(): ServerPartHelper
|
||||
{
|
||||
if ($this->_helper === null) {
|
||||
$this->_helper = new ServerPartHelper();
|
||||
$this->_helper->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): ServerPartEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): ServerPartEntity
|
||||
{
|
||||
return new ServerPartEntity($formDatas);
|
||||
}
|
||||
public function create(object $dto): ServerPartEntity
|
||||
{
|
||||
if (!$dto instanceof ServerPartDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::create($dto);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($uid, array $formDatas): ServerPartEntity
|
||||
{
|
||||
$entity = parent::modify_process($uid, $formDatas);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function modify($uid, object $dto): ServerPartEntity
|
||||
{
|
||||
if (!$dto instanceof ServerPartDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::modify($uid, $dto);
|
||||
if (!$entity instanceof ServerPartEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerPartEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
}
|
||||
95
app/Services/Equipment/ServerService.php
Normal file
95
app/Services/Equipment/ServerService.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Equipment;
|
||||
|
||||
use App\DTOs\Equipment\ServerDTO;
|
||||
use App\Entities\Equipment\ServerEntity;
|
||||
use App\Forms\Equipment\ServerForm;
|
||||
use App\Helpers\Equipment\ServerHelper;
|
||||
use App\Models\Equipment\ServerModel;
|
||||
use RuntimeException;
|
||||
|
||||
class ServerService extends EquipmentService
|
||||
{
|
||||
private $_form = null;
|
||||
private $_helper = null;
|
||||
public function __construct(ServerModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Server');
|
||||
}
|
||||
public function createDTO(array $formDatas): ServerDTO
|
||||
{
|
||||
return new ServerDTO($formDatas);
|
||||
}
|
||||
public function getFormService(): ServerForm
|
||||
{
|
||||
if ($this->_form === null) {
|
||||
$this->_form = new ServerForm();
|
||||
$this->_form->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_form;
|
||||
}
|
||||
public function getHelper(): ServerHelper
|
||||
{
|
||||
if ($this->_helper === null) {
|
||||
$this->_helper = new ServerHelper();
|
||||
$this->_helper->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): ServerEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): ServerEntity
|
||||
{
|
||||
return new ServerEntity($formDatas);
|
||||
}
|
||||
public function create(object $dto): ServerEntity
|
||||
{
|
||||
if (!$dto instanceof ServerDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::create($dto);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($uid, array $formDatas): ServerEntity
|
||||
{
|
||||
$entity = parent::modify_process($uid, $formDatas);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function modify($uid, object $dto): ServerEntity
|
||||
{
|
||||
if (!$dto instanceof ServerDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::modify($uid, $dto);
|
||||
if (!$entity instanceof ServerEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 ServerEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
}
|
||||
95
app/Services/Part/CPUService.php
Normal file
95
app/Services/Part/CPUService.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Part;
|
||||
|
||||
use App\DTOs\Part\CPUDTO;
|
||||
use App\Entities\Part\CPUEntity;
|
||||
use App\Forms\Part\CPUForm;
|
||||
use App\Helpers\Part\CPUHelper;
|
||||
use App\Models\Part\CPUModel;
|
||||
use RuntimeException;
|
||||
|
||||
class CPUService extends PartService
|
||||
{
|
||||
private $_form = null;
|
||||
private $_helper = null;
|
||||
public function __construct(CPUModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('CPU');
|
||||
}
|
||||
public function createDTO(array $formDatas): CPUDTO
|
||||
{
|
||||
return new CPUDTO($formDatas);
|
||||
}
|
||||
public function getFormService(): CPUForm
|
||||
{
|
||||
if ($this->_form === null) {
|
||||
$this->_form = new CPUForm();
|
||||
$this->_form->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_form;
|
||||
}
|
||||
public function getHelper(): CPUHelper
|
||||
{
|
||||
if ($this->_helper === null) {
|
||||
$this->_helper = new CPUHelper();
|
||||
$this->_helper->setAttributes([
|
||||
'pk_field' => $this->model->getPKField(),
|
||||
'title_field' => $this->model->getTitleField(),
|
||||
'table' => $this->model->getTable(),
|
||||
'useAutoIncrement' => $this->model->useAutoIncrement(),
|
||||
'class_path' => $this->getClassPaths(false)
|
||||
]);
|
||||
}
|
||||
return $this->_helper;
|
||||
}
|
||||
//기본 기능부분
|
||||
protected function getEntity_process(mixed $entity): CPUEntity
|
||||
{
|
||||
return $entity;
|
||||
}
|
||||
protected function create_process(array $formDatas): CPUEntity
|
||||
{
|
||||
return new CPUEntity($formDatas);
|
||||
}
|
||||
public function create(object $dto): CPUEntity
|
||||
{
|
||||
if (!$dto instanceof CPUDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::create($dto);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
protected function modify_process($uid, array $formDatas): CPUEntity
|
||||
{
|
||||
$entity = parent::modify_process($uid, $formDatas);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
public function modify($uid, object $dto): CPUEntity
|
||||
{
|
||||
if (!$dto instanceof CPUDTO) {
|
||||
throw new RuntimeException(__METHOD__ . "에서 오류발생:" . get_class($dto) . "는 사용할수 없습니다.");
|
||||
}
|
||||
$entity = parent::modify($uid, $dto);
|
||||
if (!$entity instanceof CPUEntity) {
|
||||
throw new \RuntimeException(__METHOD__ . "에서 오류발생:Return Type은 CPUEntity만 가능");
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
//List 검색용
|
||||
//FormFilter 조건절 처리
|
||||
//검색어조건절처리
|
||||
}
|
||||
15
app/Services/Part/PartService.php
Normal file
15
app/Services/Part/PartService.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Part;
|
||||
|
||||
use App\Models\CommonModel;
|
||||
use App\Services\CommonService;
|
||||
|
||||
abstract class PartService extends CommonService
|
||||
{
|
||||
protected function __construct(CommonModel $model)
|
||||
{
|
||||
parent::__construct($model);
|
||||
$this->addClassPaths('Part');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user