dbmsv4/app/Services/Equipment/ServerPartService.php
2025-11-19 10:18:16 +09:00

96 lines
3.5 KiB
PHP

<?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 조건절 처리
//검색어조건절처리
}