shoppingmallv2 init...

This commit is contained in:
최준흠git config git config --helpgit config --global user.name 최준흠 2023-08-08 22:26:55 +09:00
parent a536462ef7
commit 9a920055d5
16 changed files with 157 additions and 73 deletions

View File

@ -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;
}
}

View File

@ -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'];

View File

@ -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 '내용',

View File

@ -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 '내용',

View File

@ -16,4 +16,8 @@ abstract class BaseHierarchyEntity extends BaseEntity
{
return $this->attributes['grpdepth'];
}
final public function getHierarchy_ParentUID()
{
return $this->attributes['parent_uid'];
}
}

View File

@ -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(

View File

@ -8,6 +8,7 @@ return [
'label' => [
'uid' => "번호",
'name' => "범주제목",
'linkurl' => "LinkURL",
'photo' => "이미지",
'isaccess' => "접속권한",
'isread' => "읽기권한",

View File

@ -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;

View File

@ -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);

View File

@ -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),];

View File

@ -0,0 +1,14 @@
<div class="parent">
<div>-</div>
<div class="title"><?= $viewDatas['parent_category']->getTitle() ?></div>
</div>
<?php foreach ($viewDatas['sibling_categorys'] as $category) : ?>
<div class="sibling <?php if ($viewDatas['category']->getPrimaryKey() == $category->getPrimaryKey()) : ?>active<?php endif ?>">
<?= anchor(
$category->linkurl . '?category=' . $category->getPrimaryKey(),
$category->getTitle(),
["target" => "_self"]
) ?>
<span class="play"><?= ICONS['PLAY'] ?></span>
</div>
<?php endforeach ?>

View File

@ -1,19 +1,6 @@
<!-- left menu start -->
<link href="/css/front/left_menu.css" media="screen" rel="stylesheet" type="text/css" />
<div id="left_menu">
<div class="parent">
<div>-</div>
<div class="title"><?= $viewDatas['parent_category']->getTitle() ?></div>
</div>
<?php foreach ($viewDatas['sibling_categorys'] as $category) : ?>
<div class="sibling <?php if ($viewDatas['category']->getPrimaryKey() == $category->getPrimaryKey()) : ?>active<?php endif ?>">
<?= anchor(
'/front/' . strtolower($viewDatas['className']) .
'?category=' . $category->getPrimaryKey(),
$category->getTitle(),
["target" => "_self"]
) ?>
<span class="play"><?= ICONS['PLAY'] ?></span>
</div>
<?php endforeach ?>
</div>
<?= $this->include($viewDatas['layout']['path'] . "/left_menu/leftmenu_{$viewDatas['category']->getHierarchy_ParentUID()}"); ?>
</div>
<!-- left menu end -->

View File

@ -0,0 +1,13 @@
<!-- DEBUG-VIEW START 4 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">게시판</div>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/board?category=2" target="_self">공지사항</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/board?category=3" target="_self">FAQ</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 4 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -0,0 +1,13 @@
<!-- DEBUG-VIEW START 1 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">AboutUS</div>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/sitepage?category=11" target="_self">회사소개</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/sitepage?category=12" target="_self">인사말</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 1 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -0,0 +1,13 @@
<!-- DEBUG-VIEW START 3 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">네트워크</div>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/product?category=5" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/product?category=6" target="_self">월이용권</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 3 APPPATH\Views\admin\category\leftmenu_template.php -->

View File

@ -0,0 +1,13 @@
<!-- DEBUG-VIEW START 2 APPPATH\Views\admin\category\leftmenu_template.php -->
<div class="parent">
<div>-</div>
<div class="title">서버</div>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/product?category=8" target="_self">판매</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<div class="sibling ">
<a href="http://localhost:8080/front/product?category=9" target="_self">월이용권</a> <span class="play"><i class="bi bi-play-fill"></i></span>
</div>
<!-- DEBUG-VIEW ENDED 2 APPPATH\Views\admin\category\leftmenu_template.php -->