cfmgrv4 init...3

This commit is contained in:
최준흠 2024-10-23 19:45:07 +09:00
parent a4c262bfaf
commit 36322a95de
3 changed files with 63 additions and 8 deletions

View File

@ -77,7 +77,9 @@ abstract class MVController extends CommonController
return $formDatas;
}
// 생성
protected function create_form_process(): void {}
protected function create_form_process(): void
{
}
final protected function create_form_procedure(): RedirectResponse|string
{
try {
@ -108,7 +110,7 @@ abstract class MVController extends CommonController
{
$this->create_validate($this->action, $this->fields);
$this->formDatas = $this->getFormDatas();
$this->entity = $this->getModel()->create(formDatas: $this->formDatas);
$this->entity = $this->getModel()->create($this->formDatas);
}
protected function create_process_result(): RedirectResponse|string
{

10
app/Services/Common.php Normal file
View File

@ -0,0 +1,10 @@
<?php
namespace App\Services;
abstract class Common
{
public function __construct()
{
}
}

43
app/Services/User.php Normal file
View File

@ -0,0 +1,43 @@
<?php
namespace App\Services;
use App\Models\UserModel;
use App\Entities\UserEntity;
class User extends Common
{
private ?UserModel $_model = null;
public function __construct()
{
parent::__construct();
}
public function getModel(): UserModel
{
if ($this->_model === null) {
$this->_model = new UserModel();
}
return $this->_model;
}
public function find(array $wheres): ?UserEntity
{
return $this->getModel()->where($wheres)->first();
}
public function findAll(array $wheres = []): array
{
return $this->getModel()->where($wheres)->findAll();
}
public function create(array $formDatas): UserEntity
{
return $this->getModel()->create($formDatas);
}
public function modify(UserEntity $entity, array $formDatas): UserEntity
{
return $this->getModel()->modify($entity, $formDatas);
}
public function delete(array $wheres): void
{
$this->getModel()->where($wheres)->delete();
}
}