addClassName('Server'); } public function getFormFields(): array { return [ 'fields' => [ "code", "type", "title", "partinfo_cpu_uid", "partinfo_ram_uid", "partinfo_disk_uid", "partinfo_os_uid", "price", "amount", "manufactur_at", "format_at", "status", ], 'filters' => [ "clientinfo_uid", "serviceinfo_uid", "type", "title", "partinfo_cpu_uid", "partinfo_ram_uid", "partinfo_disk_uid", "partinfo_os_uid", "status" ], ]; } public function getIndexFields(): array { return [ 'fields' => [ 'clientinfo_uid', 'serviceinfo_uid', "type", 'title', "partinfo_uid", 'price', 'amount', 'manufactur_at', "format_at", 'status' ], 'filters' => ['clientinfo_uid', 'serviceinfo_uid', 'type', 'partinfo_uid', 'status'], ]; } public function getBatchjobFields(): array { return ['clientinfo_uid', 'partinfo_uid', 'status']; } final public function getPartService(): PartService { if (!$this->_partService) { $this->_partService = new PartService(); } return $this->_partService; } final public function getIPService(): IPService { if (!$this->_ipService) { $this->_ipService = new IPService(); } return $this->_ipService; } final public function getCSService(): CSService { if (!$this->_csService) { $this->_csService = new CSService(); } 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']); 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; case 'ipinfo_uid': //수정때문에 전체가 필요 $options = $this->getIPService()->getEntities(); break; case 'csinfo_uid': //수정때문에 전체가 필요 $options = $this->getCSService()->getEntities(); break; default: $options = parent::getFormFieldOption($field, $options); break; } return $options; } //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 { $this->getModel()->orderBy("code ASC,title ASC"); parent::setOrderBy($field, $value); } }