diff --git a/app/Config/Constants.php b/app/Config/Constants.php index 6ce8761..b10f32b 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -114,6 +114,7 @@ define('LAYOUTS', [ '', '', '', + '', '', ], 'javascripts' => [ @@ -132,7 +133,6 @@ define('LAYOUTS', [ '', '', '', - '', '', ], 'javascripts' => [ diff --git a/app/Config/Routes.php b/app/Config/Routes.php index a47bd6c..4e79d54 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -98,9 +98,9 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:master,director,cloudflare,manager,gold,silver,brone,vip,user'], static function ($routes) { - $routes->get('update', 'UserController::update_form'); - $routes->post('update', 'UserController::update'); - $routes->get('view', 'UserController::view'); + $routes->get('update/(:uuid)', 'UserController::update_form/$1'); + $routes->post('update/(:uuid)', 'UserController::update/R1'); + $routes->get('view/(:uuid)', 'UserController::view/$1'); }); $routes->group('board', static function ($routes) { $routes->get('', 'BoardController::index'); diff --git a/app/Controllers/Front/UserController.php b/app/Controllers/Front/UserController.php new file mode 100644 index 0000000..17f52fa --- /dev/null +++ b/app/Controllers/Front/UserController.php @@ -0,0 +1,84 @@ +_model = new UserModel(); + parent::initController($request, $response, $logger); + $this->_viewDatas['title'] = lang($this->_model->getClassName() . '.title'); + $this->_viewPath .= strtolower($this->_model->getClassName()); + helper($this->_model->getClassName()); + } + + //Field별 Form Datas 처리용 + protected function getFieldFormData(string $field, $entity = null): array + { + switch ($field) { + case 'passwd': + $this->_viewDatas['fieldDatas'][$field] = $this->request->getVar($field); + $this->_viewDatas['fieldDatas']['confirmpassword'] = $this->request->getVar('confirmpassword'); + break; + default: + return parent::getFieldFormData($field, $entity); + break; + } + return $this->_viewDatas['fieldDatas']; + } + + public function getFields(string $action = ""): array + { + $fields = ["id", "passwd", 'name', "email", "role", "status"]; + switch ($action) { + case "index": + case "excel": + return ["id", 'name', "email", "role", "status", 'created_at']; + break; + case "view": + return ["id", 'name', "email", "role", "status", 'updated_at', 'created_at']; + break; + default: + return $fields; + break; + } + } + public function getFieldFilters(): array + { + return ["role", "status"]; + } + public function getFieldBatchFilters(): array + { + return parent::getFieldBatchFilters(); + } + + protected function insert_validate() + { + $rules = []; + foreach ($this->_viewDatas['fieldRules'] as $field => $rule) { + switch ($field) { + case 'role': + $rules[$field . '.*'] = $rule; + break; + default: + $rules[$field] = $rule; + break; + } + } + //fieldData Rule 검사 + if (!$this->validate($rules)) { + throw new \Exception("{$this->_viewDatas['title']}의 검증 오류발생\n" . implode("\n", $this->validator->getErrors())); + } + //fieldData 적용 + $this->_viewDatas['fieldDatas'] = array(); + foreach ($this->_viewDatas['fields'] as $field) { + $this->_viewDatas['fieldDatas'] = $this->getFieldFormData($field); + } + } +} diff --git a/app/Views/front/user/index.php b/app/Views/front/user/index.php new file mode 100644 index 0000000..57e6a6a --- /dev/null +++ b/app/Views/front/user/index.php @@ -0,0 +1,45 @@ +extend('layouts/admin') ?> +section('content') ?> +
+
+ "get")) ?> + + +
+ + + + + + + + + + getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> + + + + + + + + +
번호작업
+ "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
+
+ + +
+ +
+endSection() ?> \ No newline at end of file diff --git a/app/Views/front/user/update.php b/app/Views/front/user/update.php new file mode 100644 index 0000000..f83e3b3 --- /dev/null +++ b/app/Views/front/user/update.php @@ -0,0 +1,21 @@ +extend('layouts/admin') ?> +section('content') ?> +
+ + + + + + + + + + + +
+ $field), $fieldFormOptions) ?> + +
"btn btn-outline btn-primary")); ?>
+
+ +endSection() ?> \ No newline at end of file diff --git a/app/Views/front/user/view.php b/app/Views/front/user/view.php new file mode 100644 index 0000000..a812e5d --- /dev/null +++ b/app/Views/front/user/view.php @@ -0,0 +1,16 @@ +extend('layouts/admin') ?> +section('content') ?> +
+ + + + + + + +
+ + +
+
+endSection() ?> \ No newline at end of file diff --git a/app/Views/layouts/front.php b/app/Views/layouts/front.php index 3e24c52..79a35e9 100644 --- a/app/Views/layouts/front.php +++ b/app/Views/layouts/front.php @@ -12,8 +12,8 @@ - - + +