From ed372396b6f8bc15dc96bfcaa6c39a9a6923104f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Tue, 8 Aug 2023 09:58:02 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Controllers/BaseController.php | 9 +++++- app/Controllers/Front/FrontController.php | 2 +- app/Entities/BaseEntity.php | 24 ++++++++++----- app/Entities/BoardEntity.php | 16 ---------- app/Entities/CategoryEntity.php | 23 --------------- app/Entities/OrderEntity.php | 20 ------------- app/Entities/ProductEntity.php | 36 ----------------------- app/Entities/UserEntity.php | 9 ------ 8 files changed, 26 insertions(+), 113 deletions(-) diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index c28d1a7..5e81ec0 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -213,7 +213,14 @@ abstract class BaseController extends Controller //변견된 데이터 Log로 남기기 foreach ($this->_viewDatas['fieldDatas'] as $field => $value) { if ($field != "passwd") { //보안위험성이 있으므로 passwd는 Log에 남기지 않는다. - log_message("info", "{$field} 변경: ---원본--\n%s\n---변경---\n%s", $entity->$field, var_export($value, true)); + log_message( + "info", + sprintf( + "{$field} 변경: ---원본--\n%s\n---변경---\n%s", + $entity->$field, + var_export($value, true) + ) + ); } } } diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index b6c6a77..c10daf6 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -27,7 +27,7 @@ abstract class FrontController extends BaseController //권한체크 final protected function isRole($action, $entity = null) { - $this->_category = !is_null($entity) ? $entity->getCategory_Uid() : ($this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다.")); + $this->_category = !is_null($entity) ? $entity->category_uid : ($this->request->getVar('category') ?: throw new \Exception("범주를 지정하지 않으셨습니다.")); $this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]); $categorys = $this->getCategoryModel()->getSiblingEntitys($this->_viewDatas['category']); $this->_viewDatas['parent_category'] = array_shift($categorys); diff --git a/app/Entities/BaseEntity.php b/app/Entities/BaseEntity.php index 7c7822e..0771c2b 100644 --- a/app/Entities/BaseEntity.php +++ b/app/Entities/BaseEntity.php @@ -6,9 +6,11 @@ use CodeIgniter\Entity\Entity; abstract class BaseEntity extends Entity { - abstract public function getPrimaryKey(); abstract public function getTitle(): string; - + public function getPrimaryKey() + { + $this->attributes['uid']; + } //조화수관련 Field전용 final public function getViews($field = 'view_cnt') { @@ -16,22 +18,30 @@ abstract class BaseEntity extends Entity } //파일관련 Field전용 - final public function getFileDownload($field = "upload_file") { + if (is_null($this->attributes[$field])) { + return ""; + } + $files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]); return anchor( - current_url() . "/download/{$field}/{$this->getPrimaryKey()}", - ICONS['IMAGE_FILE'] . explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1], + base_url() . "/download/{$field}/{$this->getPrimaryKey()}", + ICONS['IMAGE_FILE'] . $files[0], ["target" => "_self"] ); } //이미지관련 Field전용 final public function getFileImage($field = "photo", $size = false) { + if (is_null($this->attributes[$field])) { + return ""; + } + $files = explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field]); return sprintf( - "", + "\"%s\"", $size ? $size . '_' : '', - explode(DEFAULTS['DELIMITER_FILE'], $this->attributes[$field])[1] + $files[1], + $files[0] ); } } diff --git a/app/Entities/BoardEntity.php b/app/Entities/BoardEntity.php index bbe81d6..3287042 100644 --- a/app/Entities/BoardEntity.php +++ b/app/Entities/BoardEntity.php @@ -9,10 +9,6 @@ class BoardEntity extends BaseHierarchyEntity protected $casts = []; //기본기능 - public function getPrimaryKey() - { - return $this->attributes['uid']; - } public function getTitle(): string { return $this->attributes['title']; @@ -23,20 +19,8 @@ class BoardEntity extends BaseHierarchyEntity } //추가기능 - public function getCategory_Uid() - { - return $this->attributes['category_uid']; - } - public function getUser_Uid() - { - return $this->attributes['user_uid']; - } public function getPassword() { return $this->attributes['passwd']; } - public function getBoardFile() - { - return $this->attributes['board_file']; - } } diff --git a/app/Entities/CategoryEntity.php b/app/Entities/CategoryEntity.php index 477b319..a12025f 100644 --- a/app/Entities/CategoryEntity.php +++ b/app/Entities/CategoryEntity.php @@ -9,10 +9,6 @@ class CategoryEntity extends BaseHierarchyEntity protected $casts = []; //기본기능 - public function getPrimaryKey() - { - return $this->attributes['uid']; - } public function getTitle(): string { return $this->attributes['name']; @@ -23,23 +19,4 @@ class CategoryEntity extends BaseHierarchyEntity } //추가기능 - public function getHead() - { - return $this->attributes['head']; - } - public function getTail() - { - return $this->attributes['tail']; - } - public function getRole($field = 'isaccess') - { - return array_key_exists( - $field, - $this->attributes - ) ? $this->attributes[$field] : DEFAULTS['ROLE']; - } - public function getPhoto() - { - return $this->attributes['photo']; - } } diff --git a/app/Entities/OrderEntity.php b/app/Entities/OrderEntity.php index 7191a99..443db4d 100644 --- a/app/Entities/OrderEntity.php +++ b/app/Entities/OrderEntity.php @@ -10,10 +10,6 @@ class OrderEntity extends BaseEntity protected $casts = []; //기본기능 - final public function getPrimaryKey() - { - return $this->attributes['uid']; - } final public function getTitle(): string { return $this->attributes['name']; @@ -24,20 +20,4 @@ class OrderEntity extends BaseEntity } //추가기능 - final public function getProduct_uid() - { - return $this->attributes['product_uid']; - } - final public function getUser_uid() - { - return $this->attributes['user_uid']; - } - final public function getPrice() - { - return $this->attributes['price']; - } - final public function getQuantity() - { - return $this->attributes['quantity']; - } } diff --git a/app/Entities/ProductEntity.php b/app/Entities/ProductEntity.php index 3c310a2..50b90ce 100644 --- a/app/Entities/ProductEntity.php +++ b/app/Entities/ProductEntity.php @@ -9,10 +9,6 @@ class ProductEntity extends BaseEntity protected $casts = []; //기본기능 - public function getPrimaryKey() - { - return $this->attributes['uid']; - } public function getTitle(): string { return $this->attributes['name']; @@ -23,36 +19,4 @@ class ProductEntity extends BaseEntity } //추가기능 - public function getCategory_uid() - { - return $this->attributes['category_uid']; - } - public function getUer_uid() - { - return $this->attributes['user_uid']; - } - public function getCost() - { - return $this->attributes['cost']; - } - public function getPrice() - { - return $this->attributes['price']; - } - public function getSale() - { - return $this->attributes['sale']; - } - public function getPhoto() - { - return $this->attributes['photo']; - } - public function getContent() - { - return $this->attributes['content']; - } - public function getStock() - { - return $this->attributes['stock']; - } } diff --git a/app/Entities/UserEntity.php b/app/Entities/UserEntity.php index 9344533..ceb19f8 100644 --- a/app/Entities/UserEntity.php +++ b/app/Entities/UserEntity.php @@ -9,10 +9,6 @@ class UserEntity extends BaseEntity protected $casts = []; //기본기능 - public function getPrimaryKey() - { - return $this->attributes['uid']; - } public function getTitle(): string { return $this->attributes['name']; @@ -23,11 +19,6 @@ class UserEntity extends BaseEntity } //추가기능 - public function getRole() - { - return $this->attributes['role']; - } - public function getPassword() { return $this->attributes['passwd'];