From eb36d740339b2454067df36d86d02c27827271c8 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Wed, 27 Aug 2025 11:14:41 +0900 Subject: [PATCH] dbmsv2 init...1 --- app/Config/Constants.php | 10 +- .../Admin/Equipment/ServerController.php | 56 ++++++----- app/Controllers/Auth/AuthController.php | 5 +- app/Controllers/Auth/GoogleController.php | 4 +- app/Controllers/Auth/LocalController.php | 4 +- app/Controllers/CommonController.php | 2 +- app/Entities/Equipment/ServerEntity.php | 18 ++-- app/Entities/Equipment/ServerPartEntity.php | 47 ++++++++++ app/Helpers/Equipment/ServerHelper.php | 37 ++++---- app/Language/en/Equipment/Server.php | 14 +-- app/Models/Equipment/ServerPartModel.php | 4 +- app/Services/Auth/AuthService.php | 17 +++- app/Services/CommonService.php | 11 ++- app/Services/Equipment/ServerPartService.php | 89 ++++++++++++++++++ app/Services/Equipment/ServerService.php | 93 ++++++------------- 15 files changed, 269 insertions(+), 142 deletions(-) create mode 100644 app/Services/Equipment/ServerPartService.php diff --git a/app/Config/Constants.php b/app/Config/Constants.php index b6e1263..20f48d3 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -368,13 +368,13 @@ define('SERVICE_NEW_INTERVAL', $_ENV['SERVICE_NEW_INTERVAL'] ?? $_SERVER['SERVIC //결제관련 define("PAYMENT", [ 'BILLING' => [ - 'METHOD_MONTH' => 'month', - 'METHOD_ONETIME' => 'onetime' + 'MONTH' => 'month', + 'ONETIME' => 'onetime' ], 'PAY' => [ - 'METHOD_ACCOUNT' => 'account', - 'METHOD_COUPON' => 'coupon', - 'METHOD_POINT' => 'point' + 'ACCOUNT' => 'account', + 'COUPON' => 'coupon', + 'POINT' => 'point' ] ]); diff --git a/app/Controllers/Admin/Equipment/ServerController.php b/app/Controllers/Admin/Equipment/ServerController.php index ca2f5d9..28744ec 100644 --- a/app/Controllers/Admin/Equipment/ServerController.php +++ b/app/Controllers/Admin/Equipment/ServerController.php @@ -3,9 +3,11 @@ namespace App\Controllers\Admin\Equipment; use App\Entities\Equipment\ServerEntity; +use App\Entities\Equipment\ServerPartEntity; use App\Helpers\Equipment\ServerHelper; -use App\Services\Equipment\ServerService; +use App\Services\Equipment\ServerPartService; +use App\Services\Equipment\ServerService; use CodeIgniter\HTTP\RedirectResponse; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -13,6 +15,7 @@ use Psr\Log\LoggerInterface; class ServerController extends EquipmentController { + private ?ServerPartService $_serverPartService = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { parent::initController($request, $response, $logger); @@ -21,8 +24,8 @@ class ServerController extends EquipmentController $this->uri_path .= strtolower($this->getService()->getClassName('/')) . '/'; // $this->view_path .= strtolower($this->getService()->getClassName()) . DIRECTORY_SEPARATOR; - $this->partinfo_cnt_range = array_combine(range(0, 10), range(0, 10)); - $this->partinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS")); + $this->serverpartinfo_cnt_range = array_combine(range(0, 10), range(0, 10)); + $this->serverpartinfo_extra_options = array_merge(["" => "RAID 선택"], lang("{$this->getService()->getClassName()}.EXTRAS")); } public function getService(): ServerService { @@ -38,7 +41,13 @@ class ServerController extends EquipmentController } return $this->_helper; } - + final public function getServerPartService(): ServerPartService + { + if (!$this->_serverPartService) { + $this->_serverPartService = new ServerPartService(); + } + return $this->_serverPartService; + } //Index,FieldForm관련 //생성 protected function create_form_process(): void @@ -50,6 +59,24 @@ class ServerController extends EquipmentController $this->setFieldDefaultValue('code', $this->getService()->getLastestCode($format, (int)env("Server.Default.code", 0))); parent::create_form_process(); } + //추가 파트정보 생성 + private function createServerParts(ServerEntity $entity): array + { + $serverPartEntities = []; + foreach (ServerPartService::BaseParts as $basePart) { + $formDatas = [ + "partinfo_uid" => $this->request->getPost(["serverpartinfo_{$basePart}_uid"]), + "serverinfo_uid" => $entity->getPK(), + "serviceinfo_uid" => $entity->getServiceInfoUID(), + "billing" => ServerPartENtity::DEFAULT_BILLING, + "amount" => $this->request->getPost("amount") ?? 0, + "cnt" => $this->request->getPost("serverpartinfo_{$basePart}_uid_cnt") ?? 1, + "extra" => $this->request->getPost("serverpartinfo_{$basePart}_uid_extra") ?? "" + ]; + $serverPartEntities[] = $this->getServerPartService()->create($formDatas); + } + return $serverPartEntities; + } protected function create_process(array $formDatas): ServerEntity { //코드 패턴체크 @@ -64,30 +91,15 @@ class ServerController extends EquipmentController throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다"); } $entity = parent::create_process($formDatas); - - //추가 파트정보 생성 - $partDatas = []; - foreach ($this->getService()::BaseParts as $basePart) { - $partDatas[$basePart] = [ - "partinfo_uid" => $formDatas["partinfo_{$basePart}_uid"], - "cnt" => $this->request->getPost(index: "partinfo_{$basePart}_uid_cnt") ?? 1, - "extra" => $this->request->getPost("partinfo_{$basePart}_uid_extra") ?? "" - ]; - } - $this->serverPartEntities = $this->getService()->createServerParts($entity, $partDatas); + //추가 파트정보 생성 후 ServerEntity 에 설정 + $entity->setServerParts($this->createServerParts($entity)); return $entity; } protected function index_process(array $entities = []): array { - // //부품정보 FormOption 설정용 - // $this->serverBaseParts = $this->getService()::BaseParts; - // foreach ($this->getService()::BaseParts as $basePart) { - // $this->setFormFieldOptions("partinfo_{$basePart}_uid", $this->getFormFieldOption_process("partinfo_{$basePart}_uid")); - // } - // foreach (parent::index_process($entities) as $entity) { //서버 부품정보 정의 - $entity->setServerParts($this->getService()->getServerParts($entity)); + $entity->setServerParts($this->getServerPartService()->getEntities(['serverinfo_uid' => $entity->getPK()])); //서버 IP정보 정의 //서버 CS정보 정의 $entities[] = $entity; diff --git a/app/Controllers/Auth/AuthController.php b/app/Controllers/Auth/AuthController.php index 77288ba..884ca94 100644 --- a/app/Controllers/Auth/AuthController.php +++ b/app/Controllers/Auth/AuthController.php @@ -48,7 +48,10 @@ abstract class AuthController extends CommonController } return $result; } - + final protected function create_validate_process(array $formDatas): array + { + return $formDatas; + } //로그인화면 public function create_form_process(): void { diff --git a/app/Controllers/Auth/GoogleController.php b/app/Controllers/Auth/GoogleController.php index 96b2496..6e45986 100644 --- a/app/Controllers/Auth/GoogleController.php +++ b/app/Controllers/Auth/GoogleController.php @@ -41,11 +41,11 @@ class GoogleController extends AuthController } //로그인처리 - protected function create_process(array $formDatas): void + protected function create_process(array $formDatas): UserEntity { if (!array_key_exists('access_code', $formDatas) || !$formDatas['access_code']) { throw new \Exception("구글 로그인 실패"); } - $this->entity = $this->getService()->login($formDatas); + return $this->getService()->login($formDatas); } } diff --git a/app/Controllers/Auth/LocalController.php b/app/Controllers/Auth/LocalController.php index a1ae76e..44fd5f6 100644 --- a/app/Controllers/Auth/LocalController.php +++ b/app/Controllers/Auth/LocalController.php @@ -29,8 +29,8 @@ class LocalController extends AuthController return ""; } //로그인처리 - protected function create_process(array $formDatas): void + protected function create_process(array $formDatas): UserEntity { - $this->entity = $this->getService()->login($formDatas); + return $this->getService()->login($formDatas); } } diff --git a/app/Controllers/CommonController.php b/app/Controllers/CommonController.php index 7ff832c..c550cfe 100644 --- a/app/Controllers/CommonController.php +++ b/app/Controllers/CommonController.php @@ -462,7 +462,7 @@ abstract class CommonController extends BaseController throw new \Exception("{$uid}에 대한 정보를 찾을수 없습니다."); } $this->entity = $entity; - list($file_name, $uploaded_filename) = $this->entity->getDownlaodFile(); + list($file_name, $uploaded_filename) = $entity->getDownlaodFile(); $full_path = WRITEPATH . DIRECTORY_SEPARATOR . "uploads" . DIRECTORY_SEPARATOR . $uploaded_filename; break; } diff --git a/app/Entities/Equipment/ServerEntity.php b/app/Entities/Equipment/ServerEntity.php index 6ba6497..be20b67 100644 --- a/app/Entities/Equipment/ServerEntity.php +++ b/app/Entities/Equipment/ServerEntity.php @@ -13,6 +13,15 @@ class ServerEntity extends EquipmentEntity const STATUS_FORBIDDEN = "forbidden"; const DEFAULT_STATUS = self::STATUS_AVAILABLE; + public function setServerParts(array $datas): void + { + $this->attributes['server_parts'] = $datas; + } + public function getServerParts(): array + { + return $this->attributes['server_parts'] ?? []; + } + //기본기능용 public function getCode(): string { return $this->attributes['code']; @@ -25,13 +34,4 @@ class ServerEntity extends EquipmentEntity { return $this->attributes['serviceinfo_uid'] ?? null; } - - public function setServerParts(array $datas): void - { - $this->attributes['server_parts'] = $datas; - } - public function getServerParts(): array - { - return $this->attributes['server_parts'] ?? []; - } } diff --git a/app/Entities/Equipment/ServerPartEntity.php b/app/Entities/Equipment/ServerPartEntity.php index b509fdd..e7928bf 100644 --- a/app/Entities/Equipment/ServerPartEntity.php +++ b/app/Entities/Equipment/ServerPartEntity.php @@ -8,4 +8,51 @@ class ServerPartEntity extends EquipmentEntity { const PK = ServerPartModel::PK; const TITLE = ServerPartModel::TITLE; + const DEFAULT_BILLING = PAYMENT['BILLING']['MONTH']; + + public function setPartEntity(PartEntity $entity): void + { + $this->attributes['part'] = $entity; + } + public function getTitle(): string + { + return $this->getPartEntity()->getTitle(); + } + public function getPrice(): string + { + return $this->getPartEntity()->getPrice(); + } + //기본기능용 + public function getPartEntity(): PartEntity + { + return $this->attributes['part'] ?? []; + } + public function getPartInfoUID(): int + { + return $this->attributes['partinfo_uid']; + } + public function getServerInfoUID(): int + { + return $this->attributes['serverinfo_uid']; + } + public function getServiceInfoUID(): int|null + { + return $this->attributes['serviceinfo_uid'] ?? null; + } + public function getBilling(): string + { + return $this->attributes['billing']; + } + public function getAmount(): int + { + return $this->attributes['amount']; + } + public function getCnt(): int + { + return $this->attributes['cnt']; + } + public function getExtra(): string|null + { + return $this->attributes['extra'] ?? null; + } } diff --git a/app/Helpers/Equipment/ServerHelper.php b/app/Helpers/Equipment/ServerHelper.php index d801597..ca8b95b 100644 --- a/app/Helpers/Equipment/ServerHelper.php +++ b/app/Helpers/Equipment/ServerHelper.php @@ -19,21 +19,18 @@ class ServerHelper extends EquipmentHelper $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' calender' : 'calender'; $form = form_input($field, $value ?? "", $extras); break; - case 'partinfo_cpu_uid': - case 'partinfo_ram_uid': - case 'partinfo_disk_uid': - case 'partinfo_software_uid': - case 'partinfo_os_uid': - case 'partinfo_db_uid': + case 'serverpartinfo_cpu_uid': + case 'serverpartinfo_ram_uid': + case 'serverpartinfo_disk_uid': + case 'serverpartinfo_software_uid': + case 'serverpartinfo_os_uid': + case 'serverpartinfo_db_uid': $form = $this->form_dropdown_custom($field, $value, $viewDatas, $extras); - $form .= " " . form_dropdown("{$field}_cnt", $viewDatas['partinfo_cnt_range'], $value ?? 1) . "개"; - if ($field === 'partinfo_disk_uid') { - $form .= form_dropdown("{$field}_extra", $viewDatas['partinfo_extra_options'], $value ?? 1); + $form .= " " . form_dropdown("{$field}_cnt", $viewDatas['serverpartinfo_cnt_range'], old("{$field}_cnt") ?? $viewDatas['entity']->$field ?? 1) . "개"; + if ($field === 'serverpartinfo_disk_uid') { + $form .= form_dropdown("{$field}_extra", $viewDatas['serverpartinfo_extra_options'], old("{$field}_extra") ?? $viewDatas['entity']->$field ?? 1); } break; - case 'partinfo_uid': - $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; - $form = $this->form_dropdown_custom($field, $value, $viewDatas, $extras); case 'ipinfo_uid': case 'csinfo_uid': $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; @@ -52,11 +49,15 @@ class ServerHelper extends EquipmentHelper case 'format_at': $value = $value ? date("Y-m-d", strtotime($value)) : ""; break; - case 'partinfo_uid': + case 'serverpartinfo': $value = ""; - foreach ($viewDatas['entity']->getServerParts() as $part) { - // $value .= "
" . $this->getFieldForm("partinfo_" . strtolower($part->type) . "_uid", $part->partinfo_uid, $viewDatas, $extras) . "
"; - $value .= sprintf("
%s%s %s
", $part->title, $part->cnt > 1 ? "*" . $part->cnt . "개" : "", $part->extra ?? ""); + foreach ($viewDatas['entity']->getServerParts() as $serverPart) { + $value .= sprintf( + "
%s%s %s
", + $serverPart->getTitle(), + $serverPart->getCnt() > 1 ? "*" . $serverPart->getCnt() . "개" : "", + $serverPart->getExtra() ?? "" + ); } // dd($value); break; @@ -78,10 +79,6 @@ class ServerHelper extends EquipmentHelper $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $form = parent::getListFilter($field, $value, $viewDatas, $extras); break; - case 'partinfo_uid': - $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; - $form = $this->form_dropdown_custom($field, $value, $viewDatas, $extras); - break; default: $form = parent::getListFilter($field, $value, $viewDatas, $extras); break; diff --git a/app/Language/en/Equipment/Server.php b/app/Language/en/Equipment/Server.php index 1e43f26..6c5d928 100644 --- a/app/Language/en/Equipment/Server.php +++ b/app/Language/en/Equipment/Server.php @@ -15,15 +15,15 @@ return [ 'updated_at' => "수정일", 'created_at' => "작성일", 'deleted_at' => "삭제일", - "partinfo_uid" => "부품정보", + "serverpartinfo" => "부품정보", "ipinfo_uid" => "IP정보", "csinfo_uid" => "CS정보", - 'partinfo_cpu_uid' => "CPU", - 'partinfo_ram_uid' => "RAM", - 'partinfo_disk_uid' => "DISK", - 'partinfo_os_uid' => "OS", - 'partinfo_db_uid' => "DB", - 'partinfo_software_uid' => "기타SW", + 'serverpartinfo_cpu_uid' => "CPU", + 'serverpartinfo_ram_uid' => "RAM", + 'serverpartinfo_disk_uid' => "DISK", + 'serverpartinfo_os_uid' => "OS", + 'serverpartinfo_db_uid' => "DB", + 'serverpartinfo_software_uid' => "기타SW", ], "TITLE" => [ 'HP DL360 Gen6' => "HP DL360 Gen6", diff --git a/app/Models/Equipment/ServerPartModel.php b/app/Models/Equipment/ServerPartModel.php index a373557..1788354 100644 --- a/app/Models/Equipment/ServerPartModel.php +++ b/app/Models/Equipment/ServerPartModel.php @@ -8,7 +8,7 @@ class ServerPartModel extends EquipmentModel { const TABLE = "serverinfo_partinfo"; const PK = "uid"; - const TITLE = "partinfo_uio"; + const TITLE = "uid"; protected $table = self::TABLE; protected $primaryKey = self::PK; protected $returnType = ServerPartEntity::class; @@ -34,8 +34,8 @@ class ServerPartModel extends EquipmentModel case "partinfo_uid": case "serverinfo_uid": case "billing": - case "amount": case "cnt": + case "amount": $rule = "required|numeric"; break; case "serviceinfo_uid": diff --git a/app/Services/Auth/AuthService.php b/app/Services/Auth/AuthService.php index 0f577ed..61d0f5d 100644 --- a/app/Services/Auth/AuthService.php +++ b/app/Services/Auth/AuthService.php @@ -83,7 +83,12 @@ abstract class AuthService extends CommonService final protected function login_process(UserEntity $entity): UserEntity { $this->getSession()->set(SESSION_NAMES['ISLOGIN'], true); - $this->getSession()->set(SESSION_NAMES['AUTH'], ['uid' => $entity->getPK(), 'id' => $entity->getID(), 'name' => $entity->getTitle(), 'role' => $entity->role]); + $this->getSession()->set(SESSION_NAMES['AUTH'], [ + 'uid' => $entity->getPK(), + 'id' => $entity->getID(), + 'name' => $entity->getTitle(), + 'role' => $entity->role + ]); return $entity; } final public function logout(): void @@ -96,7 +101,15 @@ abstract class AuthService extends CommonService // 세션 쿠키 삭제 if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); - setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]); + setcookie( + session_name(), + '', + time() - 42000, + $params["path"], + $params["domain"], + $params["secure"], + $params["httponly"] + ); } // 세션 재생성 session_start(); diff --git a/app/Services/CommonService.php b/app/Services/CommonService.php index f39b8a1..731775b 100644 --- a/app/Services/CommonService.php +++ b/app/Services/CommonService.php @@ -72,15 +72,16 @@ abstract class CommonService if ($where) { $this->getModel()->where($where); } - return $this->getModel()->select(implode(',', $columns))->findAll(); + $entities = []; + foreach ($this->getModel()->select(implode(',', $columns))->findAll() as $entity) { + $entities[$entity->getPK()] = $this->getEntity_process($entity); + } + return $entities; } final public function getEntities(mixed $where = null, array $columns = ['*']): array { try { - $entities = []; - foreach ($this->getEntities_process($where, $columns) as $entity) { - $entities[$entity->getPK()] = $this->getEntity_process($entity); - } + $entities = $this->getEntities_process($where, $columns); $debug = sprintf("debug.%s.%s", $this->getClassName(), __FUNCTION__); if (env($debug, false)) { echo $debug . "=>" . $this->getModel()->getLastQuery() . "
"; diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php new file mode 100644 index 0000000..6242b2e --- /dev/null +++ b/app/Services/Equipment/ServerPartService.php @@ -0,0 +1,89 @@ +addClassName('Server'); + } + public function getFormFields(): array + { + return [ + 'fields' => [ + "partinfo_uid", + "serverinfo_uid", + "serviceinfo_uid", + "billing", + "amount", + "cnt", + "extra", + ], + 'filters' => [ + "partinfo_uid", + "serverinfo_uid", + "serviceinfo_uid", + ], + ]; + } + public function getIndexFields(): array + { + return $this->getFormFields(); + } + public function getBatchjobFields(): array + { + return ['partinfo_uid', "serverinfo_uid", "serviceinfo_uid",]; + } + final public function getPartService(): PartService + { + if (!$this->_partService) { + $this->_partService = new PartService(); + } + return $this->_partService; + } + //기본 기능부분 + //FieldForm관련용 + public function getFormFieldOption(string $field, array $options = []): array + { + switch ($field) { + case 'partinfo_cpu_uid': + $options = $this->getPartService()->getEntities(['type' => 'CPU']); + break; + case 'partinfo_ram_uid': + $options = $this->getPartService()->getEntities(['type' => 'RAM']); + break; + case 'partinfo_disk_uid': + $options = $this->getPartService()->getEntities(['type' => 'DISK']); + break; + case 'partinfo_os_uid': + $options = $this->getPartService()->getEntities(['type' => 'OS']); + break; + case 'partinfo_db_uid': + $options = $this->getPartService()->getEntities(['type' => 'DB']); + break; + case 'partinfo_software_uid': + $options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']); + break; + case 'partinfo_uid': //수정때문에 전체가 필요 + $options = $this->getPartService()->getEntities(); + break; + default: + $options = parent::getFormFieldOption($field, $options); + break; + } + return $options; + } + //partEntity 정보 추가 + protected function getEntity_process(mixed $entity): mixed + { + $entity->setPartEntity($this->getPartService()->getEntity($entity->getPartInfoUID())); + return $entity; + } +} diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 1c2d9ef..bece5ac 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -9,11 +9,7 @@ use App\Services\Equipment\EquipmentService; class ServerService extends EquipmentService { - private ?PartService $_partService = null; - private ?IPService $_ipService = null; - private ?CSService $_csService = null; - private ?ServerPartModel $_serverPartModel = null; - const BaseParts = ['cpu', 'ram', 'disk', 'os']; + private ?ServerPartService $_serverPartService = null; public function __construct() { parent::__construct(new ServerModel()); @@ -26,10 +22,10 @@ class ServerService extends EquipmentService "code", "type", "title", - "partinfo_cpu_uid", - "partinfo_ram_uid", - "partinfo_disk_uid", - "partinfo_os_uid", + "serverpartinfo_cpu_uid", + "serverpartinfo_ram_uid", + "serverpartinfo_disk_uid", + "serverpartinfo_os_uid", "price", "amount", "manufactur_at", @@ -41,10 +37,10 @@ class ServerService extends EquipmentService "serviceinfo_uid", "type", "title", - "partinfo_cpu_uid", - "partinfo_ram_uid", - "partinfo_disk_uid", - "partinfo_os_uid", + "serverpartinfo_cpu_uid", + "serverpartinfo_ram_uid", + "serverpartinfo_disk_uid", + "serverpartinfo_os_uid", "status" ], ]; @@ -57,26 +53,26 @@ class ServerService extends EquipmentService 'serviceinfo_uid', "type", 'title', - "partinfo_uid", + "serverpartinfo", 'price', 'amount', 'manufactur_at', "format_at", 'status' ], - 'filters' => ['clientinfo_uid', 'serviceinfo_uid', 'type', 'partinfo_uid', 'status'], + 'filters' => ['clientinfo_uid', 'serviceinfo_uid', 'type', 'status'], ]; } public function getBatchjobFields(): array { - return ['clientinfo_uid', 'partinfo_uid', 'status']; + return ['clientinfo_uid', 'status']; } - final public function getPartService(): PartService + final public function getServerPartService(): ServerPartService { - if (!$this->_partService) { - $this->_partService = new PartService(); + if (!$this->_serverPartService) { + $this->_serverPartService = new ServerPartService(); } - return $this->_partService; + return $this->_serverPartService; } final public function getIPService(): IPService { @@ -92,38 +88,27 @@ class ServerService extends EquipmentService } return $this->_csService; } - final public function getServerPartModel(): ServerPartModel - { - if (!$this->_serverPartModel) { - $this->_serverPartModel = new ServerPartModel(); - } - return $this->_serverPartModel; - } //기본 기능부분 - //FieldForm관련용 public function getFormFieldOption(string $field, array $options = []): array { switch ($field) { - case 'partinfo_cpu_uid': - $options = $this->getPartService()->getEntities(['type' => 'CPU']); + case 'serverpartinfo_cpu_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_cpu_uid'); break; - case 'partinfo_ram_uid': - $options = $this->getPartService()->getEntities(['type' => 'RAM']); + case 'serverpartinfo_ram_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_ram_uid'); break; - case 'partinfo_disk_uid': - $options = $this->getPartService()->getEntities(['type' => 'DISK']); + case 'serverpartinfo_disk_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_disk_uid'); break; - case 'partinfo_os_uid': - $options = $this->getPartService()->getEntities(['type' => 'OS']); + case 'serverpartinfo_os_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_os_uid'); break; - case 'partinfo_db_uid': - $options = $this->getPartService()->getEntities(['type' => 'DB']); + case 'serverpartinfo_db_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_db_uid'); break; - case 'partinfo_software_uid': - $options = $this->getPartService()->getEntities(['type' => 'SOFTWARE']); - break; - case 'partinfo_uid': //수정때문에 전체가 필요 - $options = $this->getPartService()->getEntities(); + case 'serverpartinfo_software_uid': + $options = $this->getServerPartService()->getFormFieldOption('partinfo_software_uid'); break; case 'ipinfo_uid': //수정때문에 전체가 필요 $options = $this->getIPService()->getEntities(); @@ -137,32 +122,12 @@ class ServerService extends EquipmentService } return $options; } + //FieldForm관련용 //create용 장비코드 마지막번호 가져오기 final public function getLastestCode(string $format, int $default): string { return $this->getModel()->getLastestCode($format, $default); } - - //Server Part별 저장 - public function createServerParts(ServerEntity $entity, array $partDatas): array - { - $serverPartEntities = []; - foreach (self::BaseParts as $basePart) { - $partDatas[$basePart]["serverinfo_uid"] = $entity->getPK(); - $partDatas[$basePart]["serviceinfo_uid"] = $entity->getServiceInfoUID(); - $serverPartEntities[] = $this->getServerPartModel()->create($partDatas[$basePart]); - } - return $serverPartEntities; - } - //Server Part별 정보가져오기 - public function getServerParts(ServerEntity $entity): array - { - $sql = "SELECT serverinfo_partinfo.*,partinfo.title as title,partinfo.price,partinfo.type FROM serverinfo_partinfo - LEFT JOIN partinfo ON serverinfo_partinfo.partinfo_uid = partinfo.uid - WHERE serverinfo_partinfo.serverinfo_uid = ?"; - return $this->getModel()->query($sql, [$entity->getPK()])->getResult(); - } - //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void