From ee63d7037be8d3e0ec2313a0854b5e284d9b1654 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: Sat, 5 Aug 2023 09:53:31 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Controllers/Front/ProductController.php | 49 +++++++++++++++++-- app/Views/front/product/index.php | 2 + app/Views/front/product/view.php | 2 + .../layouts/front/left_menu/shoppingmall.php | 46 +++++++++++------ 4 files changed, 81 insertions(+), 18 deletions(-) diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index 3536898..487bf36 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -6,16 +6,24 @@ use App\Models\ProductModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; +use App\Models\CategoryModel; class ProductController extends FrontController { + private $_category = null; + private $_categoryModel = null; public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { - $this->_model = new ProductModel(); + $this->_model = new ProductModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); } + private function getCategoryModel(): CategoryModel + { + return $this->_categoryModel = $this->_categoryModel ?: new CategoryModel(); + } + public function getFields(string $action = ""): array { $fields = ["category_uid", 'name', "photo", "cost", "price", "sale", "stock", "view_cnt", "status", "content",]; @@ -57,7 +65,42 @@ class ProductController extends FrontController //View관련 protected function view_process($entity) { - $entity = parent::view_process($entity); - return $this->_model->addViewCount($entity); + $this->_viewDatas['category'] = $this->getCategoryModel()->getEntity( + [$this->getCategoryModel()->getPrimaryKey() => $entity->getCategory_Uid()] + ); + //사용자가 Category에서 해당 게시판의 READ권한이 있는지 확인 + if (!isRole_CommonHelper( + $this->_viewDatas['currentRoles'], + $this->_viewDatas['category'], + CATEGORY_ROLE_FIELDS['READ'] + )) { + throw new \Exception("고객님은 읽기권한이 없습니다."); + } + //조회수 올리기 + $this->_model->addViewCount($entity); + return parent::view_process($entity); + } + + //Index관련 + protected function index_process() + { + $this->_category = $this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다."); + $this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]); + //사용자가 Category에서 해당 게시판의 ACCESS권한이 있는지 확인 + if (!isRole_CommonHelper( + $this->_viewDatas['currentRoles'], + $this->_viewDatas['category'], + CATEGORY_ROLE_FIELDS['ACCESS'] + )) { + throw new \Exception("고객님은 접속권한이 없습니다."); + } + return parent::index_process(); + } + //Category 및 Status 조건추가 + protected function index_setCondition() + { + $this->_model->where("category_uid", $this->_viewDatas['category']->getPrimaryKey()); + $this->_model->where("status", DEFAULTS['STATUS']); + parent::index_setCondition(); } } diff --git a/app/Views/front/product/index.php b/app/Views/front/product/index.php index 188f8e9..140a104 100644 --- a/app/Views/front/product/index.php +++ b/app/Views/front/product/index.php @@ -1,6 +1,7 @@ extend('layouts/front') ?> section('content') ?>
+
getHead()) ?>
"get")) ?>
+
getTail()) ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/front/product/view.php b/app/Views/front/product/view.php index 5d249d5..bf91cf9 100644 --- a/app/Views/front/product/view.php +++ b/app/Views/front/product/view.php @@ -1,6 +1,7 @@ extend('layouts/admin') ?> section('content') ?>
+
getHead()) ?>
@@ -19,5 +20,6 @@ 이제품은 현재[getStatus()) ?>]입니다. +
getTail()) ?>
endSection() ?> \ No newline at end of file diff --git a/app/Views/layouts/front/left_menu/shoppingmall.php b/app/Views/layouts/front/left_menu/shoppingmall.php index 9709627..ccb2e84 100644 --- a/app/Views/layouts/front/left_menu/shoppingmall.php +++ b/app/Views/layouts/front/left_menu/shoppingmall.php @@ -1,16 +1,32 @@ + + +
+

+ +

+
-

- -

- -
\ No newline at end of file +

가구

+
+ +
+ +
+

+ +

+
+ + +
+
\ No newline at end of file