Feature #53
openFeature #56: CATEGORY POST PRODUCT
Thiết kế database cho hans-spa
0%
Description
Menu danh mục
- danh mục setup được cha, con
- mỗi danh mục có thể có chứa bài viết
- mỗi bài viết có thể là 1 product
- breadcum động cho SEO dễ setup
......
https://docs.google.com/spreadsheets/d/1jX7PPKl5R2VPGBc0P3TwaEOZ5H1exWBBW-E2_vdf9n4/edit?usp=sharing
Updated by Minh Trung Nguyễn 17 days ago · Edited
CREATE TABLE hans_spa_categories (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
slug VARCHAR(255) NOT NULL,
-- Xác định danh mục là service hay blog
type ENUM('service', 'blog') NOT NULL DEFAULT 'service',
parent_id INT UNSIGNED NULL,
sort INT DEFAULT 0,
is_publish TINYINT(1) DEFAULT 1,
meta_title VARCHAR(255) DEFAULT NULL,
meta_keyword VARCHAR(255) DEFAULT NULL,
meta_description VARCHAR(255) DEFAULT NULL,
created_by INT UNSIGNED NULL,
updated_by INT UNSIGNED NULL,
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_parent_id (parent_id),
INDEX idx_type (type),
-- Không được trùng slug trong cùng 1 cấp cha
UNIQUE KEY uq_category_slug_parent (slug, parent_id),
UNIQUE KEY uq_category_name_parent (name, parent_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO hans_spa_categories
(id, name, slug, type, parent_id, sort, is_publish,
meta_title, meta_keyword, meta_description, created_by, updated_by)
VALUES
-- Service root
(1,'Massage','massage','service',NULL,1,1,NULL,NULL,NULL,NULL,NULL),
(2,'Shampoo','shampoo','service',NULL,2,1,NULL,NULL,NULL,NULL,NULL),
(3,'Nail','nail','service',NULL,3,1,NULL,NULL,NULL,NULL,NULL),
(4,'Individual Service','individual-service','service',NULL,4,1,NULL,NULL,NULL,NULL,NULL),
-- Blog root
(5,'Blog','blog','blog',NULL,5,1,NULL,NULL,NULL,NULL,NULL),
-- Massage children
(6,'Foot Massage','foot-massage','service',1,1,1,NULL,NULL,NULL,NULL,NULL),
(7,'Body Massage','body-massage','service',1,2,1,NULL,NULL,NULL,NULL,NULL),
-- Body massage children
(8,'Body Aroma Massage','aroma-massage','service',7,1,1,NULL,NULL,NULL,NULL,NULL),
(9,'Body Thai Massage','thai-massage','service',7,2,1,NULL,NULL,NULL,NULL,NULL),
(10,'Body Bamboo Massage','bamboo-massage','service',7,3,1,NULL,NULL,NULL,NULL,NULL),
-- Shampoo children
(11,'Shampoo And Massage','shampoo-and-massage','service',2,1,1,NULL,NULL,NULL,NULL,NULL),
(12,'Shampoo And Facial','shampoo-and-facial','service',2,2,1,NULL,NULL,NULL,NULL,NULL),
-- Blog children
(13,'Blog Massage','massage','blog',5,1,1,NULL,NULL,NULL,NULL,NULL),
(14,'Blog Shampoo','shampoo','blog',5,2,1,NULL,NULL,NULL,NULL,NULL);
Updated by Minh Trung Nguyễn 17 days ago · Edited
CREATE TABLE hans_spa_category_urls (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
category_id INT UNSIGNED NOT NULL,
full_path VARCHAR(500) NOT NULL,
is_primary TINYINT(1) DEFAULT 1,
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
UNIQUE KEY uq_category_url (full_path),
INDEX idx_category_id (category_id)
);
INSERT INTO hans_spa_category_urls (category_id, full_path, is_primary)
VALUES
-- massage
(1,'massage',1),
-- massage con
(6,'massage/foot-massage',1),
(7,'massage/body-massage',1),
-- aroma / thai / bamboo (KHÔNG theo cây cha)
(8,'aroma-massage',1),
(9,'thai-massage',1),
(10,'bamboo-massage',1),
-- shampoo
(2,'shampoo',1),
(11,'shampoo/shampoo-and-massage',1),
(12,'shampoo/shampoo-and-facial',1),
-- nail
(3,'nail',1),
-- blog
(5,'blog',1),
(13, 'blog/massage', 1),
(14, 'blog/shampoo', 1);
Updated by Minh Trung Nguyễn 17 days ago · Edited
CREATE TABLE hans_spa_posts (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
category_id INT UNSIGNED NOT NULL,
title VARCHAR(255) NOT NULL,
slug VARCHAR(255) DEFAULT NULL,
content LONGTEXT DEFAULT NULL,
featured_image VARCHAR(500) DEFAULT NULL,
meta_title VARCHAR(255) DEFAULT NULL,
meta_keyword VARCHAR(255) DEFAULT NULL,
meta_description VARCHAR(255) DEFAULT NULL,
is_publish TINYINT(1) DEFAULT 1,
is_hot TINYINT(1) DEFAULT 0,
created_by INT UNSIGNED DEFAULT NULL,
updated_by INT UNSIGNED DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-- slug chỉ cần unique trong cùng blog category
UNIQUE KEY uq_post_slug (slug, category_id),
INDEX idx_category (category_id),
INDEX idx_publish (is_publish)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
INSERT INTO hans_spa_posts
(category_id, title, slug, content, meta_title, meta_keyword, meta_description, is_publish, created_by)
VALUES
(1,
'Massage',
NULL,
'Dịch vụ massage body toàn thân giúp thư giãn và phục hồi năng lượng.',
'Massage body thư giãn',
'massage body, thư giãn',
'Dịch vụ massage body giúp thư giãn và phục hồi năng lượng',
1, 1),
(7,
'Massage Body',
NULL,
'Dịch vụ massage body cao cấp giúp thư giãn toàn thân, giảm căng thẳng và phục hồi năng lượng.',
'Massage body cao cấp',
'massage body cao cấp',
'Dịch vụ massage body cao cấp',
1, 1),
(8,
'Massage Aroma',
NULL,
'Liệu trình massage tinh dầu Aroma giúp thư giãn tinh thần, giảm stress và phục hồi năng lượng.',
'Massage tinh dầu Aroma',
'massage aroma, tinh dầu',
'Massage tinh dầu Aroma giúp thư giãn sâu',
1, 1),
(5,
'Massage đá nóng là gì?',
'massage-da-nong-la-gi',
'Massage bằng đá nóng giúp lưu thông khí huyết và thư giãn sâu.',
'test1',
'test2',
'test3',
1, 1),
(5,
'Massage đá nóng là gì1?',
'massage-da-nong-la-gi1',
'Massage bằng đá nóng giúp lưu thông khí huyết và thư giãn sâu1.',
'test11',
'test21',
'test31',
1, 1),
(13,
'Massage đá nóng là gì?',
'massage-da-nong-la-gi',
'Massage bằng đá nóng giúp thư giãn sâu...',
'test11',
'test21',
'test31',
1, 1),
(13,
'Massage đá nóng là gì1?',
'massage-da-nong-la-gi1',
'Massage bằng đá nóng giúp thư giãn sâu1...',
'test11',
'test21',
'test31',
1, 1);
Updated by Redmine Admin 13 days ago
CREATE TABLE hans_spa_post_products (
id int UNSIGNED AUTO_INCREMENT PRIMARY KEY,
post_id int UNSIGNED NOT NULL,
title VARCHAR(255) NOT NULL,
price int NOT NULL,
sale_price INT DEFAULT NULL,
duration INT NOT NULL COMMENT 'Thời lượng (phút)',
note VARCHAR(255) DEFAULT NULL,
created_by INT UNSIGNED DEFAULT NULL,
updated_by INT UNSIGNED DEFAULT NULL,
created_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_post_id (post_id)
);
INSERT INTO hans_spa_post_products
(id, post_id, title, duration, price, sale_price, note, created_by, updated_by)
VALUES
-- Post 1: Massage body
(1, 1, 'Massage body', 60, 300000, NULL, 'Phù hợp thư giãn cơ bản', 1, NULL),
(2, 1, 'Massage body1', 90, 450000, 420000, 'Ưu đãi gói 90 phút', 1, NULL),
-- Post 2: Massage đá nóng
(3, 2, 'Massage đá nóng', 60, 350000, NULL, 'Đá nóng Himalaya', 1, NULL),
(4, 2, 'Massage đá nóng1', 90, 500000, 470000, 'Ưu đãi gói 90 phút', 1, NULL),
-- Post 4: Massage body tinh dầu
(5, 4, 'Massage body tinh dầu', 60, 350000, NULL, 'Tinh dầu thiên nhiên', 1, NULL),
(6, 4, 'Massage body tinh dầu1', 90, 500000, 460000, 'Ưu đãi thư giãn sâu', 1, NULL),
(7, 4, 'Massage body tinh dầu2', 120, 650000, 600000, 'Combo 120 phút tiết kiệm', 1, NULL);