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 '变更说明',
  `gross_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, '');