From 571468dfc689393b42575d2e8f34f0b341df726a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0git=20config=20git=20config=20-?= =?UTF-8?q?-helpgit=20config=20--global=20user=2Ename=20=EC=B5=9C=EC=A4=80?= =?UTF-8?q?=ED=9D=A0?= Date: Thu, 3 Aug 2023 03:36:33 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Config/Routes.php | 48 ++---------------------- app/Controllers/Admin/UserController.php | 24 ++++++++++++ app/Controllers/BaseController.php | 20 +--------- app/Models/BaseModel.php | 8 ++++ app/Views/admin/board/index.php | 8 ++-- app/Views/admin/boardconfig/index.php | 8 ++-- app/Views/admin/category/index.php | 8 ++-- app/Views/admin/order/index.php | 2 +- app/Views/admin/product/index.php | 8 ++-- app/Views/admin/user/index.php | 8 ++-- app/Views/admin/usersns/index.php | 8 ++-- app/Views/front/board/index.php | 2 +- app/Views/layouts/front/top_menu.php | 14 +++++++ 13 files changed, 76 insertions(+), 90 deletions(-) create mode 100644 app/Views/layouts/front/top_menu.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 9a142d2..1f05cb0 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -39,9 +39,9 @@ $routes->get('/login', 'AuthController::login'); $routes->post('/signup', 'AuthController::signup/local'); $routes->get('/signup/(:alpha)', 'AuthController::signup/$1'); $routes->get('/logout', 'AuthController::logout'); -$routes->group('ecommerce', ['namespace' => 'App\Controllers'], static function ($routes) { - $routes->post('addCart', 'EcommerceController::addCart'); - $routes->get('cancelCart/(:uuid)', 'EcommerceController::cancelCart/$1'); +$routes->group('cart', ['namespace' => 'App\Controllers'], static function ($routes) { + $routes->post('addCart', 'CartController::addCart'); + $routes->get('cancelCart/(:uuid)', 'CartController::cancelCart/$1'); });; $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) { }); @@ -95,39 +95,6 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au $routes->post('batchjob', 'BoardController::batchjob'); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); - $routes->group('category', static function ($routes) { - $routes->get('', 'CategoryController::index'); - $routes->get('excel', 'CategoryController::excel/$1'); - $routes->get('insert', 'CategoryController::insert_form'); - $routes->post('insert', 'CategoryController::insert'); - $routes->get('update/(:num)', 'CategoryController::update_form/$1'); - $routes->post('update/(:num)', 'CategoryController::update/$1'); - $routes->get('view/(:num)', 'CategoryController::view/$1'); - $routes->get('reply/(:num)', 'CategoryController::reply_form/$1'); - $routes->post('reply/(:num)', 'CategoryController::reply/$1'); - $routes->get('delete/(:num)', 'CategoryController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:num)/(:hash)', 'CategoryController::toggle/$1/$2'); - $routes->post('batchjob', 'CategoryController::batchjob'); - }); - $routes->group('product', static function ($routes) { - $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); - $routes->get('insert', 'ProductController::insert_form'); - $routes->post('insert', 'ProductController::insert'); - $routes->get('update/(:uuid)', 'ProductController::update_form/$1'); - $routes->post('update/(:uuid)', 'ProductController::update/$1'); - $routes->get('view/(:uuid)', 'ProductController::view/$1'); - $routes->get('delete/(:uuid)', 'ProductController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'ProductController::toggle/$1/$2'); - $routes->post('batchjob', 'ProductController::batchjob'); - }); - $routes->group('order', static function ($routes) { - $routes->get('', 'OrderController::index'); - $routes->get('view/(:uuid)', 'OrderController::view/$1'); - $routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']); - $routes->get('toggle/(:uuid)/(:hash)', 'OrderController::toggle/$1/$2'); - $routes->post('batchjob', 'OrderController::batchjob`'); - }); }); $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) { @@ -148,15 +115,6 @@ $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($rou $routes->get('delete/(:num)', 'BoardController::delete/$1', ['filter' => 'authFilter:master']); $routes->get('download/(:any)/(:num)', 'BoardController::download/$1/$2'); }); - $routes->group('product', static function ($routes) { - $routes->get('', 'ProductController::index'); - $routes->get('excel', 'ProductController::excel/$1'); - $routes->get('view/(:uuid)', 'ProductController::view/$1'); - }); - $routes->group('order', static function ($routes) { - $routes->get('', 'OrderController::index'); - $routes->get('view/(:uuid)', 'OrderController::view/$1'); - });; }); /* * -------------------------------------------------------------------- diff --git a/app/Controllers/Admin/UserController.php b/app/Controllers/Admin/UserController.php index 87f01db..e15d814 100644 --- a/app/Controllers/Admin/UserController.php +++ b/app/Controllers/Admin/UserController.php @@ -61,4 +61,28 @@ class UserController extends AdminController { return parent::getFieldBatchFilters(); } + + protected function insert_validate() + { + $rules = []; + foreach ($this->_viewDatas['fieldRules'] as $field => $rule) { + switch ($field) { + case 'role': + $rules['role.*'] = $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/Controllers/BaseController.php b/app/Controllers/BaseController.php index 552d2c0..36cb928 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -3,7 +3,6 @@ namespace App\Controllers; -use App\Models\UserModel; use CodeIgniter\Controller; use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\Files\UploadedFile; @@ -70,23 +69,6 @@ abstract class BaseController extends Controller { return $this->getFieldFilters(); } - protected function getFieldRule(string $field, array $rules, string $action = ""): array - { - switch ($field) { - default: - $rules = $this->_model->getFieldRule($field, $rules, $action); - break; - } - return $rules; - } - final public function getFieldRules(array $fields, string $action = ""): array - { - $rules = array(); - foreach ($fields as $field) { - $rules = $this->getFieldRule($field, $rules, $action); - } - return $rules; - } //Field별 Form Datas 처리용 protected function getFieldFormData(string $field, $entity = null): array { @@ -144,7 +126,7 @@ abstract class BaseController extends Controller break; } $this->_viewDatas['fields'] = $fields ?: $this->getFields($action); - $this->_viewDatas['fieldRules'] = $this->getFieldRules($this->_viewDatas['fields'], $action); + $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], $action); $this->_viewDatas['fieldFilters'] = $this->getFieldFilters(); $this->_viewDatas['batchjobFilters'] = $this->getFieldBatchFilters(); $this->_viewDatas['fieldFormOptions'] = $this->_model->getFieldFormOptions($this->_viewDatas['fieldFilters']); diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index c2fe284..f57d605 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -106,6 +106,14 @@ abstract class BaseModel extends Model } return $rules; } + final public function getFieldRules(array $fields, string $action = ""): array + { + $rules = array(); + foreach ($fields as $field) { + $rules = $this->getFieldRule($field, $rules, $action); + } + return $rules; + } //Field별 Form Option용 public function getOptions(array $conditions = array(), $options = array()): array { diff --git a/app/Views/admin/board/index.php b/app/Views/admin/board/index.php index 4737b03..0e4ec9b 100644 --- a/app/Views/admin/board/index.php +++ b/app/Views/admin/board/index.php @@ -9,7 +9,7 @@ - + @@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/boardconfig/index.php b/app/Views/admin/boardconfig/index.php index 8168605..3e28890 100644 --- a/app/Views/admin/boardconfig/index.php +++ b/app/Views/admin/boardconfig/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/category/index.php b/app/Views/admin/category/index.php index 08b5334..9f35470 100644 --- a/app/Views/admin/category/index.php +++ b/app/Views/admin/category/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/order/index.php b/app/Views/admin/order/index.php index a196f32..020703d 100644 --- a/app/Views/admin/order/index.php +++ b/app/Views/admin/order/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
diff --git a/app/Views/admin/product/index.php b/app/Views/admin/product/index.php index c0aa53b..f4cc3d1 100644 --- a/app/Views/admin/product/index.php +++ b/app/Views/admin/product/index.php @@ -9,7 +9,7 @@ - +
번호
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/user/index.php b/app/Views/admin/user/index.php index 67f1860..57e6a6a 100644 --- a/app/Views/admin/user/index.php +++ b/app/Views/admin/user/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/admin/usersns/index.php b/app/Views/admin/usersns/index.php index 4294d44..b4a08b9 100644 --- a/app/Views/admin/usersns/index.php +++ b/app/Views/admin/usersns/index.php @@ -9,7 +9,7 @@ - +
번호
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
@@ -21,12 +21,12 @@ getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - + @@ -36,7 +36,7 @@ - + diff --git a/app/Views/front/board/index.php b/app/Views/front/board/index.php index cc70ffd..5637821 100644 --- a/app/Views/front/board/index.php +++ b/app/Views/front/board/index.php @@ -19,7 +19,7 @@ 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(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?>
get(SESSION_NAMES['ISLOGIN']) && $entity->getUser_Uid() == $session->get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['ID']]) : ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> diff --git a/app/Views/layouts/front/top_menu.php b/app/Views/layouts/front/top_menu.php new file mode 100644 index 0000000..cac30be --- /dev/null +++ b/app/Views/layouts/front/top_menu.php @@ -0,0 +1,14 @@ + \ No newline at end of file