diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 95adb24..9a3b1af 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -16,7 +16,7 @@ $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) $routes->cli('collect', 'Collector::execute'); }); $routes->group('', ['namespace' => 'App\Controllers'], function ($routes) { - $routes->get('/', 'Home::welcome'); + $routes->get('/', 'Home::index'); $routes->group('auth', ['namespace' => 'App\Controllers\Auth'], function ($routes) { $routes->get('login', 'LocalController::login_form'); $routes->post('login', 'LocalController::login'); @@ -26,7 +26,7 @@ $routes->group('', ['namespace' => 'App\Controllers'], function ($routes) { }); //Admin 관련 $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'authFilter:manager'], function ($routes) { - $routes->get('/', 'Home::welcome'); + $routes->get('/', 'Home::index'); $routes->group('user', function ($routes) { $routes->get('/', 'UserController::index'); $routes->get('create', 'UserController::create_form'); @@ -244,6 +244,19 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->post('batchjob_delete', 'CSController::batchjob_delete'); $routes->get('download/(:alpha)', 'CSController::download/$1'); }); + $routes->group('chassis', function ($routes) { + $routes->get('/', 'CHASSISController::index'); + $routes->get('create', 'CHASSISController::create_form'); + $routes->post('create', 'CHASSISController::create'); + $routes->get('modify/(:num)', 'CHASSISController::modify_form/$1'); + $routes->post('modify/(:num)', 'CHASSISController::modify/$1'); + $routes->get('view/(:num)', 'CHASSISController::view/$1'); + $routes->get('delete/(:num)', 'CHASSISController::delete/$1'); + $routes->get('toggle/(:num)/(:any)', 'CHASSISController::toggle/$1/$2'); + $routes->post('batchjob', 'CHASSISController::batchjob'); + $routes->post('batchjob_delete', 'CHASSISController::batchjob_delete'); + $routes->get('download/(:alpha)', 'CHASSISController::download/$1'); + }); $routes->group('cpu', function ($routes) { $routes->get('/', 'CPUController::index'); $routes->get('create', 'CPUController::create_form'); diff --git a/app/Config/Services.php b/app/Config/Services.php index b460725..ebb3cf5 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -14,6 +14,7 @@ use App\Services\Equipment\LineService; use App\Services\Equipment\ServerPartService; use App\Services\Equipment\ServerService; use App\Services\MylogService; +use App\Services\Part\CHASSISService; use App\Services\Part\CPUService; use App\Services\Part\CSService; use App\Services\Part\DISKService; @@ -194,6 +195,15 @@ class Services extends BaseService ); } //Part + public static function part_chassisservice($getShared = true): CHASSISService + { + if ($getShared) { + return static::getSharedInstance(__FUNCTION__); + } + return new CHASSISService( + new \App\Models\Part\CHASSISModel(), + ); + } public static function part_cpuservice($getShared = true): CPUService { if ($getShared) { diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index a914cf1..901f940 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -9,22 +9,30 @@ use Psr\Log\LoggerInterface; class Home extends AbstractWebController { + private $_layout = 'admin'; + protected $layouts = []; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); if ($this->service === null) { $this->service = service('customer_serviceservice'); } - $this->addActionPaths('home'); + $this->addActionPaths($this->_layout); + $this->layouts = LAYOUTS[$this->_layout]; } protected function action_init_process(string $action, array $formDatas = []): void { - // $this->service->action_init_process($action, $entity); + $this->service->action_init_process($action, $formDatas); parent::action_init_process($action, $formDatas); - $this->addViewDatas('layout', LAYOUTS['admin']); + $this->addViewDatas('layout', $this->layouts); + $this->addViewDatas('helper', $this->service->getHelper()); + $this->addViewDatas('formFields', $this->service->getFormService()->getFormFields()); + $this->addViewDatas('formRules', $this->service->getFormService()->getFormRules()); + $this->addViewDatas('formFilters', $this->service->getFormService()->getFormFilters()); + $this->addViewDatas('formOptions', $this->service->getFormService()->getFormOptions()); } //Index,FieldForm관련 - public function welcome(): string + public function index(): string { $action = __FUNCTION__; $this->action_init_process($action); @@ -45,6 +53,6 @@ class Home extends AbstractWebController } $this->addViewDatas('unPaidTotalCount', $unPaidTotalCount); $this->addViewDatas('unPaidTotalAmount', $unPaidTotalAmount); - return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate')); + return $this->action_render_process($action, $this->getViewDatas(), $this->request->getVar('ActionTemplate') ?? "welcome"); } } diff --git a/app/Controllers/Admin/Part/CHASSISController b/app/Controllers/Admin/Part/CHASSISController new file mode 100644 index 0000000..b2703a9 --- /dev/null +++ b/app/Controllers/Admin/Part/CHASSISController @@ -0,0 +1,22 @@ +service === null) { + $this->service = service('part_chassisservice'); + } + $this->addActionPaths('chassis'); + } + //기본 함수 작업 + //Custom 추가 함수 +} diff --git a/app/DTOs/Part/CHASSISDTO.php b/app/DTOs/Part/CHASSISDTO.php new file mode 100644 index 0000000..b3be1b9 --- /dev/null +++ b/app/DTOs/Part/CHASSISDTO.php @@ -0,0 +1,20 @@ +attributes['stock']; + } + public function getUsed(): int + { + return $this->attributes['used']; + } + public function getAvailable(): int + { + return $this->getStock() - $this->getUsed(); + } +} diff --git a/app/Forms/Part/CHASSISForm.php b/app/Forms/Part/CHASSISForm.php new file mode 100644 index 0000000..28d91b4 --- /dev/null +++ b/app/Forms/Part/CHASSISForm.php @@ -0,0 +1,23 @@ + "서버샷시정보", + 'label' => [ + 'title' => "모델명", + 'price' => "기본가", + 'used' => "사용갯수", + 'stock' => "재고", + 'status' => "상태", + 'updated_at' => "수정일", + 'created_at' => "작성일", + 'deleted_at' => "삭제일", + ], + "STATUS" => [ + STATUS['AVAILABLE'] => "사용가능", + STATUS['FORBIDDEN'] => "사용불가", + ], +]; diff --git a/app/Models/Part/CHASSISModel.php b/app/Models/Part/CHASSISModel.php new file mode 100644 index 0000000..1e3e650 --- /dev/null +++ b/app/Models/Part/CHASSISModel.php @@ -0,0 +1,29 @@ +addClassPaths('CHASSIS'); + } + protected function getDTOClass(): string + { + return CHASSISDTO::class; + } + public function createDTO(array $formDatas): CHASSISDTO + { + return new CHASSISDTO($formDatas); + } + public function getEntityClass(): string + { + return CHASSISEntity::class; + } + public function getFormService(): CHASSISForm + { + if ($this->_form === null) { + $this->_form = new CHASSISForm(); + $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(): CHASSISHelper + { + if ($this->_helper === null) { + $this->_helper = new CHASSISHelper(); + $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; + } + public function action_init_process(string $action, array $formDatas = []): void + { + $fields = [ + "title", + "price", + "stock", + ]; + $filters = [ + "status", + ]; + $indexFilter = $filters; + $batchjobFilters = ['status']; + 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; + } + $this->getFormService()->setFormFields($fields); + $this->getFormService()->setFormRules($action, $fields); + $this->getFormService()->setFormFilters($filters); + $this->getFormService()->setFormOptions($action, $filters, $formDatas); + $this->getFormService()->setIndexFilters($indexFilter); + $this->getFormService()->setBatchjobFilters($batchjobFilters); + } + //기본 기능부분 + protected function getEntity_process(mixed $entity): CHASSISEntity + { + return $entity; + } + protected function create_process(array $formDatas): CHASSISEntity + { + return parent::create_process($formDatas); + } + protected function modify_process($entity, array $formDatas): CHASSISEntity + { + return parent::modify_process($entity, $formDatas); + } + //List 검색용 + //FormFilter 조건절 처리 + //검색어조건절처리 + //OrderBy 처리 + public function setOrderBy(mixed $field = null, mixed $value = null): void + { + $this->model->orderBy('title ASC'); + parent::setOrderBy($field, $value); + } + //서버파트관련 작업 + //파트정보가져오기 + public function getPartEntityByServerPart(ServerPartEntity $serverPartEntity): CHASSISEntity + { + //IP정보에서 해당하는 IP가 있으면 가져와서 사용중인지 체크 후 수정 + $entity = $this->getEntity($serverPartEntity->getPartUID()); + if (!$entity instanceof CHASSISEntity) { + throw new \Exception(message: "{$serverPartEntity->getPartUID()}에 해당하는 CHASSISEntity정보를 찾을수없습니다."); + } + return $entity; + } + public function attachToServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity + { + /** @var CHASSISEntity $entity IDE에 entity type알려주기*/ + $entity = parent::attachToServerPart($serverPartEntity, $formDatas); + return $entity; + } + public function detachFromServerPart(ServerPartEntity $serverPartEntity, array $formDatas = []): CHASSISEntity + { + /** @var CHASSISEntity $entity IDE에 entity type알려주기*/ + $entity = parent::detachFromServerPart($serverPartEntity, $formDatas); + return $entity; + } +} diff --git a/app/Services/Part/CPUService.php b/app/Services/Part/CPUService.php index 9d437db..1f0519d 100644 --- a/app/Services/Part/CPUService.php +++ b/app/Services/Part/CPUService.php @@ -2,13 +2,11 @@ namespace App\Services\Part; -use RuntimeException; use App\Models\Part\CPUModel; use App\Helpers\Part\CPUHelper; use App\Forms\Part\CPUForm; use App\Entities\Part\CPUEntity; use App\Entities\Equipment\ServerPartEntity; -use App\Entities\CommonEntity; use App\DTOs\Part\CPUDTO; class CPUService extends PartType1Service diff --git a/app/Views/admin/welcome.php b/app/Views/admin/welcome/index.php similarity index 100% rename from app/Views/admin/welcome.php rename to app/Views/admin/welcome/index.php diff --git a/app/Views/admin/welcome/new_service.php b/app/Views/admin/welcome/new_service.php index b003bdd..062d505 100644 --- a/app/Views/admin/welcome/new_service.php +++ b/app/Views/admin/welcome/new_service.php @@ -24,13 +24,9 @@ getSite()] ?> - getHelper()->getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?> - $entity->getServerInfoUID(), - 'types' => SERVERPART['SERVICE_PARTTYPES'], - 'template' => 'partlist_service' - ]) ?> - getHelper()->getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?> + getFieldView('clientinfo_uid', $entity->getClientInfoUID(), $viewDatas) ?> + getFieldView('serverinfo_uid', $entity->getServerInfoUID(), $viewDatas) ?> + getFieldView('user_uid', $entity->getUserUID(), $viewDatas) ?> diff --git a/app/Views/layouts/admin/left_menu/part.php b/app/Views/layouts/admin/left_menu/part.php index 34cd735..6ba4142 100644 --- a/app/Views/layouts/admin/left_menu/part.php +++ b/app/Views/layouts/admin/left_menu/part.php @@ -14,6 +14,9 @@
CS정보
+
+ 서버샷시정보 +
CPU정보