-- ----------------------------
-- Table structure for goods_cate 商品分类表
-- ----------------------------
DROP TABLE IF EXISTS `goods_cate`;
CREATE TABLE `goods_cate` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT '标题',
`cate_img` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT '分类图片',
`link` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT '跳转地址',
`template` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT '加载的模板: 为空的话加载默认模板, 不为空的话加载自定义模板',
`pid` int(0) NULL DEFAULT NULL COMENT '上级id: 为0的话则是顶级分类',
`sub_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT 'SEO标题',
`keywords` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT 'SEO关键字',
`description` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT 'SEO描述',
`status` tinyint(1) NULL DEFAULT NULL COMENT '排序',
`sort` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMENT '状态: 1 显示, 0 隐藏',
`add_time` int(0) NULL DEFAULT NULL COMENT '添加时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 35 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for goods_type 商品类型表
-- ----------------------------
DROP TABLE IF EXISTS `goods_type`;
CREATE TABLE `goods_type` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '类型名称',
`description` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '介绍',
`status` int(0) NULL DEFAULT NULL COMMENT '状态',
`add_time` int(0) NULL DEFAULT NULL COMMENT '添加时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for goods_type_attribute 商品类型属性表
-- ----------------------------
DROP TABLE IF EXISTS `goods_type_attribute`;
CREATE TABLE `goods_type_attribute` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`cate_id` int(0) NULL DEFAULT NULL COMMENT '商品类型id:商品类型表goods_type.id',
`title` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性名称',
`attr_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '属性录入方式: 1 单行文本框, 2 多行文本框, 3 从下面列表中选择(一行代表一个可选值)',
`attr_value` varchar(1024) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '可选值列表',
`status` tinyint(1) NULL DEFAULT NULL COMMENT '状态',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
`add_time` int(0) NULL DEFAULT NULL COMMENT '增加时间',
PRIMARY KEY (`id`) USING BTREE,
INDEX `cate_id`(`cate_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
以电脑类型为例
以电脑类型为例
以电脑类型为例
在增加/修改商品 规格包装时使用,以电脑类型为例
-- ----------------------------
-- Table structure for goods 商品表
-- ----------------------------
DROP TABLE IF EXISTS `goods`;
CREATE TABLE `goods` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品标题',
`sub_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '附属标题:用于SEO搜索',
`goods_sn` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品编号',
`cate_id` int(0) NULL DEFAULT NULL COMMENT '商品分类id: 商品分类表goods_cate.id',
`click_count` int(0) NULL DEFAULT NULL COMMENT '商品点击数量',
`goods_number` int(0) NULL DEFAULT NULL COMMENT '商品库存',
`price` decimal(10, 2) NULL DEFAULT NULL COMMENT '价格',
`market_price` decimal(10, 2) NULL DEFAULT NULL COMMENT '商品市场价(原价)',
`relation_goods` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '关联商品id,如: 1, 23,55 ,商品id以逗号隔开',
`goods_attr` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品更多属性',
`goods_color` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品版本',
`goods_version` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '图片',
`goods_img` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品赠品',
`goods_gift` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '商品配件',
`goods_fitting` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '颜色',
`goods_keywords` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'SEO关键字',
`goods_desc` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT 'SEO商品描述',
`goods_content` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL COMMENT '商品详情',
`is_delete` tinyint(0) NULL DEFAULT NULL COMMENT '是否删除',
`is_hot` tinyint(0) NULL DEFAULT NULL COMMENT '是否热销',
`is_best` tinyint(0) NULL DEFAULT NULL COMMENT '是否精品',
`is_new` tinyint(0) NULL DEFAULT NULL COMMENT '是否新品',
`goods_type_id` int(0) NULL DEFAULT NULL COMMENT '商品类型id,关联GoodsType.Id',
`sort` int(0) NULL DEFAULT NULL COMMENT '排序',
`status` tinyint(0) NULL DEFAULT NULL COMMENT '状态',
`add_time` int(0) NULL DEFAULT NULL COMMENT '添加时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 39 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for goods_attr 商品属性表(保存规格包装-商品类型对应的数据)
-- ----------------------------
DROP TABLE IF EXISTS `goods_attr`;
CREATE TABLE `goods_attr` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`goods_id` int(0) NULL DEFAULT NULL COMMENT '商品id:关联表goods.id',
`attribute_cate_id` int(0) NULL DEFAULT NULL COMMENT '商品类型id,关联表goods_type.id',
`attribute_id` int(0) NULL DEFAULT NULL COMMENT '商品类型属性id,关联表goods_type_attribute.id',
`attribute_title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型属性标题',
`attribute_type` tinyint(1) NULL DEFAULT NULL COMMENT '类型属性录入方式:关联表goods_type_attribute.attr_type',
`attribute_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '类型属性值',
`sort` int(0) NULL DEFAULT NULL COMMENT '',
`add_time` int(0) NULL DEFAULT NULL COMMENT '',
`status` tinyint(1) NULL DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 113 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for goods_image 商品相册表
-- ----------------------------
DROP TABLE IF EXISTS `goods_image`;
CREATE TABLE `goods_image` (
`id` int(0) NOT NULL AUTO_INCREMENT COMMENT '',
`goods_id` int(0) NULL DEFAULT NULL COMMENT '商品id',
`img_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '图片保存路径:一般只会保存类似于/static/upload/20230313/xxx.png这种格式',
`color_id` int(0) NULL DEFAULT NULL COMMENT '颜色id',
`sort` int(0) NULL DEFAULT NULL COMMENT '',
`add_time` int(0) NULL DEFAULT NULL COMMENT '',
`status` tinyint(1) NULL DEFAULT NULL COMMENT '',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Table structure for goods_color 商品颜色
-- ----------------------------
DROP TABLE IF EXISTS `goods_color`;
CREATE TABLE `goods_color` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`color_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMEMT '颜色名称',
`color_value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMEMT '颜色标记,如:red,#000'',
`status` int(0) NULL DEFAULT NULL COMMENT '状态',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
需要用到商品分类表goods_cate,选择所属分类
需要用到商品颜色表goods_color,选择商品颜色
需要用到商品类型表goods_type,商品类型属性表goods_type_attribute,选择商品类型,以及设置类型对应的属性,完成后保存数据到商品属性表goods_attr中
选择图片,保存到商品相册表goods_image中
[上一节][golang gin框架] 15.Gin 商城项目-封装上传图片方法,轮播图的增删改查以及异步修改状态,数量
[下一节][golang gin框架] 17.Gin 商城项目-商品分类模块, 商品类型模块,商品类型属性模块功能操作