diff --git a/app/Controllers/Admin/Equipment/EquipmentController.php b/app/Controllers/Admin/Equipment/EquipmentController.php index 95ebdca..d89bd67 100644 --- a/app/Controllers/Admin/Equipment/EquipmentController.php +++ b/app/Controllers/Admin/Equipment/EquipmentController.php @@ -4,9 +4,10 @@ namespace App\Controllers\Admin\Equipment; use App\Controllers\Admin\AdminController; use App\Services\Customer\ClientService; +use App\Services\Customer\ServiceService; use App\Services\Equipment\LineService; -use App\Services\Equipment\ServerService; +use App\Services\Equipment\ServerService; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; @@ -16,6 +17,7 @@ abstract class EquipmentController extends AdminController private ?ClientService $_clientService = null; private ?LineService $_lineService = null; private ?ServerService $_serverService = null; + private ?ServiceService $_serviceService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -29,6 +31,14 @@ abstract class EquipmentController extends AdminController } return $this->_clientService; } + final public function getServiceService(): ServiceService + { + if (!$this->_serviceService) { + $this->_serviceService = new ServiceService($this->request); + } + return $this->_serviceService; + } + final public function getLineService(): LineService { if (!$this->_lineService) { @@ -47,6 +57,14 @@ abstract class EquipmentController extends AdminController protected function getFormFieldOption(string $field, array $options): array { switch ($field) { + case 'serviceinfo_uid': + $temps = []; + foreach ($this->getServiceService()->getEntities() as $entity) { + $temps[$entity->getPK()] = $entity->getTitle(); + } + $options[$field] = $temps; + // dd($options); + break; case 'clientinfo_uid': $temps = []; foreach ($this->getClientService()->getEntities() as $entity) { diff --git a/app/Controllers/Admin/Equipment/Link/CpuController.php b/app/Controllers/Admin/Equipment/Link/CpuController.php index e01a790..0e7a4be 100644 --- a/app/Controllers/Admin/Equipment/Link/CpuController.php +++ b/app/Controllers/Admin/Equipment/Link/CpuController.php @@ -2,15 +2,17 @@ namespace App\Controllers\Admin\Equipment\Link; -use App\Helpers\Equipment\Link\CpuHelper; -use App\Services\Equipment\Link\CpuService; use CodeIgniter\HTTP\RequestInterface; - use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Helpers\Equipment\Link\CpuHelper; +use App\Services\Equipment\Link\CpuService; +use App\Services\Equipment\Part\CpuService as PartService; + class CpuController extends LinkController { + protected ?PartService $_partService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -33,12 +35,19 @@ class CpuController extends LinkController } return $this->_helper; } + public function getPartService(): PartService + { + if (!$this->_partService) { + $this->_partService = new PartService($this->request); + } + return $this->_partService; + } //Index,FieldForm관련 protected function index_process(): array { $fields = [ - 'fields' => ['billing_type', 'serviceinfo_uid', 'serverinfo_uid', 'cpuinfo_uid', 'amount'], + 'fields' => ['serverinfo_uid', 'cpuinfo_uid'], ]; $this->init('index', $fields); $this->modal_type = 'modal_iframe'; diff --git a/app/Controllers/Admin/Equipment/Link/DiskController.php b/app/Controllers/Admin/Equipment/Link/DiskController.php index 0537bff..5626bbd 100644 --- a/app/Controllers/Admin/Equipment/Link/DiskController.php +++ b/app/Controllers/Admin/Equipment/Link/DiskController.php @@ -2,15 +2,17 @@ namespace App\Controllers\Admin\Equipment\Link; -use App\Helpers\Equipment\Link\DiskHelper; -use App\Services\Equipment\Link\DiskService; use CodeIgniter\HTTP\RequestInterface; - use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Helpers\Equipment\Link\DiskHelper; +use App\Services\Equipment\Link\DiskService; +use App\Services\Equipment\Part\DiskService as PartService; + class DiskController extends LinkController { + protected ?PartService $_partService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -33,11 +35,18 @@ class DiskController extends LinkController } return $this->_helper; } + public function getPartService(): PartService + { + if (!$this->_partService) { + $this->_partService = new PartService($this->request); + } + return $this->_partService; + } //Index,FieldForm관련 protected function index_process(): array { $fields = [ - 'fields' => ['billing_type', 'serviceinfo_uid', 'serverinfo_uid', 'diskinfo_uid', 'amount'], + 'fields' => ['serverinfo_uid', 'diskinfo_uid'], ]; $this->init('index', $fields); $this->modal_type = 'modal_iframe'; diff --git a/app/Controllers/Admin/Equipment/Link/LinkController.php b/app/Controllers/Admin/Equipment/Link/LinkController.php index d18602e..a21a28d 100644 --- a/app/Controllers/Admin/Equipment/Link/LinkController.php +++ b/app/Controllers/Admin/Equipment/Link/LinkController.php @@ -17,6 +17,7 @@ abstract class LinkController extends EquipmentController $this->uri_path .= 'part/'; // $this->view_path .= "part" . DIRECTORY_SEPARATOR; } + abstract public function getPartService(): mixed; protected function setOrderByForList() { @@ -39,4 +40,32 @@ abstract class LinkController extends EquipmentController } return $result; } + + protected function getFormFieldOption(string $field, array $options): array + { + switch ($field) { + case 'serverinfo_uid': + $temps = []; + foreach ($this->getServerService()->getEntities() as $entity) { + $temps[$entity->getPK()] = $entity->getTitle(); + } + $options[$field] = $temps; + // dd($options); + break; + case 'cpuinfo_uid': + case 'raminfo_uid': + case 'diskinfo_uid': + $temps = []; + foreach ($this->getPartService()->getEntities() as $entity) { + $temps[$entity->getPK()] = $entity->getTitle(); + } + $options[$field] = $temps; + // dd($options); + break; + default: + $options = parent::getFormFieldOption($field, $options); + break; + } + return $options; + } } diff --git a/app/Controllers/Admin/Equipment/Link/RamController.php b/app/Controllers/Admin/Equipment/Link/RamController.php index a6c7940..51c4bb8 100644 --- a/app/Controllers/Admin/Equipment/Link/RamController.php +++ b/app/Controllers/Admin/Equipment/Link/RamController.php @@ -2,15 +2,17 @@ namespace App\Controllers\Admin\Equipment\Link; -use App\Helpers\Equipment\Link\RamHelper; -use App\Services\Equipment\Link\RamService; use CodeIgniter\HTTP\RequestInterface; - use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Helpers\Equipment\Link\RamHelper; +use App\Services\Equipment\Link\RamService; +use App\Services\Equipment\Part\RamService as PartService; + class RamController extends LinkController { + protected ?PartService $_partService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -33,11 +35,18 @@ class RamController extends LinkController } return $this->_helper; } + public function getPartService(): PartService + { + if (!$this->_partService) { + $this->_partService = new PartService($this->request); + } + return $this->_partService; + } //Index,FieldForm관련 protected function index_process(): array { $fields = [ - 'fields' => ['billing_type', 'serviceinfo_uid', 'serverinfo_uid', 'raminfo_uid', 'amount'], + 'fields' => ['serverinfo_uid', 'raminfo_uid'], ]; $this->init('index', $fields); $this->modal_type = 'modal_iframe'; diff --git a/app/Language/en/Equipment/Link/Cpu.php b/app/Language/en/Equipment/Link/Cpu.php index 63e6655..a8fd2de 100644 --- a/app/Language/en/Equipment/Link/Cpu.php +++ b/app/Language/en/Equipment/Link/Cpu.php @@ -10,4 +10,8 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + "BILLING_TYPE" => [ + "month" => "월별", + "onetime" => "일회성", + ], ]; diff --git a/app/Language/en/Equipment/Link/Disk.php b/app/Language/en/Equipment/Link/Disk.php index 556c772..e4bf073 100644 --- a/app/Language/en/Equipment/Link/Disk.php +++ b/app/Language/en/Equipment/Link/Disk.php @@ -10,4 +10,8 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + "BILLING_TYPE" => [ + "month" => "월별", + "onetime" => "일회성", + ], ]; diff --git a/app/Language/en/Equipment/Link/Ram.php b/app/Language/en/Equipment/Link/Ram.php index 15da5c2..31443ac 100644 --- a/app/Language/en/Equipment/Link/Ram.php +++ b/app/Language/en/Equipment/Link/Ram.php @@ -10,4 +10,8 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", ], + "BILLING_TYPE" => [ + "month" => "월별", + "onetime" => "일회성", + ], ]; diff --git a/app/Models/Equipment/Link/CpuModel.php b/app/Models/Equipment/Link/CpuModel.php index 8bab4d0..ba9ea52 100644 --- a/app/Models/Equipment/Link/CpuModel.php +++ b/app/Models/Equipment/Link/CpuModel.php @@ -13,11 +13,8 @@ class CpuModel extends LinkModel protected $primaryKey = self::PK; protected $returnType = CpuEntity::class; protected $allowedFields = [ - "serviceinfo_uid", "serverinfo_uid", "cpuinfo_uid", - "billing_type", - "amount", "updated_at", ]; public function __construct() diff --git a/app/Models/Equipment/Link/DiskModel.php b/app/Models/Equipment/Link/DiskModel.php index c865021..cd49cea 100644 --- a/app/Models/Equipment/Link/DiskModel.php +++ b/app/Models/Equipment/Link/DiskModel.php @@ -13,11 +13,8 @@ class DiskModel extends LinkModel protected $primaryKey = self::PK; protected $returnType = DiskEntity::class; protected $allowedFields = [ - "serviceinfo_uid", "serverinfo_uid", "diskinfo_uid", - "billing_type", - "amount", "updated_at", ]; public function __construct() diff --git a/app/Models/Equipment/Link/LinkModel.php b/app/Models/Equipment/Link/LinkModel.php index 06e411f..ffef37c 100644 --- a/app/Models/Equipment/Link/LinkModel.php +++ b/app/Models/Equipment/Link/LinkModel.php @@ -16,14 +16,10 @@ abstract class LinkModel extends EquipmentModel throw new \Exception(__FUNCTION__ . "=> field가 array 입니다.\n" . var_export($field, true)); } switch ($field) { - case "serviceinfo_uid": case "serverinfo_uid": case "cpuinfo_uid": case "raminfo_uid": case "diskinfo_uid": - $rule = "required|trim|string"; - break; - case "amount": $rule = "required|numeric"; break; default: diff --git a/app/Models/Equipment/Link/RamModel.php b/app/Models/Equipment/Link/RamModel.php index 2ceb7f5..a962a8f 100644 --- a/app/Models/Equipment/Link/RamModel.php +++ b/app/Models/Equipment/Link/RamModel.php @@ -13,11 +13,8 @@ class RamModel extends LinkModel protected $primaryKey = self::PK; protected $returnType = RamEntity::class; protected $allowedFields = [ - "serviceinfo_uid", "serverinfo_uid", "raminfo_uid", - "billing_type", - "amount", "updated_at", ]; public function __construct() diff --git a/app/Services/Equipment/Link/CpuService.php b/app/Services/Equipment/Link/CpuService.php index ec8c031..f9468fc 100644 --- a/app/Services/Equipment/Link/CpuService.php +++ b/app/Services/Equipment/Link/CpuService.php @@ -25,15 +25,20 @@ class CpuService extends LinkService { return new CpuEntity(); } - public function getFields(): array { return [ - "billing_type", - "serviceinfo_uid", "serverinfo_uid", "cpuinfo_uid", - "amount", ]; } + + public function getFilterFields(): array + { + return ["serverinfo_uid", "cpuinfo_uid"]; + } + public function getBatchJobFields(): array + { + return []; + } } diff --git a/app/Services/Equipment/Link/DiskService.php b/app/Services/Equipment/Link/DiskService.php index 3b3f249..9855b9a 100644 --- a/app/Services/Equipment/Link/DiskService.php +++ b/app/Services/Equipment/Link/DiskService.php @@ -29,11 +29,17 @@ class DiskService extends LinkService public function getFields(): array { return [ - "billing_type", - "serviceinfo_uid", "serverinfo_uid", "diskinfo_uid", - "amount", ]; } + + public function getFilterFields(): array + { + return ["serverinfo_uid", "diskinfo_uid"]; + } + public function getBatchJobFields(): array + { + return []; + } } diff --git a/app/Services/Equipment/Link/LinkService.php b/app/Services/Equipment/Link/LinkService.php index 55376d5..0d6f887 100644 --- a/app/Services/Equipment/Link/LinkService.php +++ b/app/Services/Equipment/Link/LinkService.php @@ -16,13 +16,4 @@ abstract class LinkService extends EquipmentService { return parent::getClassName() . DIRECTORY_SEPARATOR . "Link"; } - - public function getFilterFields(): array - { - return []; - } - public function getBatchJobFields(): array - { - return []; - } } diff --git a/app/Services/Equipment/Link/RamService.php b/app/Services/Equipment/Link/RamService.php index 94edced..9fffc06 100644 --- a/app/Services/Equipment/Link/RamService.php +++ b/app/Services/Equipment/Link/RamService.php @@ -29,11 +29,17 @@ class RamService extends LinkService public function getFields(): array { return [ - "billing_type", - "serviceinfo_uid", "serverinfo_uid", "raminfo_uid", - "amount", ]; } + + public function getFilterFields(): array + { + return ["serverinfo_uid", "raminfo_uid"]; + } + public function getBatchJobFields(): array + { + return []; + } }