diff --git a/app/Config/Constants.php b/app/Config/Constants.php
index c4e1583..97b7787 100644
--- a/app/Config/Constants.php
+++ b/app/Config/Constants.php
@@ -108,7 +108,8 @@ define('LAYOUTS', [
'front' => [
'title' => '사용자화면',
'path' => 'layouts' . DIRECTORY_SEPARATOR . 'front',
- 'topmenus' => ['aboutus', 'hosting', 'serverdevice', 'service', 'support'],
+ //'topmenus' => ['aboutus', 'hosting', 'serverdevice', 'service', 'support'],
+ 'topmenus' => ['aboutus', 'hosting', 'service', 'support'],
'stylesheets' => [
'',
'',
@@ -230,6 +231,20 @@ foreach (PATHS as $key => $path) {
}
}
+define('CLASS_ICONS', [
+ 'USER' => '',
+ 'USERSNS' => '',
+ 'BOARD' => '',
+ 'SITEPAGE' => '',
+ 'CATEGORY' => '',
+ 'PRODUCT' => '',
+ 'ORDER' => '',
+ 'BILLING' => '',
+ 'CART' => '',
+ 'CARD' => '',
+ 'DEPOSIT' => '',
+]);
+
//아이콘 및 Sound관련
define('ICONS', [
'LOGIN' => '',
@@ -254,19 +269,6 @@ define('ICONS', [
'RIGHT' => '',
'IMAGE_FILE' => '',
]);
-define('CLASS_ICONS', [
- 'USER' => '',
- 'USERSNS' => '',
- 'BOARD' => '',
- 'SITEPAGE' => '',
- 'CATEGORY' => '',
- 'PRODUCT' => '',
- 'ORDER' => '',
- 'BILLING' => '',
- 'CART' => '',
- 'CARD' => '',
- 'DEPOSIT' => '',
-]);
define('TOP_BANNER', [
'default' => '
',
diff --git a/app/Database/base.sql b/app/Database/base.sql
index d0ed180..4dd4032 100644
--- a/app/Database/base.sql
+++ b/app/Database/base.sql
@@ -42,6 +42,7 @@ DROP TABLE IF EXISTS vhost.tw_category;
CREATE TABLE vhost.tw_category (
uid varchar(50) NOT NULL,
+ classname varchar(50) NOT NULL DEFAULT 'Sitepage',
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씩 추가필요',
@@ -100,8 +101,7 @@ CREATE TABLE vhost.tw_sitepage (
user_uid varchar(36) DEFAULT NULL COMMENT '작성자 정보',
title varchar(255) NOT NULL COMMENT '제목',
content text NOT NULL COMMENT '내용',
- status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,
- unuse: 사용않함 등등',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 사용않함 등등',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
@@ -121,13 +121,13 @@ CREATE TABLE vhost.tw_product (
type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대, onetime:판매,일회성',
name varchar(255) NOT NULL COMMENT '상품명',
photo varchar(255) DEFAULT NULL COMMENT '상품이미지',
- cost int(10) unsigned NOT NULL COMMENT '원가',
- price int(10) unsigned NOT NULL COMMENT '판매가',
+ cost int(10) unsigned NOT NULL DEFAULT 0 COMMENT '원가',
+ price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가',
sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가',
- stock int(5) unsigned DEFAULT 1 COMMENT '재고수량',
- view_cnt int(4) unsigned NOT NULL DEFAULT 0 COMMENT '조회수',
- content text NOT NULL COMMENT '상품정보',
- status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매, unuse: 판매않함, standby: 판매준비, hold: 판매중지 soldout: 상품부족 등등',
+ stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량',
+ view_cnt int(4) unsigned NOT NULL DEFAULT 1 COMMENT '조회수',
+ content text NOT NULL COMMENT '상품내용',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매, unuse: 판매않함, soldout:상품부족 등등',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
@@ -138,6 +138,39 @@ CREATE TABLE vhost.tw_product (
CONSTRAINT tw_product_ibfk_2 FOREIGN KEY (user_uid) REFERENCES tw_user (uid)
) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT = '상품 정보';
+DROP TABLE IF EXISTS vhost.tw_device;
+
+CREATE TABLE vhost.tw_device (
+ uid varchar(36) NOT NULL,
+ type varchar(20) NOT NULL COMMENT '형식:server(HP,KVM,Container),cpu,memory,disk(ssd,nvme),os(linux,windows),공인ip등등',
+ name varchar(255) NOT NULL,
+ cost int(10) unsigned NOT NULL DEFAULT 0 COMMENT '원가',
+ price int(10) unsigned NOT NULL DEFAULT 0 COMMENT '판매가',
+ sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가',
+ stock int(5) unsigned NOT NULL DEFAULT 1 COMMENT '재고수량',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 판매중 unuse: 판매않함, soldout:상품부족 등등',
+ content text NOT NULL COMMENT '장비내용',
+ updated_at timestamp NULL DEFAULT NULL,
+ created_at timestamp NOT NULL DEFAULT current_timestamp(),
+ deleted_at timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (uid)
+) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '장비 정보';
+
+DROP TABLE IF EXISTS vhost.tw_product_device;
+
+CREATE TABLE vhost.tw_product_device (
+ uid int(10) unsigned NOT NULL AUTO_INCREMENT,
+ product_uid varchar(36) NOT NULL COMMENT '상품 정보',
+ device_uid varchar(36) NOT NULL COMMENT '장비 정보',
+ device_cnt int(3) unsigned NOT NULL DEFAULT 1 COMMENT '장비 갯수',
+ created_at timestamp NOT NULL DEFAULT current_timestamp(),
+ PRIMARY KEY (uid),
+ KEY product_uid (product_uid),
+ KEY device_uid (device_uid),
+ CONSTRAINT tw_product_device_ibfk_1 FOREIGN KEY (product_uid) REFERENCES tw_product (uid) ON DELETE CASCADE,
+ CONSTRAINT tw_product_device_ibfk_2 FOREIGN KEY (device_uid) REFERENCES tw_device (uid) ON DELETE RESTRICT
+) ENGINE = InnoDB CHARSET = utf8 COLLATE = utf8_general_ci COMMENT '상품장비연결';
+
DROP TABLE IF EXISTS vhost.tw_order;
CREATE TABLE vhost.tw_order (
@@ -149,11 +182,9 @@ CREATE TABLE vhost.tw_order (
sale int(10) unsigned NOT NULL DEFAULT 0 COMMENT '할인가',
price int(10) unsigned NOT NULL COMMENT '결제액',
quantity varchar(255) NOT NULL COMMENT '수량',
- type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대,
- onetime:판매,일회성',
+ type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대,onetime:판매,일회성',
paymentday int(2) unsigned DEFAULT NULL COMMENT '결제일',
- status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 주문요청/장바구니,
- unuse: 주문완료/서비스',
+ status varchar(10) NOT NULL DEFAULT 'unuse' COMMENT 'use: 주문요청/장바구니,unuse: 주문완료/서비스',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
@@ -168,13 +199,12 @@ DROP TABLE IF EXISTS vhost.tw_service;
CREATE TABLE vhost.tw_service (
uid varchar(36) NOT NULL,
+ product_uid varchar(36) DEFAULT NULL COMMENT '상품 정보',
user_uid varchar(36) DEFAULT NULL COMMENT '구매자 정보',
- type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대,
- onetime:판매,일회성',
+ type varchar(10) NOT NULL DEFAULT 'rental' COMMENT 'rental: 월임대,onetime:판매,일회성',
price int(10) unsigned NOT NULL COMMENT '결제액',
paymentday int(2) unsigned DEFAULT NULL COMMENT '결제일',
- status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,
- unuse: 해지',
+ status varchar(10) NOT NULL DEFAULT 'use' COMMENT 'use: 사용,unuse: 해지',
updated_at timestamp NULL DEFAULT NULL,
created_at timestamp NOT NULL DEFAULT current_timestamp(),
deleted_at timestamp NULL DEFAULT NULL,
diff --git a/app/Models/BaseModel.php b/app/Models/BaseModel.php
index 6123c43..e06529d 100644
--- a/app/Models/BaseModel.php
+++ b/app/Models/BaseModel.php
@@ -40,8 +40,12 @@ abstract class BaseModel extends Model
protected $beforeDelete = [];
protected $afterDelete = [];
- private $_user_options = null;
+ //추가변수선언
private $_className = null;
+ private $_userModel = null;
+ private $_categoryModel = null;
+ protected $_user_options = null;
+ protected $_category_options = null;
protected $_session = null;
protected $_validation = null;
protected function __construct(string $className)
@@ -60,11 +64,25 @@ abstract class BaseModel extends Model
{
return $this->_className;
}
- final public function getPrimaryKey(): string
+ final protected function getUserModel(): UserModel
+ {
+ if (is_null($this->_userModel)) {
+ $this->_userModel = new UserModel();
+ }
+ return $this->_userModel;
+ }
+ final protected function getCategoryModel(): CategoryModel
+ {
+ if (is_null($this->_categoryModel)) {
+ $this->_categoryModel = new CategoryModel();
+ }
+ return $this->_categoryModel;
+ }
+ abstract public function getTitleField(): string;
+ final public function getPrimaryKey()
{
return $this->primaryKey;
}
- abstract public function getTitleField(): string;
public function getEntity($conditions): BaseEntity
{
return $this->where($conditions)->first() ?: throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 해당 데이터가 없습니다.");
@@ -156,11 +174,16 @@ abstract class BaseModel extends Model
switch ($field) {
case 'user_uid':
if (is_null($this->_user_options)) {
- $userModel = new UserModel();
- $this->_user_options = $userModel->getOptions();
+ $this->_user_options = $this->getUserModel()->getOptions();
}
$options = $this->_user_options;
break;
+ case 'category_uid':
+ if (is_null($this->_category_options)) {
+ $this->_category_options = $this->getCategoryModel()->getOptions(['classname' => $this->_className]);
+ }
+ $options = $this->_category_options;
+ break;
default:
$options = lang($this->getClassName() . '.' . strtoupper($field));
break;
diff --git a/app/Models/BoardModel.php b/app/Models/BoardModel.php
index 6f115cc..bf6a88f 100644
--- a/app/Models/BoardModel.php
+++ b/app/Models/BoardModel.php
@@ -6,7 +6,6 @@ use App\Entities\BoardEntity;
class BoardModel extends BaseHierarchyModel
{
- private $_category_options = null;
protected $table = "tw_board";
protected $returnType = BoardEntity::class;
public function __construct()
@@ -53,26 +52,6 @@ class BoardModel extends BaseHierarchyModel
}
return $rules;
}
- //Field별 Form Option용
- public function getFieldFormOption(string $field): array
- {
- switch ($field) {
- case 'category_uid':
- if (is_null($this->_category_options)) {
- $categoryModel = new CategoryModel();
- $this->_category_options = $categoryModel->getOptions();
- }
- $options = $this->_category_options;
- break;
- default:
- return parent::getFieldFormOption($field);
- break;
- }
- if (!is_array($options)) {
- throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
- }
- return $options;
- }
public function getEntity($conditions): BoardEntity
{
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
diff --git a/app/Models/CategoryModel.php b/app/Models/CategoryModel.php
index bd1afcc..bbaf2e4 100644
--- a/app/Models/CategoryModel.php
+++ b/app/Models/CategoryModel.php
@@ -58,11 +58,10 @@ class CategoryModel extends BaseHierarchyModel
return $rules;
}
//Form 선택용 Options Data용
- public function getOptions(array $conditions = array(), $options = array()): array
+ public function getOptions(array $conditions = [], $options = []): array
{
//대분류 부분은 선택이 되지 않게 하기위해 따로 만듬 (form_dropdown의 optgroup 기능)
$old = "";
- $options = array();
foreach ($this->getEntitys($conditions) as $entity) {
if ($entity->getHierarchy_Depth() == 1) {
$old = $entity->getTitle();
@@ -74,7 +73,7 @@ class CategoryModel extends BaseHierarchyModel
return $options;
}
- public function getMenus(array $conditions = array()): array
+ public function getMenus(array $conditions = []): array
{
$old = "";
$menus = array();
diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php
index aeea6c2..295ccc1 100644
--- a/app/Models/ProductModel.php
+++ b/app/Models/ProductModel.php
@@ -7,7 +7,6 @@ use App\Entities\ProductEntity;
class ProductModel extends BaseModel
{
const STATUS_OUTOFSTOCK = "outofstock";
- private $_category_options = null;
protected $table = "tw_product";
protected $useAutoIncrement = false;
protected $returnType = ProductEntity::class;
@@ -63,26 +62,6 @@ class ProductModel extends BaseModel
}
return $rules;
}
- //Field별 Form Option용
- public function getFieldFormOption(string $field): array
- {
- switch ($field) {
- case 'category_uid':
- if (is_null($this->_category_options)) {
- $categoryModel = new CategoryModel();
- $this->_category_options = $categoryModel->getOptions();
- }
- $options = $this->_category_options;
- break;
- default:
- return parent::getFieldFormOption($field);
- break;
- }
- if (!is_array($options)) {
- throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
- }
- return $options;
- }
public function getEntity($conditions): ProductEntity
{
diff --git a/app/Models/SitepageModel.php b/app/Models/SitepageModel.php
index 2e80517..f6a3536 100644
--- a/app/Models/SitepageModel.php
+++ b/app/Models/SitepageModel.php
@@ -6,7 +6,6 @@ use App\Entities\SitepageEntity;
class SitepageModel extends BaseModel
{
- private $_category_options = null;
protected $table = "tw_sitepage";
protected $returnType = SitepageEntity::class;
public function __construct()
@@ -47,26 +46,7 @@ class SitepageModel extends BaseModel
}
return $rules;
}
- //Field별 Form Option용
- public function getFieldFormOption(string $field): array
- {
- switch ($field) {
- case 'category_uid':
- if (is_null($this->_category_options)) {
- $categoryModel = new CategoryModel();
- $this->_category_options = $categoryModel->getOptions();
- }
- $options = $this->_category_options;
- break;
- default:
- return parent::getFieldFormOption($field);
- break;
- }
- if (!is_array($options)) {
- throw new \Exception(__FUNCTION__ . "에서 {$this->getClassName()}의 Field:{$field}의 FormOptionData가 array가 아닙니다.\n" . var_export($options, true));
- }
- return $options;
- }
+
public function getEntity($conditions): SitepageEntity
{
return $this->where($conditions)->first() ?: throw new \Exception("해당 데이터가 없습니다.\n" . var_export($conditions, true));
diff --git a/app/Views/layouts/admin/left_menu.php b/app/Views/layouts/admin/left_menu.php
index 918ed83..38be6ad 100644
--- a/app/Views/layouts/admin/left_menu.php
+++ b/app/Views/layouts/admin/left_menu.php
@@ -4,7 +4,7 @@