From adbf052a1234f1ab1228fc7cf5545199e84c4913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Mon, 31 Jul 2023 16:58:22 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Backend/BaseBackend.php | 4 +- app/Backend/CartgoryBackend.php | 16 +++ app/Backend/OrderBackend.php | 78 ++++++++++++ app/Backend/ProductBackend.php | 41 ++++++ app/Config/Routes.php | 36 ++++++ app/Config/Services.php | 21 +++ app/Config/Services_Shoppingmall.php | 81 ++++++++++++ .../Admin/AdminHierarchyController.php | 64 ---------- app/Controllers/Admin/CategoryController.php | 11 +- app/Controllers/Admin/OrderController.php | 120 ++---------------- app/Controllers/Admin/ProductController.php | 36 +----- app/Models/CategoryModel.php | 22 ++-- app/Models/OrderModel.php | 2 +- app/Models/ProductModel.php | 12 +- app/Views/admin/category/reply.php | 1 - app/Views/admin/order/index.php | 3 +- app/Views/admin/product/view.php | 19 ++- app/Views/layouts/admin/left_menu.php | 1 + .../layouts/admin/left_menu_shoppingmall.php | 10 ++ 19 files changed, 336 insertions(+), 242 deletions(-) create mode 100644 app/Backend/CartgoryBackend.php create mode 100644 app/Backend/OrderBackend.php create mode 100644 app/Backend/ProductBackend.php create mode 100644 app/Config/Services_Shoppingmall.php delete mode 100644 app/Controllers/Admin/AdminHierarchyController.php create mode 100644 app/Views/layouts/admin/left_menu_shoppingmall.php diff --git a/app/Backend/BaseBackend.php b/app/Backend/BaseBackend.php index 3ae6eb8..e13ec67 100644 --- a/app/Backend/BaseBackend.php +++ b/app/Backend/BaseBackend.php @@ -2,8 +2,8 @@ namespace App\Backend; -use App\Models\UserModel; use App\Entities\BaseEntity; +use App\Models\UserModel; use CodeIgniter\HTTP\Files\UploadedFile; abstract class BaseBackend @@ -25,7 +25,7 @@ abstract class BaseBackend } //User모델 - final protected function getUserModel(): UserModel + final public function getUserModel(): UserModel { return is_null($this->_userModel) ? new UserModel() : $this->_userModel; } diff --git a/app/Backend/CartgoryBackend.php b/app/Backend/CartgoryBackend.php new file mode 100644 index 0000000..661ea5f --- /dev/null +++ b/app/Backend/CartgoryBackend.php @@ -0,0 +1,16 @@ +_model = new CategoryModel(); + } +} diff --git a/app/Backend/OrderBackend.php b/app/Backend/OrderBackend.php new file mode 100644 index 0000000..be4fa74 --- /dev/null +++ b/app/Backend/OrderBackend.php @@ -0,0 +1,78 @@ +_model = new OrderModel(); + } + + //Porduct모델 + final public function getProductModel(): ProductModel + { + return is_null($this->_productModel) ? new ProductModel() : $this->_productModel; + } + + //Field별 Form Option용 + public function getFieldFormOption(string $field): array + { + switch ($field) { + case 'product_uid': + $options = $this->_product_uids = $this->_product_uids ?: $this->getProductModel()->getFieldFormOptions([]); + break; + default: + return parent::getFieldFormOption($field); + break; + } + if (!is_array($options)) { + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + } + return $options; + } + + //Insert관련 //장바구니에 담기 및 Product 재고 차감 + public function insert(array $fieldDatas): OrderEntity + { + //상품정보가져오기 + $product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $fieldDatas['product_uid']]); + if (!$fieldDatas['quantity']) { + throw new \Exception("제품 구매수량을 확인해주세요"); + } + if (!$fieldDatas['price']) { + throw new \Exception("제품 구매금액을 확인해주세요"); + } + if ($product->getStock() < $fieldDatas['quantity']) { + throw new \Exception(sprintf( + "%s의 재고수[%s]보다 많은 수량[%s]을 주문하셨습니다.\\n", + $product->getTitle(), + $product->getStock(), + $fieldDatas['quantity'] + )); + } + //구매금액 = (판매가-할인가)*구매수량과 맞는지 다시 확인. + // $calculated_price = ($product->getPrice() - $product->getSale()) * $quantity; + $calculated_price = ($product->getPrice() - $product->getSale()) * $fieldDatas['quantity']; + if ($fieldDatas['price'] != $calculated_price) { + throw new \Exception( + sprintf( + "%s상품의 구매금액[%s원]과 판매금액[%s원]이 맞지않습니다.", + $product->getTitle(), + number_format($fieldDatas['price']), + number_format($calculated_price) + ) + ); + } + //상품모델에서 Order에 담은 갯수만큼 재고에서 뺀다. + $this->getProductModel()->decreaseStock($product, $fieldDatas['quantity']); + return parent::insert($fieldDatas); + } +} diff --git a/app/Backend/ProductBackend.php b/app/Backend/ProductBackend.php new file mode 100644 index 0000000..834cd26 --- /dev/null +++ b/app/Backend/ProductBackend.php @@ -0,0 +1,41 @@ +_model = new ProductModel(); + } + + //Category모델 + final protected function getCategoryModel(): CategoryModel + { + return is_null($this->_categoryModel) ? new CategoryModel() : $this->_categoryModel; + } + + //Field별 Form Option용 + public function getFieldFormOption(string $field): array + { + switch ($field) { + case 'category_uid': + $options = $this->_category_uids = $this->_category_uids ?: $this->getCategoryModel()->getFieldFormOptions(['status' => 'use']); + break; + default: + return parent::getFieldFormOption($field); + break; + } + if (!is_array($options)) { + throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); + } + return $options; + } +} diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 0a684af..52e74cb 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -91,6 +91,42 @@ $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('reply/(:uuid)', 'ProductController::reply_form/$1'); + $routes->post('reply/(:uuid)', 'ProductController::reply/$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->get('download/(:any)/(:uuid)', 'ProductController::download/$1/$2'); + }); + $routes->group('order', static function ($routes) { + $routes->get('', 'OrderController::index'); + $routes->post('insert/(:uuid)', 'OrderController::insert/$1'); + $routes->get('view/(:uuid)', 'OrderController::view/$1'); + $routes->post('batchjob', 'OrderController::batchjob`'); + $routes->get('delete/(:uuid)', 'OrderController::delete/$1', ['filter' => 'authFilter:master']); + }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { $routes->get('/', 'Home::index'); diff --git a/app/Config/Services.php b/app/Config/Services.php index 9c71556..7d2eca1 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -57,4 +57,25 @@ class Services extends BaseService } return new \App\Backend\BoardConfigBackend(); } + public static function category($getShared = true) + { + if ($getShared) { + return static::getSharedInstance('category'); + } + return new \App\Backend\CategoryBackend(); + } + public static function prodcut($getShared = true) + { + if ($getShared) { + return static::getSharedInstance('product'); + } + return new \App\Backend\ProductBackend(); + } + public static function order($getShared = true) + { + if ($getShared) { + return static::getSharedInstance('order'); + } + return new \App\Backend\OrderBackend(); + } } diff --git a/app/Config/Services_Shoppingmall.php b/app/Config/Services_Shoppingmall.php new file mode 100644 index 0000000..7d2eca1 --- /dev/null +++ b/app/Config/Services_Shoppingmall.php @@ -0,0 +1,81 @@ +update_form_process($entity); - } - final public function reply_form($uid) - { - try { - $entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); - $this->_viewDatas['fields'] = $this->_model->getFields('reply'); - $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'reply'); - $this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters(); - $this->_viewDatas['entity'] = $this->reply_form_process($entity); - $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); - return view($this->_viewPath . '/update', $this->_viewDatas); - } catch (\Exception $e) { - return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']))->with('return_message', $e->getMessage()); - } - } - protected function reply_validate($entity) - { - return $this->update_validate($entity); - } - protected function reply_process($entity) - { - return $this->_model->reply($entity, $this->_viewDatas['fieldDatas']); - } - public function reply($uid) - { - $msg = ""; - try { - $entity = $entity = $this->_model->getEntity([$this->_model->getPrimaryKey() => $uid]); - $this->_viewDatas['fields'] = $this->_model->getFields('reply'); - $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'reply'); - $this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters(); - $entity = $this->reply_validate($entity); - $entity = $this->reply_process($entity); - $msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 완료하였습니다."; - return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); - } catch (\Exception $e) { - $msg = "{$this->_viewDatas['title']}에서 " . __FUNCTION__ . " 실패하였습니다.\n" . $e->getMessage(); - log_message("error", $e->getMessage()); - log_message("error", var_export($this->_viewDatas['fieldDatas'], true)); - return redirect()->back()->withInput(); - } finally { - $this->_session->setFlashdata("return_message", $msg); - } - } -} diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php index 9e16e66..3bb1a71 100644 --- a/app/Controllers/Admin/CategoryController.php +++ b/app/Controllers/Admin/CategoryController.php @@ -2,21 +2,16 @@ namespace App\Controllers\Admin; -use App\Models\CategoryModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -class CategoryController extends AdminHierarchyController +class CategoryController extends AdminController { public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { + $this->_backend = service('category'); parent::initController($request, $response, $logger); - $this->_className .= 'Category'; - $this->_model = new CategoryModel(); - helper($this->_className); - $this->_viewPath .= strtolower($this->_className); - $this->_viewDatas['title'] = lang($this->_className . '.title'); - $this->_viewDatas['className'] = $this->_className; + $this->_viewPath .= strtolower($this->_backend->getClassName()); } } diff --git a/app/Controllers/Admin/OrderController.php b/app/Controllers/Admin/OrderController.php index 0830052..58940f9 100644 --- a/app/Controllers/Admin/OrderController.php +++ b/app/Controllers/Admin/OrderController.php @@ -2,85 +2,18 @@ namespace App\Controllers\Admin; -use App\Entities\OrderEntity; -use App\Models\OrderModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Models\ProductModel; class OrderController extends AdminController { - private $_productModel = null; - private $_product_uids = array(); + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { + $this->_backend = service('order'); parent::initController($request, $response, $logger); - $this->_className .= 'Order'; - $this->_model = new OrderModel(); - helper($this->_className); - $this->_viewPath .= strtolower($this->_className); - $this->_viewDatas['title'] = lang($this->_className . '.title'); - $this->_viewDatas['className'] = $this->_className; - } - //Porduct모델 - final protected function getProductModel(): ProductModel - { - return is_null($this->_productModel) ? new ProductModel() : $this->_productModel; - } - - //Field별 Form Option용 - protected function getFieldFormOption(string $field): array - { - switch ($field) { - case 'product_uid': - $options = $this->_product_uids = $this->_product_uids ?: $this->getProductModel()->getFieldFormOptions([]); - break; - default: - return parent::getFieldFormOption($field); - break; - } - if (!is_array($options)) { - throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); - } - return $options; - } - - //구매상품검사 - protected function insert_process(): OrderEntity - { - //상품정보가져오기 - $product = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $this->_viewDatas['fieldDatas']['product_uid']]); - if (!$this->_viewDatas['fieldDatas']['quantity']) { - throw new \Exception("제품 구매수량을 확인해주세요"); - } - if (!$this->_viewDatas['fieldDatas']['price']) { - throw new \Exception("제품 구매금액을 확인해주세요"); - } - if ($product->getStock() < $this->_viewDatas['fieldDatas']['quantity']) { - throw new \Exception(sprintf( - "%s의 재고수[%s]보다 많은 수량[%s]을 주문하셨습니다.\\n", - $product->getTitle(), - $product->getStock(), - $this->_viewDatas['fieldDatas']['quantity'] - )); - } - //구매금액 = (판매가-할인가)*구매수량과 맞는지 다시 확인. - // $calculated_price = ($product->getPrice() - $product->getSale()) * $quantity; - $calculated_price = ($product->getPrice() - $product->getSale()) * $this->_viewDatas['fieldDatas']['quantity']; - if ($this->_viewDatas['fieldDatas']['price'] != $calculated_price) { - throw new \Exception( - sprintf( - "%s상품의 구매금액[%s원]과 판매금액[%s원]이 맞지않습니다.", - $product->getTitle(), - number_format($this->_viewDatas['fieldDatas']['price']), - number_format($calculated_price) - ) - ); - } - //상품모델에서 Order에 담은 갯수만큼 재고에서 뺀다. - $this->getProductModel()->decreaseStock($product, $this->_viewDatas['fieldDatas']['quantity']); - return parent::insert_process(); + $this->_viewPath .= strtolower($this->_backend->getClassName()); } //장바구니에 담기 @@ -88,24 +21,22 @@ class OrderController extends AdminController { $msg = ""; try { - $this->_viewDatas['fields'] = $this->_model->getFields('insert'); - $this->_viewDatas['fieldRules'] = $this->_model->getFieldRules($this->_viewDatas['fields'], 'insert'); - $this->_viewDatas['fieldFilters'] = $this->_model->getFieldFilters(); - $this->insert_validate(); + $this->_viewDatas = $this->init(__FUNCTION__); //Transaction manully 시작 - $this->_model->transBegin(); + $this->_backend->transBegin(); $this->insert_process(); + $entity = $this->_backend->insert($this->_viewDatas['fieldDatas']); //Transaction manully Commit - $this->_model->transCommit(); + $this->_backend->transCommit(); $msg = sprintf( - "%s에서 상품 %s개를 장바구니에 담았습니다.", + "%s에서 %s상품 %s개를 장바구니에 담았습니다.", $this->_viewDatas['title'], + $entity->getTtile(), $this->_viewDatas['fieldDatas']['quantity'] ); - return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); } catch (\Exception $e) { //Transaction manully Rollback - $this->_model->transRollback(); + $this->_backend->transRollback(); $msg = sprintf( "%s에서 다음 오류로 인해 장바구니에 담기를 실패하였습니다.\n%s", $this->_viewDatas['title'], @@ -113,40 +44,17 @@ class OrderController extends AdminController ); log_message("error", $e->getMessage()); log_message("error", var_export($this->_viewDatas['fieldDatas'], true)); - return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); } finally { $this->_session->setFlashdata("return_message", $msg); + return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL'])); } } - - - - - - - - - - - - - - - - - - - - - - - //View관련 protected function view_process($entity) { - $this->_viewDatas['user'] = $this->getUserModel()->getEntity([$this->getUserModel()->getPrimaryKey() => $entity->getUser_uid()]); - $this->_viewDatas['product'] = $this->getProductModel()->getEntity([$this->getProductModel()->getPrimaryKey() => $entity->getProduct_uid()]); - return $entity; + $this->_viewDatas['user'] = $this->_backend->getUserModel()->getEntity([$this->_backend->getUserModel()->getPrimaryKey() => $entity->getUser_uid()]); + $this->_viewDatas['product'] = $this->_backend->getProductModel()->getEntity([$this->_backend->getProductModel()->getPrimaryKey() => $entity->getProduct_uid()]); + return parent::view_process($entity); } } diff --git a/app/Controllers/Admin/ProductController.php b/app/Controllers/Admin/ProductController.php index 87db3d2..fcb9fe6 100644 --- a/app/Controllers/Admin/ProductController.php +++ b/app/Controllers/Admin/ProductController.php @@ -2,48 +2,18 @@ namespace App\Controllers\Admin; -use App\Models\CategoryModel; -use App\Models\ProductModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; class ProductController extends AdminController { - private $_categoryModel = null; - private $_category_uids = null; + public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { + $this->_backend = service('product'); parent::initController($request, $response, $logger); - $this->_className .= 'Product'; - $this->_model = new ProductModel(); - helper($this->_className); - $this->_viewPath .= strtolower($this->_className); - $this->_viewDatas['title'] = lang($this->_className . '.title'); - $this->_viewDatas['className'] = $this->_className; - } - - //Category모델 - final protected function getCategoryModel(): CategoryModel - { - return is_null($this->_categoryModel) ? new CategoryModel() : $this->_categoryModel; - } - - //Field별 Form Option용 - protected function getFieldFormOption(string $field): array - { - switch ($field) { - case 'category_uid': - $options = $this->_category_uids = $this->_category_uids ?: $this->getCategoryModel()->getFieldFormOptions(['status' => 'use']); - break; - default: - return parent::getFieldFormOption($field); - break; - } - if (!is_array($options)) { - throw new \Exception(__FUNCTION__ . "에서 {$this->_className}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true)); - } - return $options; + $this->_viewPath .= strtolower($this->_backend->getClassName()); } //Field별 Form Datas 처리용 diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index 70d0b82..b4750bd 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -15,20 +15,24 @@ class CategoryModel extends BaseHierarchyModel $this->allowedFields = [...$this->allowedFields, ...$this->getFields(),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } - public function getTitle(): string + public function getTitleField(): string { return 'name'; } + public function getContentField(): string + { + return 'head'; + } public function getFields(string $action = ""): array { - $fields = [$this->getTitle(), "status", "head", "tail",]; + $fields = [$this->getTitleField(), "status", "head", "tail",]; switch ($action) { case "index": case "excel": - return [$this->getTitle(), "status", "created_at"]; + return [$this->getTitleField(), "status", "created_at"]; break; case "view": - return [$this->getTitle(), "status", "created_at", "head", "tail",]; + return [$this->getTitleField(), "status", "created_at", "head", "tail",]; break; default: return $fields; @@ -46,7 +50,7 @@ class CategoryModel extends BaseHierarchyModel protected function getFieldRule(string $field, array $rules, string $action = ""): array { switch ($field) { - case $this->getTitle(): + case $this->getTitleField(): $rules[$field] = "required|trim|string"; break; case "head": @@ -70,10 +74,10 @@ class CategoryModel extends BaseHierarchyModel $old_title = ""; foreach ($this->where($conditions)->orderby("grpno DESC, grporder ASC")->findAll() as $entity) { if ($entity->getPrimaryKey() == $entity->getHierarchy_No()) { - $options[$entity->getTitle()] = []; - $old_title = $entity->getTitle(); + $options[$entity->getTitleField()] = []; + $old_title = $entity->getTitleField(); } else { - $options[$old_title][$entity->getPrimaryKey()] = $entity->getTitle(); + $options[$old_title][$entity->getPrimaryKey()] = $entity->getTitleField(); } } return $options; @@ -96,7 +100,7 @@ class CategoryModel extends BaseHierarchyModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitle(), $word, "both"); + $this->orLike($this->getTitleField(), $word, "both"); $this->orLike("head", $word, "both"); //befor , after , both $this->orLike("tail", $word, "both"); //befor , after , both } diff --git a/app/Models/OrderModel.php b/app/Models/OrderModel.php index 98ef368..787fc4c 100644 --- a/app/Models/OrderModel.php +++ b/app/Models/OrderModel.php @@ -16,7 +16,7 @@ class OrderModel extends BaseModel $this->allowedFields = ["uid", "user_uid", "sess_id", ...$this->allowedFields, ...$this->getFields(),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } - final public function getTitle(): string + final public function getTitleField(): string { return 'product_uid'; } diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index b8164e0..a7e48a5 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -16,17 +16,17 @@ class ProductModel extends BaseModel $this->allowedFields = ["uid", "user_uid", ...$this->allowedFields, ...$this->getFields(),]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } - public function getTitle(): string + public function getTitleField(): string { return 'name'; } public function getFields(string $action = ""): array { - $fields = ["category_uid", $this->getTitle(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; + $fields = ["category_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; switch ($action) { case "index": case "excel": - return ["category_uid", "user_uid", $this->getTitle(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; + return ["category_uid", "user_uid", $this->getTitleField(), "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "created_at"]; break; case "view": return [...$fields, "created_at"]; @@ -53,7 +53,7 @@ class ProductModel extends BaseModel case "user_uid": $rules[$field] = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; break; - case $this->getTitle(): + case $this->getTitleField(): $rules[$field] = "required|trim|string"; break; case 'photo': @@ -94,12 +94,12 @@ class ProductModel extends BaseModel public function setIndexWordFilter(string $word) { parent::setIndexWordFilter($word); - $this->orLike($this->getTitle(), $word, "both"); + $this->orLike($this->getTitleField(), $word, "both"); $this->orLike("content", $word, "both"); //befor , after , both } //추가Action - //View관련 (게시판등의 조회수 증가함수) + //장바구니에 넣은 갯수만큼 차감 final public function decreaseStock(ProductEntity $entity, int $cnt) { if ($entity->getStock() == $cnt) { diff --git a/app/Views/admin/category/reply.php b/app/Views/admin/category/reply.php index 5415755..919b319 100644 --- a/app/Views/admin/category/reply.php +++ b/app/Views/admin/category/reply.php @@ -4,7 +4,6 @@ - getStatus() != DEFAULTS['STATUS'] ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> @@ -36,6 +36,7 @@ + diff --git a/app/Views/admin/product/view.php b/app/Views/admin/product/view.php index 05592de..dd97d54 100644 --- a/app/Views/admin/product/view.php +++ b/app/Views/admin/product/view.php @@ -11,15 +11,12 @@ - - -
diff --git a/app/Views/admin/order/index.php b/app/Views/admin/order/index.php index de932ac..cfed366 100644 --- a/app/Views/admin/order/index.php +++ b/app/Views/admin/order/index.php @@ -21,7 +21,7 @@
"checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> - getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> + "_self"] ?>
- getStatus() == DEFAULTS['STATUS']) : ?> - include('admin/product/orderform'); ?> - - 이제품은 현재[getStatus()) ?>]입니다. - -
- -endSection() ?> \ No newline at end of file +
+ getStatus() == DEFAULTS['STATUS']) : ?> + include('admin/product/orderform'); ?> + + 이제품은 현재[getStatus()) ?>]입니다. + +
+ endSection() ?> \ No newline at end of file diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php index 03a3677..7ebd6ca 100644 --- a/app/Views/layouts/admin/left_menu.php +++ b/app/Views/layouts/admin/left_menu.php @@ -5,5 +5,6 @@
include($layout['path'] . '/left_menu/base'); ?> include($layout['path'] . '/left_menu/board'); ?> + include($layout['path'] . '/left_menu/shoppingmall'); ?>
\ No newline at end of file diff --git a/app/Views/layouts/admin/left_menu_shoppingmall.php b/app/Views/layouts/admin/left_menu_shoppingmall.php new file mode 100644 index 0000000..7ebd6ca --- /dev/null +++ b/app/Views/layouts/admin/left_menu_shoppingmall.php @@ -0,0 +1,10 @@ + + + +
+
+ include($layout['path'] . '/left_menu/base'); ?> + include($layout['path'] . '/left_menu/board'); ?> + include($layout['path'] . '/left_menu/shoppingmall'); ?> +
+
\ No newline at end of file