From 9a920055d579a95ce36b5f98b1a18352ca6a5e9e 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: Tue, 8 Aug 2023 22:26:55 +0900 Subject: [PATCH] shoppingmallv2 init... --- app/Controllers/Admin/CategoryController.php | 80 ++++++++++--------- app/Controllers/Front/FrontController.php | 4 +- app/Database/base.sql | 10 ++- app/Database/shoppingmall.sql | 11 ++- app/Entities/BaseHierarchyEntity.php | 4 + app/Helpers/Order_helper.php | 9 +++ app/Language/ko/Category.php | 1 + app/Models/BaseHierarchyModel.php | 6 +- app/Models/BaseModel.php | 18 ++--- app/Models/CategoryModel.php | 2 +- .../admin/category/leftmenu_template.php | 14 ++++ app/Views/layouts/front/left_menu.php | 19 +---- .../layouts/front/left_menu/leftmenu_1.php | 13 +++ .../layouts/front/left_menu/leftmenu_10.php | 13 +++ .../layouts/front/left_menu/leftmenu_4.php | 13 +++ .../layouts/front/left_menu/leftmenu_7.php | 13 +++ 16 files changed, 157 insertions(+), 73 deletions(-) create mode 100644 app/Views/admin/category/leftmenu_template.php create mode 100644 app/Views/layouts/front/left_menu/leftmenu_1.php create mode 100644 app/Views/layouts/front/left_menu/leftmenu_10.php create mode 100644 app/Views/layouts/front/left_menu/leftmenu_4.php create mode 100644 app/Views/layouts/front/left_menu/leftmenu_7.php diff --git a/app/Controllers/Admin/CategoryController.php b/app/Controllers/Admin/CategoryController.php index 33726d5..26ece7f 100644 --- a/app/Controllers/Admin/CategoryController.php +++ b/app/Controllers/Admin/CategoryController.php @@ -21,14 +21,14 @@ class CategoryController extends AdminController public function getFields(string $action = ""): array { $fields = [ - 'name', "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + 'name', "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status", "head", "tail", ]; switch ($action) { case "index": case "excel": return [ - 'name', 'photo', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + 'name', "linkurl", 'photo', "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "status", "created_at" ]; break; @@ -65,39 +65,47 @@ class CategoryController extends AdminController return $this->_viewDatas['fieldDatas']; } - // private function build_leftmenu() - // { - // $categorys = $this->_model->getEntitys(['status' => DEFAULTS['STATUS']]); - // $leftmenu = view($this->_viewPath . '/leftmenu', ['categorys' => $categorys]); - // file_put_contents(APPPATH . 'Views' . '/layouts/front/left_menu/leftmenu.php', $leftmenu); - // } + private function build_leftmenu() + { + foreach ($this->_model->getEntitys(['grpdepth' => 1, 'status' => DEFAULTS['STATUS']]) as $entity) { + $categorys = $this->_model->getSiblingEntitys($entity); + $viewDatas = [ + 'className' => $this->_model->getClassName(), + 'category' => $entity, + 'parent_category' => array_shift($categorys), + 'sibling_categorys' => $categorys + ]; + $leftmenu = view($this->_viewPath . '/leftmenu_template', ['viewDatas' => $viewDatas]); + file_put_contents(APPPATH . 'Views' . "/layouts/front/left_menu/leftmenu_{$entity->getPrimaryKey()}.php", $leftmenu); + } + } - // //Insert관련 - // protected function insert_process() - // { - // $entity = parent::insert_process(); - // $this->build_leftmenu(); - // return $entity; - // } - // //Update관련 - // protected function update_process($entity) - // { - // $entity = parent::update_process($entity); - // $this->build_leftmenu(); - // return $entity; - // } - // //Reply관련 - // protected function reply_process($entity) - // { - // $entity = parent::reply_process($entity); - // $this->build_leftmenu(); - // return $entity; - // } - // //Delete 관련 - // protected function delete_process($entity) - // { - // $entity = parent::delete_process($entity); - // $this->build_leftmenu(); - // return $entity; - // } + //Insert관련 + protected function insert_process() + { + $entity = parent::insert_process(); + $this->build_leftmenu(); + return $entity; + } + //Update관련 + protected function update_process($entity) + { + $entity = parent::update_process($entity); + $this->build_leftmenu(); + return $entity; + } + //Reply관련 + protected function reply_process($entity) + { + $entity = parent::reply_process($entity); + $this->build_leftmenu(); + return $entity; + } + //Delete 관련 + protected function delete_process($entity) + { + $entity = parent::delete_process($entity); + $this->build_leftmenu(); + return $entity; + } } diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index d62c89a..d32f669 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -33,9 +33,7 @@ abstract class FrontController extends BaseController $this->_category = !is_null($entity) ? $entity->category_uid : 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); - $this->_viewDatas['sibling_categorys'] = $categorys; + $this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]); switch ($action) { case 'insert': $category_field = CATEGORY_ROLE_FIELDS['WRITE']; diff --git a/app/Database/base.sql b/app/Database/base.sql index d32f2dd..d7ceac2 100644 --- a/app/Database/base.sql +++ b/app/Database/base.sql @@ -50,7 +50,10 @@ CREATE TABLE baseproject.tw_category ( grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함', grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', - name varchar(255) NOT NULL COMMENT '범주명', + parent_uid int(10) UNSIGNED NULL COMMENT '부모UID', + name varchar(255) NOT NULL COMMENT '분류명', + linkurl varchar(100) NOT NULL DEFAULT '/front/board' COMMENT 'Front Link URL', + photo varchar(255) NULL COMMENT '이미지', isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한', isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한', iswrite varchar(30) NOT NULL DEFAULT 'guest' COMMENT '쓰기권한', @@ -64,7 +67,7 @@ CREATE TABLE baseproject.tw_category ( created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, PRIMARY KEY (uid) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='범주'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='분류'; DROP TABLE IF EXISTS baseproject.tw_board; -- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업 @@ -78,7 +81,8 @@ CREATE TABLE baseproject.tw_board ( grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함', grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', - category_uid int(10) UNSIGNED NOT NULL COMMENT '범주 UID', + parent_uid int(10) UNSIGNED NULL COMMENT '부모UID', + category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID', user_uid varchar(36) NULL COMMENT '작성자 정보', title varchar(255) NOT NULL COMMENT '제목', content text NOT NULL COMMENT '내용', diff --git a/app/Database/shoppingmall.sql b/app/Database/shoppingmall.sql index 7bab674..5e07d9e 100644 --- a/app/Database/shoppingmall.sql +++ b/app/Database/shoppingmall.sql @@ -48,7 +48,9 @@ CREATE TABLE shoppingmall.tw_category ( grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함', grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', - name varchar(255) NOT NULL COMMENT '범주명', + parent_uid int(10) UNSIGNED NULL COMMENT '부모UID', + name varchar(255) NOT NULL COMMENT '분류명', + linkurl varchar(100) NOT NULL DEFAULT '/front/board' COMMENT 'Front Link URL', photo varchar(255) NULL COMMENT '이미지', isaccess varchar(30) NOT NULL DEFAULT 'guest' COMMENT '접근권한', isread varchar(30) NOT NULL DEFAULT 'guest' COMMENT '읽기권한', @@ -63,7 +65,7 @@ CREATE TABLE shoppingmall.tw_category ( created_at timestamp NOT NULL DEFAULT current_timestamp(), deleted_at timestamp NULL DEFAULT NULL, PRIMARY KEY (uid) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='범주'; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT ='분류'; DROP TABLE IF EXISTS shoppingmall.tw_board; -- 1. 게시물 추가전 grpno에 해당하는 max(grporder)+1씩증가 작업 @@ -77,7 +79,8 @@ CREATE TABLE shoppingmall.tw_board ( grpno int(10) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group번호: 상위가없을시 기본 uid와 같음,항상 숫자여야함', grporder int(5) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group순서: 상위가없을시 1부터시작', grpdepth int(3) UNSIGNED NOT NULL DEFAULT 1 COMMENT 'Group깊이: 상위가없을시 1부터시작 , 상위 grpdepth+1씩 추가필요', - category_uid int(10) UNSIGNED NOT NULL COMMENT '범주 UID', + parent_uid int(10) UNSIGNED NULL COMMENT '부모UID', + category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID', user_uid varchar(36) NULL COMMENT '작성자 정보', title varchar(255) NOT NULL COMMENT '제목', content text NOT NULL COMMENT '내용', @@ -96,7 +99,7 @@ CREATE TABLE shoppingmall.tw_board ( DROP TABLE IF EXISTS shoppingmall.tw_sitepage; CREATE TABLE shoppingmall.tw_sitepage ( uid int(10) UNSIGNED NOT NULL AUTO_INCREMENT, - category_uid int(10) UNSIGNED NOT NULL COMMENT '범주 UID', + category_uid int(10) UNSIGNED NOT NULL COMMENT '분류 UID', user_uid varchar(36) NULL COMMENT '작성자 정보', title varchar(255) NOT NULL COMMENT '제목', content text NOT NULL COMMENT '내용', diff --git a/app/Entities/BaseHierarchyEntity.php b/app/Entities/BaseHierarchyEntity.php index ff5ebc7..5eb3bec 100644 --- a/app/Entities/BaseHierarchyEntity.php +++ b/app/Entities/BaseHierarchyEntity.php @@ -16,4 +16,8 @@ abstract class BaseHierarchyEntity extends BaseEntity { return $this->attributes['grpdepth']; } + final public function getHierarchy_ParentUID() + { + return $this->attributes['parent_uid']; + } } diff --git a/app/Helpers/Order_helper.php b/app/Helpers/Order_helper.php index ce28b72..6086275 100644 --- a/app/Helpers/Order_helper.php +++ b/app/Helpers/Order_helper.php @@ -116,7 +116,16 @@ function getFieldIndex_Row_OrderHelper($field, $entity, array $viewDatas): strin //Admin용 function getFieldIndex_Row_OrderHelper_Admin($field, $entity, array $viewDatas): string { + $value = $entity->$field ?: DEFAULTS['EMPTY']; switch ($field) { + case 'title': + case 'name': + return anchor( + current_url() . '/view/' . $entity->getPrimaryKey(), + $value, + ["target" => "_self"] + ); + break; default: if (in_array($field, $viewDatas['fieldFilters'])) { $attributes["onChange"] = sprintf( diff --git a/app/Language/ko/Category.php b/app/Language/ko/Category.php index b83d504..0e653b2 100644 --- a/app/Language/ko/Category.php +++ b/app/Language/ko/Category.php @@ -8,6 +8,7 @@ return [ 'label' => [ 'uid' => "번호", 'name' => "범주제목", + 'linkurl' => "LinkURL", 'photo' => "이미지", 'isaccess' => "접속권한", 'isread' => "읽기권한", diff --git a/app/Models/BaseHierarchyModel.php b/app/Models/BaseHierarchyModel.php index 2d3f41e..1f1ed29 100644 --- a/app/Models/BaseHierarchyModel.php +++ b/app/Models/BaseHierarchyModel.php @@ -10,7 +10,7 @@ abstract class BaseHierarchyModel extends BaseModel protected function __construct(string $className) { parent::__construct($className); - $this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth"]; + $this->allowedFields = [...$this->allowedFields, "grpno", "grporder", "grpdepth", "parent_uid"]; $this->validationRules = [...$this->validationRules,]; } abstract public function getContentField(); @@ -27,6 +27,9 @@ abstract class BaseHierarchyModel extends BaseModel case "grpdepth": $rules[$field] = "if_exist|numeric"; //반드시숫자여야함 break; + case "parent_uid": + $rules[$field] = "if_exist"; + break; default: $rules = parent::getFieldRule($field, $rules, $action); break; @@ -55,6 +58,7 @@ abstract class BaseHierarchyModel extends BaseModel ]); $this->update(); //reply용 설정 + $entity->parent_uid = $parent_entity->getPrimaryKey(); $entity->grpno = $parent_entity->grpno; $entity->grporder = $parent_entity->grporder + 1; $entity->grpdepth = $parent_entity->grpdepth + 1; diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php index f2abc3d..e2fac7f 100644 --- a/app/Models/BaseModel.php +++ b/app/Models/BaseModel.php @@ -184,6 +184,13 @@ abstract class BaseModel extends Model protected function changeFormData(string $action, string $field, array $formDatas, $entity) { switch ($field) { + case $this->primaryKey: + //primaryKey가 수동입력이고 추가(Reply도 결국엔 create_process를 상용)시에만 + if ($action == 'create' && !$this->useAutoIncrement) { + $pk = $this->primaryKey; + $entity->$pk = $this->getUUID(); + } + break; case "user_uid": //입력데이터로 있을시 관리툴에서 (사용자,등)추가, 없을시는 입력의 경우에만 자동(장바구니,등)으로 추가 if (array_key_exists($field, $formDatas)) { //관리툴 USERSNS에서 사용자 연동 시 추가기능등에 사용 @@ -230,14 +237,9 @@ abstract class BaseModel extends Model } protected function create_process($entity, array $formDatas) { - foreach (array_keys($formDatas) as $field) { + foreach ($this->allowedFields as $field) { $entity = $this->changeFormData('create', $field, $formDatas, $entity); } - //primaryKey가 수동입력이면 - if (!$this->useAutoIncrement) { - $pk = $this->primaryKey; - $entity->$pk = $this->getUUID(); - } $entity = $this->save_process($entity); //primaryKey가 자동입력이면 if ($this->useAutoIncrement) { @@ -249,9 +251,7 @@ abstract class BaseModel extends Model final protected function modify_process($entity, array $formDatas) { foreach ($this->allowedFields as $field) { - if ($field != $this->primaryKey) { - $entity = $this->changeFormData('modify', $field, $formDatas, $entity); - } + $entity = $this->changeFormData('modify', $field, $formDatas, $entity); } $entity->updated_at = time(); return $this->save_process($entity); diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php index b09b430..dc81303 100644 --- a/app/Models/CategoryModel.php +++ b/app/Models/CategoryModel.php @@ -13,7 +13,7 @@ class CategoryModel extends BaseHierarchyModel parent::__construct('Category'); $this->allowedFields = [ ...$this->allowedFields, - 'name', "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", + 'name', "linkurl", "photo", "isaccess", "isread", "iswrite", "isreply", "isupload", "isdownload", "head", "tail", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; diff --git a/app/Views/admin/category/leftmenu_template.php b/app/Views/admin/category/leftmenu_template.php new file mode 100644 index 0000000..540d651 --- /dev/null +++ b/app/Views/admin/category/leftmenu_template.php @@ -0,0 +1,14 @@ +
+
-
+
getTitle() ?>
+
+ +
+ linkurl . '?category=' . $category->getPrimaryKey(), + $category->getTitle(), + ["target" => "_self"] + ) ?> + +
+ \ No newline at end of file diff --git a/app/Views/layouts/front/left_menu.php b/app/Views/layouts/front/left_menu.php index 5afb57b..0c74bb4 100644 --- a/app/Views/layouts/front/left_menu.php +++ b/app/Views/layouts/front/left_menu.php @@ -1,19 +1,6 @@
-
-
-
-
getTitle() ?>
-
- -
- getPrimaryKey(), - $category->getTitle(), - ["target" => "_self"] - ) ?> - -
- -
\ No newline at end of file + include($viewDatas['layout']['path'] . "/left_menu/leftmenu_{$viewDatas['category']->getHierarchy_ParentUID()}"); ?> + + \ No newline at end of file diff --git a/app/Views/layouts/front/left_menu/leftmenu_1.php b/app/Views/layouts/front/left_menu/leftmenu_1.php new file mode 100644 index 0000000..3f1697a --- /dev/null +++ b/app/Views/layouts/front/left_menu/leftmenu_1.php @@ -0,0 +1,13 @@ + +
+
-
+
게시판
+
+
+ 공지사항 +
+
+ FAQ +
+ + diff --git a/app/Views/layouts/front/left_menu/leftmenu_10.php b/app/Views/layouts/front/left_menu/leftmenu_10.php new file mode 100644 index 0000000..52de5ce --- /dev/null +++ b/app/Views/layouts/front/left_menu/leftmenu_10.php @@ -0,0 +1,13 @@ + +
+
-
+
AboutUS
+
+
+ 회사소개 +
+
+ 인사말 +
+ + diff --git a/app/Views/layouts/front/left_menu/leftmenu_4.php b/app/Views/layouts/front/left_menu/leftmenu_4.php new file mode 100644 index 0000000..1349c76 --- /dev/null +++ b/app/Views/layouts/front/left_menu/leftmenu_4.php @@ -0,0 +1,13 @@ + +
+
-
+
네트워크
+
+
+ 판매 +
+
+ 월이용권 +
+ + diff --git a/app/Views/layouts/front/left_menu/leftmenu_7.php b/app/Views/layouts/front/left_menu/leftmenu_7.php new file mode 100644 index 0000000..70f42c9 --- /dev/null +++ b/app/Views/layouts/front/left_menu/leftmenu_7.php @@ -0,0 +1,13 @@ + +
+
-
+
서버
+
+
+ 판매 +
+
+ 월이용권 +
+ +