From 36322a95de5378d69802e70a71c24a604aa2a777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Wed, 23 Oct 2024 19:45:07 +0900 Subject: [PATCH] cfmgrv4 init...3 --- app/Controllers/MVController.php | 18 +++++++------ app/Services/Common.php | 10 ++++++++ app/Services/User.php | 43 ++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 app/Services/Common.php create mode 100644 app/Services/User.php diff --git a/app/Controllers/MVController.php b/app/Controllers/MVController.php index d9a4331..b114a79 100644 --- a/app/Controllers/MVController.php +++ b/app/Controllers/MVController.php @@ -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 { @@ -124,7 +126,7 @@ abstract class MVController extends CommonController $this->create_process(); $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 생성작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); return $this->create_process_result(); } catch (\Exception $e) { //Transaction Rollback @@ -192,7 +194,7 @@ abstract class MVController extends CommonController $this->modify_process($uid); $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 수정작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); return $this->modify_process_result(); } catch (\Exception $e) { //Transaction Rollback @@ -225,7 +227,7 @@ abstract class MVController extends CommonController } $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 일괄처리작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); // 이전 URL로 리다이렉트 return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message); } catch (\Exception $e) { @@ -246,7 +248,7 @@ abstract class MVController extends CommonController $this->modify_process($uid); $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 단일필드작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); // 이전 URL로 리다이렉트 return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message); } catch (\Exception $e) { @@ -302,7 +304,7 @@ abstract class MVController extends CommonController $this->delete_process($uid); $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 삭제작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); // 이전 URL로 리다이렉트 return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message); } catch (\Exception $e) { @@ -328,7 +330,7 @@ abstract class MVController extends CommonController } $this->getModel()->transCommit(); $this->message = "{$this->class_name} : 일괄삭제처리작업이 완료되었습니다."; - log_message("notice", $this->message); + log_message("notice", $this->message); // 이전 URL로 리다이렉트 return redirect()->to($this->myauth->popPreviousUrl())->with('error', $this->message); } catch (\Exception $e) { diff --git a/app/Services/Common.php b/app/Services/Common.php new file mode 100644 index 0000000..7737694 --- /dev/null +++ b/app/Services/Common.php @@ -0,0 +1,10 @@ +_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(); + } +}