From 70ba4dc67bd5ccdccc838b295d5de53a36ec87a2 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 20:12:45 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Controllers/Front/BoardController.php | 7 +++++++ app/Controllers/Front/ProductController.php | 7 +++++++ app/Models/BoardModel.php | 7 +++++++ app/Models/ProductModel.php | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index 4743f87..c39c341 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -60,4 +60,11 @@ class BoardController extends FrontController } return $this->_viewDatas['fieldDatas']; } + + //View관련 + protected function view_process($entity) + { + $entity = parent::view_process($entity); + return $this->_model->addViewCount($entity); + } } diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index b906499..3536898 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -53,4 +53,11 @@ class ProductController extends FrontController } return $this->_viewDatas['fieldDatas']; } + + //View관련 + protected function view_process($entity) + { + $entity = parent::view_process($entity); + return $this->_model->addViewCount($entity); + } } diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php index 4238360..8dcd3e2 100644 --- a/app/Models/BoardModel.php +++ b/app/Models/BoardModel.php @@ -95,4 +95,11 @@ class BoardModel extends BaseHierarchyModel $this->orLike($this->getTitleField(), $word, "both"); $this->orLike("content", $word, "both"); //befor , after , both } + + //조회수 올리기 + final public function addViewCount(BoardEntity $entity, int $view_cnt = 1): BoardEntity + { + $entity->view_cnt += $view_cnt; + return $this->save_process($entity); + } } diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index b8a75cb..040ae50 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -115,6 +115,13 @@ class ProductModel extends BaseModel $this->orLike("content", $word, "both"); //befor , after , both } + //조회수 올리기 + final public function addViewCount(ProductEntity $entity, int $view_cnt = 1): ProductEntity + { + $entity->view_cnt += $view_cnt; + return $this->save_process($entity); + } + //장바구니에 넣기 final public function addCart(ProductEntity $entity, int $quantity): ProductEntity {