DROP TABLE IF EXISTS `dhc_product_info`;
CREATE TABLE `dhc_product_info` (
  `product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '产品ID',
  `product_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品名称',
  `product_code` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品编码',
  `category_large` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属大类编码',
  `category_middle` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属中类编码',
  `category_small` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属小类编码',
  `product_status` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '产品状态（0草稿 1在售 2下市 3冻结）',
  `brand_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '品牌名称',
  `brand_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '品牌编码',
  `sales_type` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '内外销标识（0内销 1外销 2内外销）',
  `description` varchar(500) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '产品描述',
  `version_no` varchar(32) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '1.0.0' COMMENT '版本号',
  `version_status` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '版本状态（0启用 1停用）',
  `change_desc` varchar(500) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '变更说明',
  `origin_place` varchar(100) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '产地',
  `gross_weight` decimal(16,4) DEFAULT '0.0000' COMMENT '毛重(kg)',
  `net_weight` decimal(16,4) DEFAULT '0.0000' COMMENT '净重(kg)',
  `package_length` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-长(mm)',
  `package_width` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-宽(mm)',
  `package_height` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-高(mm)',
  `ir_datetime` datetime DEFAULT NULL COMMENT 'IR时间',
  `dr_datetime` datetime DEFAULT NULL COMMENT 'DR时间',
  `production_version` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '生产版本',
  `sales_model` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '销售型号',
  `ext_properties` json DEFAULT NULL COMMENT '扩展属性（JSON格式）',
  `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
  `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`product_id`),
  UNIQUE KEY `idx_product_code_version` (`product_code`,`version_no`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='产品信息表';

-- 产品表
-- CREATE TABLE `dhc_product_info` (
--   `product_id` bigint NOT NULL AUTO_INCREMENT COMMENT '产品ID',
--   `product_name` varchar(100) COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品名称',
--   `product_code` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT '产品编码',
--   `category_large` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属大类编码',
--   `category_middle` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属中类编码',
--   `category_small` varchar(10) COLLATE utf8mb4_general_ci NOT NULL COMMENT '所属小类编码',
--   `product_status` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '产品状态（0草稿 1在售 2下市 3冻结）',
--   `brand_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '品牌名称',
--   `brand_code` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '品牌编码',
--   `sales_type` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '内外销标识（0内销 1外销 2内外销）',
--   `description` varchar(500) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '产品描述',
--   `ext_properties` json DEFAULT NULL COMMENT '扩展属性（JSON格式）',
--   `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
--   `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
--   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
--   `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
--   `update_time` datetime DEFAULT NULL COMMENT '更新时间',
--   PRIMARY KEY (`product_id`),
--   UNIQUE KEY `idx_product_code` (`product_code`)
-- ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='产品信息表';


CREATE TABLE `dhc_product_version` (
  `version_id` bigint NOT NULL AUTO_INCREMENT COMMENT '版本ID',
  `product_id` bigint NOT NULL COMMENT '产品ID',
  `version_no` varchar(32) COLLATE utf8mb4_general_ci NOT NULL COMMENT '版本号',
  `version_status` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '版本状态（0启用 1停用）',
  `change_desc` varchar(500) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '变更说明',
  `origin_place` varchar(100) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '产地',
  `gross_weight` decimal(16,4) DEFAULT '0.0000' COMMENT '毛重(kg)',
  `net_weight` decimal(16,4) DEFAULT '0.0000' COMMENT '净重(kg)',
  `package_length` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-长(mm)',
  `package_width` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-宽(mm)',
  `package_height` decimal(16,4) DEFAULT '0.0000' COMMENT '外包装尺寸-高(mm)',
  `ir_datetime` datetime DEFAULT NULL COMMENT 'IR时间',
  `dr_datetime` datetime DEFAULT NULL COMMENT 'DR时间',
  `production_version` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '生产版本',
  `sales_model` varchar(32) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '销售型号',
  `del_flag` char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标志（0代表存在 1代表删除）',
  `create_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '创建者',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_by` varchar(64) COLLATE utf8mb4_general_ci DEFAULT '' COMMENT '更新者',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`version_id`),
  UNIQUE KEY `idx_product_version` (`product_id`,`version_no`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='产品版本表';


---------------------------------------------------------------------------------------------------------
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品管理', '3', '1', 'product', 'gss/product/index', 1, 0, 'C', '0', '0', 'gss:product:list', 'product', 'admin', sysdate(), '', null, '产品管理菜单');

-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();

-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'gss:product:query',        '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'gss:product:add',          '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'gss:product:edit',         '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'gss:product:remove',       '#', 'admin', sysdate(), '', null, '');

insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
values('产品导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'gss:product:export',       '#', 'admin', sysdate(), '', null, '');


-----------------------------------------------------------------
-- 全产品表mock数据
-- 插入模拟数据
INSERT INTO `dhc_product_info` (`product_name`, `product_code`, `category_large`, `category_middle`, `category_small`, 
    `product_status`, `brand_name`, `brand_code`, `sales_type`, `description`, `version_no`, `version_status`, 
    `change_desc`, `origin_place`, `gross_weight`, `net_weight`, `package_length`, `package_width`, `package_height`, 
    `ir_datetime`, `dr_datetime`, `production_version`, `sales_model`, `ext_properties`, `create_by`, `create_time`)
VALUES 
    ('98英寸会议平板', 'CD001', 'D01', 'E01', 'F01', '1', '东华商显', 'DHC', '0', '98英寸4K超高清智能会议平板', '1.0.0', '0', '初始版本', '中国浙江', 98.5000, 85.2000, 2350.0000, 1400.0000, 160.0000, '2023-01-15 10:00:00', '2023-01-20 14:00:00', 'V1.0', 'IFP98-2023', '{"resolution": "3840x2160", "brightness": "500nits", "contrast": "1200:1"}', 'admin', NOW()),
    
    ('86英寸教育平板', 'CD002', 'D01', 'E01', 'F02', '1', '东华商显', 'DHC', '0', '86英寸教育交互式智能平板', '2.1.0', '0', '教育版本升级', '中国浙江', 78.6000, 65.3000, 2000.0000, 1220.0000, 150.0000, '2023-02-01 09:00:00', '2023-02-10 16:00:00', 'V2.1', 'IFP86-EDU', '{"resolution": "3840x2160", "touch_points": "40点", "speaker": "2x15W"}', 'admin', NOW()),
    
    ('75英寸商用显示器', 'CD003', 'D01', 'E02', 'F03', '1', '东华商显', 'DHC', '2', '75英寸商用广告机', '1.5.0', '0', '性能优化版本', '中国浙江', 45.8000, 38.2000, 1800.0000, 1100.0000, 120.0000, '2023-03-01 11:00:00', '2023-03-10 15:00:00', 'V1.5', 'DS75-PRO', '{"brightness": "700nits", "operation_time": "24/7", "orientation": "横竖双向"}', 'admin', NOW()),
    
    ('65英寸壁挂广告机', 'CD004', 'D01', 'E02', 'F04', '1', '东华商显', 'DHC', '1', '65英寸壁挂式数字标牌显示器', '1.0.1', '0', '初始版本', '中国浙江', 35.6000, 28.9000, 1600.0000, 950.0000, 100.0000, '2023-04-01 08:00:00', '2023-04-10 17:00:00', 'V1.0', 'DS65-WALL', '{"resolution": "3840x2160", "viewing_angle": "178°", "response_time": "8ms"}', 'admin', NOW()),
    
    ('55英寸户外广告机', 'CD005', 'D01', 'E03', 'F05', '1', '东华商显', 'DHC', '0', '55英寸高亮户外广告显示器', '2.0.0', '0', '户外防护升级', '中国浙江', 68.5000, 55.2000, 1400.0000, 850.0000, 200.0000, '2023-05-01 10:30:00', '2023-05-15 14:30:00', 'V2.0', 'DS55-OUT', '{"brightness": "2500nits", "protection": "IP65", "cooling": "智能温控"}', 'admin', NOW()),
    
    ('49英寸拼接屏', 'CD006', 'D01', 'E04', 'F06', '1', '东华商显', 'DHC', '2', '49英寸液晶拼接显示单元', '1.2.0', '0', '拼接优化版本', '中国浙江', 25.8000, 20.5000, 1200.0000, 700.0000, 95.0000, '2023-06-01 09:15:00', '2023-06-10 16:45:00', 'V1.2', 'DV49-SPLICE', '{"bezel": "1.8mm", "splice_control": "智能拼接", "calibration": "自动校色"}', 'admin', NOW()),
    
    ('43英寸条形屏', 'CD007', 'D01', 'E05', 'F07', '1', '东华商显', 'DHC', '0', '43英寸超宽条形商业显示器', '3.0.0', '0', '全新升级版本', '中国浙江', 18.5000, 15.2000, 1150.0000, 350.0000, 85.0000, '2023-07-01 11:20:00', '2023-07-12 15:20:00', 'V3.0', 'DB43-BAR', '{"aspect_ratio": "16:4.5", "application": "货架标签", "wireless": "WiFi6"}', 'admin', NOW()),
    
    ('32英寸桌面显示器', 'CD008', 'D01', 'E06', 'F08', '1', '东华商显', 'DHC', '1', '32英寸触控一体机', '1.1.0', '0', '触控升级版本', '中国浙江', 12.5000, 9.8000, 800.0000, 500.0000, 60.0000, '2023-08-01 10:40:00', '2023-08-11 14:40:00', 'V1.1', 'DT32-TOUCH', '{"touch_type": "电容触控", "stand": "可调底座", "interface": "Type-C"}', 'admin', NOW()),
    
    ('27英寸收银显示器', 'CD009', 'D01', 'E06', 'F09', '1', '东华商显', 'DHC', '0', '27英寸商用收银显示器', '2.2.0', '0', '功能增强版本', '中国浙江', 8.5000, 6.8000, 650.0000, 450.0000, 50.0000, '2023-09-01 09:50:00', '2023-09-13 16:50:00', 'V2.2', 'DT27-POS', '{"screen_type": "IPS", "vesa": "100x100", "power": "外置电源"}', 'admin', NOW()),
    
    ('15.6英寸台式显示器', 'CD010', 'D01', 'E07', 'F10', '1', '东华商显', 'DHC', '2', '15.6英寸触控显示器', '1.3.0', '0', '便携版本升级', '中国浙江', 3.5000, 2.8000, 400.0000, 250.0000, 30.0000, '2023-10-01 08:30:00', '2023-10-14 15:30:00', 'V1.3', 'DT15-PORT', '{"panel": "IPS", "touch": "十点触控", "portable": "便携支架"}', 'admin', NOW()),
    
    ('98英寸LED显示屏', 'CD011', 'D01', 'E08', 'F11', '1', '东华商显', 'DHC', '0', '98英寸LED商用大屏', '1.0.0', '0', '初始版本', '中国浙江', 125.0000, 102.0000, 2400.0000, 1450.0000, 180.0000, '2023-11-01 09:00:00', '2023-11-15 15:00:00', 'V1.0', 'LED98-PRO', '{"pixel_pitch": "1.25mm", "refresh": "3840Hz", "control": "智能控制"}', 'admin', NOW());