text: -- ----------------------------
  -- banner管理表
  -- ----------------------------
  DROP TABLE IF EXISTS `banner`;
  CREATE TABLE `banner` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `name` VARCHAR(50) DEFAULT NULL COMMENT 'Banner名称，通常作为标识',
      `description` VARCHAR(255) DEFAULT NULL COMMENT 'Banner描述',
      `delete_time` INT DEFAULT NULL,
      `update_time` INT DEFAULT NULL,
      PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='banner管理表';
  
  INSERT INTO `banner` VALUES ('1', '首页置顶', '首页轮播图', null, null);
  
  -- ----------------------------
  -- banner子项表
  -- ----------------------------
  DROP TABLE IF EXISTS `banner_item`;
  CREATE TABLE `banner_item` (
      `id` INT NOT NULL AUTO_INCREMENT,
      `img_id` INT NOT NULL COMMENT '外键，关联image表',
      `key_word` VARCHAR(100) NOT NULL COMMENT '执行关键字，根据不同的type有不同含义',
      `type` TINYINT NOT NULL DEFAULT '1' COMMENT '跳转类型，可能导向商品，可能导向专题页',
      `banner_id` INT NOT NULL COMMENT '外键，关联banner表',
      `delete_time` INT DEFAULT NULL,
      `update_time` INT DEFAULT NULL,
      PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='banner子项表';
  
  INSERT INTO `banner_item` VALUES ('1', '65', '6', '1', '1', null, null);
  INSERT INTO `banner_item` VALUES ('2', '2', '25', '1', '1', null, null);
  INSERT INTO `banner_item` VALUES ('3', '3', '11', '1', '1', null, null);
  INSERT INTO `banner_item` VALUES ('5', '1', '10', '1', '1', null, null);
  
  
  -- ----------------------------
  -- 图片总表
  -- ----------------------------
  DROP TABLE IF EXISTS `image`;
  CREATE TABLE `image` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `url` VARCHAR(255) NOT NULL COMMENT '图片路径',
    `from` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '1 来自本地，2 来自公网',
    `delete_time` INT DEFAULT NULL,
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='图片总表';
  
  
  INSERT INTO `image` VALUES ('1', '/banner-1a.png', '1', null, null);
  INSERT INTO `image` VALUES ('2', '/banner-2a.png', '1', null, null);
  INSERT INTO `image` VALUES ('3', '/banner-3a.png', '1', null, null);
  INSERT INTO `image` VALUES ('4', '/category-cake.png', '1', null, null);
  INSERT INTO `image` VALUES ('5', '/category-vg.png', '1', null, null);
  INSERT INTO `image` VALUES ('6', '/category-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('7', '/category-fry-a.png', '1', null, null);
  INSERT INTO `image` VALUES ('8', '/category-tea.png', '1', null, null);
  INSERT INTO `image` VALUES ('9', '/category-rice.png', '1', null, null);
  INSERT INTO `image` VALUES ('10', '/product-dryfruit@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('13', '/product-vg@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('14', '/product-rice@6.png', '1', null, null);
  INSERT INTO `image` VALUES ('16', '/1@theme.png', '1', null, null);
  INSERT INTO `image` VALUES ('17', '/2@theme.png', '1', null, null);
  INSERT INTO `image` VALUES ('18', '/3@theme.png', '1', null, null);
  INSERT INTO `image` VALUES ('19', '/detail-1@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('20', '/detail-2@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('21', '/detail-3@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('22', '/detail-4@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('23', '/detail-5@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('24', '/detail-6@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('25', '/detail-7@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('26', '/detail-8@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('27', '/detail-9@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('28', '/detail-11@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('29', '/detail-10@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('31', '/product-rice@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('32', '/product-tea@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('33', '/product-dryfruit@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('36', '/product-dryfruit@3.png', '1', null, null);
  INSERT INTO `image` VALUES ('37', '/product-dryfruit@4.png', '1', null, null);
  INSERT INTO `image` VALUES ('38', '/product-dryfruit@5.png', '1', null, null);
  INSERT INTO `image` VALUES ('39', '/product-dryfruit-a@6.png', '1', null, null);
  INSERT INTO `image` VALUES ('40', '/product-dryfruit@7.png', '1', null, null);
  INSERT INTO `image` VALUES ('41', '/product-rice@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('42', '/product-rice@3.png', '1', null, null);
  INSERT INTO `image` VALUES ('43', '/product-rice@4.png', '1', null, null);
  INSERT INTO `image` VALUES ('44', '/product-fry@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('45', '/product-fry@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('46', '/product-fry@3.png', '1', null, null);
  INSERT INTO `image` VALUES ('47', '/product-tea@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('48', '/product-tea@3.png', '1', null, null);
  INSERT INTO `image` VALUES ('49', '/1@theme-head.png', '1', null, null);
  INSERT INTO `image` VALUES ('50', '/2@theme-head.png', '1', null, null);
  INSERT INTO `image` VALUES ('51', '/3@theme-head.png', '1', null, null);
  INSERT INTO `image` VALUES ('52', '/product-cake@1.png', '1', null, null);
  INSERT INTO `image` VALUES ('53', '/product-cake@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('54', '/product-cake-a@3.png', '1', null, null);
  INSERT INTO `image` VALUES ('55', '/product-cake-a@4.png', '1', null, null);
  INSERT INTO `image` VALUES ('56', '/product-dryfruit@8.png', '1', null, null);
  INSERT INTO `image` VALUES ('57', '/product-fry@4.png', '1', null, null);
  INSERT INTO `image` VALUES ('58', '/product-fry@5.png', '1', null, null);
  INSERT INTO `image` VALUES ('59', '/product-rice@5.png', '1', null, null);
  INSERT INTO `image` VALUES ('60', '/product-rice@7.png', '1', null, null);
  INSERT INTO `image` VALUES ('62', '/detail-12@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('63', '/detail-13@1-dryfruit.png', '1', null, null);
  INSERT INTO `image` VALUES ('65', '/banner-4a.png', '1', null, null);
  INSERT INTO `image` VALUES ('66', '/product-vg@4.png', '1', null, null);
  INSERT INTO `image` VALUES ('67', '/product-vg@5.png', '1', null, null);
  INSERT INTO `image` VALUES ('68', '/product-vg@2.png', '1', null, null);
  INSERT INTO `image` VALUES ('69', '/product-vg@3.png', '1', null, null);
  
  
  -- ----------------------------
  -- 商品表
  -- ----------------------------
  DROP TABLE IF EXISTS `product`;
  CREATE TABLE `product` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(80) NOT NULL COMMENT '商品名称',
    `price` DECIMAL(6,2) NOT NULL COMMENT '价格,单位：分',
    `stock` INT NOT NULL DEFAULT '0' COMMENT '库存量',
    `delete_time` INT DEFAULT NULL,
    `category_id` INT DEFAULT NULL,
    `main_img_url` VARCHAR(255) DEFAULT NULL COMMENT '主图ID号，这是一个反范式设计，有一定的冗余',
    `from` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '图片来自 1 本地 ，2公网',
    `create_time` INT DEFAULT NULL COMMENT '创建时间',
    `update_time` INT DEFAULT NULL,
    `summary` VARCHAR(50) DEFAULT NULL COMMENT '摘要',
    `img_id` INT DEFAULT NULL COMMENT '图片外键',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT= '商品表';
  
  INSERT INTO `product` VALUES ('1', '芹菜 半斤', '0.01', '998', null, '3', '/product-vg@1.png', '1', null, null, null, '13');
  INSERT INTO `product` VALUES ('2', '梨花带雨 3个', '0.01', '984', null, '2', '/product-dryfruit@1.png', '1', null, null, null, '10');
  INSERT INTO `product` VALUES ('3', '素米 327克', '0.01', '996', null, '7', '/product-rice@1.png', '1', null, null, null, '31');
  INSERT INTO `product` VALUES ('4', '红袖枸杞 6克*3袋', '0.01', '998', null, '6', '/product-tea@1.png', '1', null, null, null, '32');
  INSERT INTO `product` VALUES ('5', '春生龙眼 500克', '0.01', '995', null, '2', '/product-dryfruit@2.png', '1', null, null, null, '33');
  INSERT INTO `product` VALUES ('6', '小红的猪耳朵 120克', '0.01', '997', null, '5', '/product-cake@2.png', '1', null, null, null, '53');
  INSERT INTO `product` VALUES ('7', '泥蒿 半斤', '0.01', '998', null, '3', '/product-vg@2.png', '1', null, null, null, '68');
  INSERT INTO `product` VALUES ('8', '夏日芒果 3个', '0.01', '995', null, '2', '/product-dryfruit@3.png', '1', null, null, null, '36');
  INSERT INTO `product` VALUES ('9', '冬木红枣 500克', '0.01', '996', null, '2', '/product-dryfruit@4.png', '1', null, null, null, '37');
  INSERT INTO `product` VALUES ('10', '万紫千凤梨 300克', '0.01', '996', null, '2', '/product-dryfruit@5.png', '1', null, null, null, '38');
  INSERT INTO `product` VALUES ('11', '贵妃笑 100克', '0.01', '994', null, '2', '/product-dryfruit-a@6.png', '1', null, null, null, '39');
  INSERT INTO `product` VALUES ('12', '珍奇异果 3个', '0.01', '999', null, '2', '/product-dryfruit@7.png', '1', null, null, null, '40');
  INSERT INTO `product` VALUES ('13', '绿豆 125克', '0.01', '999', null, '7', '/product-rice@2.png', '1', null, null, null, '41');
  INSERT INTO `product` VALUES ('14', '芝麻 50克', '0.01', '999', null, '7', '/product-rice@3.png', '1', null, null, null, '42');
  INSERT INTO `product` VALUES ('15', '猴头菇 370克', '0.01', '999', null, '7', '/product-rice@4.png', '1', null, null, null, '43');
  INSERT INTO `product` VALUES ('16', '西红柿 1斤', '0.01', '999', null, '3', '/product-vg@3.png', '1', null, null, null, '69');
  INSERT INTO `product` VALUES ('17', '油炸花生 300克', '0.01', '999', null, '4', '/product-fry@1.png', '1', null, null, null, '44');
  INSERT INTO `product` VALUES ('18', '春泥西瓜子 128克', '0.01', '997', null, '4', '/product-fry@2.png', '1', null, null, null, '45');
  INSERT INTO `product` VALUES ('19', '碧水葵花籽 128克', '0.01', '999', null, '4', '/product-fry@3.png', '1', null, null, null, '46');
  INSERT INTO `product` VALUES ('20', '碧螺春 12克*3袋', '0.01', '999', null, '6', '/product-tea@2.png', '1', null, null, null, '47');
  INSERT INTO `product` VALUES ('21', '西湖龙井 8克*3袋', '0.01', '998', null, '6', '/product-tea@3.png', '1', null, null, null, '48');
  INSERT INTO `product` VALUES ('22', '梅兰清花糕 1个', '0.01', '997', null, '5', '/product-cake-a@3.png', '1', null, null, null, '54');
  INSERT INTO `product` VALUES ('23', '清凉薄荷糕 1个', '0.01', '998', null, '5', '/product-cake-a@4.png', '1', null, null, null, '55');
  INSERT INTO `product` VALUES ('25', '小明的妙脆角 120克', '0.01', '999', null, '5', '/product-cake@1.png', '1', null, null, null, '52');
  INSERT INTO `product` VALUES ('26', '红衣青瓜 混搭160克', '0.01', '999', null, '2', '/product-dryfruit@8.png', '1', null, null, null, '56');
  INSERT INTO `product` VALUES ('27', '锈色瓜子 100克', '0.01', '998', null, '4', '/product-fry@4.png', '1', null, null, null, '57');
  INSERT INTO `product` VALUES ('28', '春泥花生 200克', '0.01', '999', null, '4', '/product-fry@5.png', '1', null, null, null, '58');
  INSERT INTO `product` VALUES ('29', '冰心鸡蛋 2个', '0.01', '999', null, '7', '/product-rice@5.png', '1', null, null, null, '59');
  INSERT INTO `product` VALUES ('30', '八宝莲子 200克', '0.01', '999', null, '7', '/product-rice@6.png', '1', null, null, null, '14');
  INSERT INTO `product` VALUES ('31', '深涧木耳 78克', '0.01', '999', null, '7', '/product-rice@7.png', '1', null, null, null, '60');
  INSERT INTO `product` VALUES ('32', '土豆 半斤', '0.01', '999', null, '3', '/product-vg@4.png', '1', null, null, null, '66');
  INSERT INTO `product` VALUES ('33', '青椒 半斤', '0.01', '999', null, '3', '/product-vg@5.png', '1', null, null, null, '67');
  
  
  -- ----------------------------
  -- 主题信息表
  -- ----------------------------
  DROP TABLE IF EXISTS `theme`;
  CREATE TABLE `theme` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL COMMENT '专题名称',
    `description` VARCHAR(255) DEFAULT NULL COMMENT '专题描述',
    `topic_img_id` INT NOT NULL COMMENT '主题图，外键',
    `delete_time` INT DEFAULT NULL,
    `head_img_id` INT NOT NULL COMMENT '专题列表页，头图',
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题信息表';
  
  INSERT INTO `theme` VALUES ('1', '专题栏位一', '美味水果世界', '16', null, '49', null);
  INSERT INTO `theme` VALUES ('2', '专题栏位二', '新品推荐', '17', null, '50', null);
  INSERT INTO `theme` VALUES ('3', '专题栏位三', '做个干物女', '18', null, '18', null);
  
  
  -- ----------------------------
  -- 主题所包含的商品
  -- ----------------------------
  DROP TABLE IF EXISTS `theme_product`;
  CREATE TABLE `theme_product` (
    `theme_id` INT NOT NULL COMMENT '主题外键',
    `product_id` INT NOT NULL COMMENT '商品外键',
    PRIMARY KEY (`theme_id`,`product_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='主题所包含的商品';
  
  INSERT INTO `theme_product` VALUES ('1', '2');
  INSERT INTO `theme_product` VALUES ('1', '5');
  INSERT INTO `theme_product` VALUES ('1', '8');
  INSERT INTO `theme_product` VALUES ('1', '10');
  INSERT INTO `theme_product` VALUES ('1', '12');
  INSERT INTO `theme_product` VALUES ('2', '1');
  INSERT INTO `theme_product` VALUES ('2', '2');
  INSERT INTO `theme_product` VALUES ('2', '3');
  INSERT INTO `theme_product` VALUES ('2', '5');
  INSERT INTO `theme_product` VALUES ('2', '6');
  INSERT INTO `theme_product` VALUES ('2', '16');
  INSERT INTO `theme_product` VALUES ('2', '33');
  INSERT INTO `theme_product` VALUES ('3', '15');
  INSERT INTO `theme_product` VALUES ('3', '18');
  INSERT INTO `theme_product` VALUES ('3', '19');
  INSERT INTO `theme_product` VALUES ('3', '27');
  INSERT INTO `theme_product` VALUES ('3', '30');
  INSERT INTO `theme_product` VALUES ('3', '31');
  
  
  -- ----------------------------
  -- 商品类目
  -- ----------------------------
  DROP TABLE IF EXISTS `category`;
  CREATE TABLE `category` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL COMMENT '分类名称',
    `topic_img_id` INT DEFAULT NULL COMMENT '外键，关联image表',
    `delete_time` INT DEFAULT NULL,
    `description` VARCHAR(100) DEFAULT NULL COMMENT '描述',
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='商品类目';
  
  INSERT INTO `category` VALUES ('2', '果味', '6', null, null, null);
  INSERT INTO `category` VALUES ('3', '蔬菜', '5', null, null, null);
  INSERT INTO `category` VALUES ('4', '炒货', '7', null, null, null);
  INSERT INTO `category` VALUES ('5', '点心', '4', null, null, null);
  INSERT INTO `category` VALUES ('6', '粗茶', '8', null, null, null);
  INSERT INTO `category` VALUES ('7', '淡饭', '9', null, null, null);
  
  
  -- ----------------------------
  -- 用户信息
  -- ----------------------------
  DROP TABLE IF EXISTS `user`;
  CREATE TABLE `user` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `openid` VARCHAR(50) NOT NULL,
    `nickname` VARCHAR(50) DEFAULT NULL,
    `extend` VARCHAR(255) DEFAULT NULL,
    `delete_time` INT DEFAULT NULL,
    `create_time` INT DEFAULT NULL COMMENT '注册时间',
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `openid` (`openid`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  
  -- ----------------------------
  -- 商品详情图片
  -- ----------------------------
  DROP TABLE IF EXISTS `product_image`;
  CREATE TABLE `product_image` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `img_id` INT NOT NULL COMMENT '外键，关联图片表',
    `delete_time` INT DEFAULT NULL COMMENT '状态，主要表示是否删除，也可以扩展其他状态',
    `order` INT NOT NULL DEFAULT '0' COMMENT '图片排序序号',
    `product_id` INT NOT NULL COMMENT '商品id，外键',
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  INSERT INTO `product_image` VALUES ('4', '19', null, '1', '11');
  INSERT INTO `product_image` VALUES ('5', '20', null, '2', '11');
  INSERT INTO `product_image` VALUES ('6', '21', null, '3', '11');
  INSERT INTO `product_image` VALUES ('7', '22', null, '4', '11');
  INSERT INTO `product_image` VALUES ('8', '23', null, '5', '11');
  INSERT INTO `product_image` VALUES ('9', '24', null, '6', '11');
  INSERT INTO `product_image` VALUES ('10', '25', null, '7', '11');
  INSERT INTO `product_image` VALUES ('11', '26', null, '8', '11');
  INSERT INTO `product_image` VALUES ('12', '27', null, '9', '11');
  INSERT INTO `product_image` VALUES ('13', '28', null, '11', '11');
  INSERT INTO `product_image` VALUES ('14', '29', null, '10', '11');
  INSERT INTO `product_image` VALUES ('18', '62', null, '12', '11');
  INSERT INTO `product_image` VALUES ('19', '63', null, '13', '11');
  
  
  -- ----------------------------
  -- 商品参数
  -- ----------------------------
  DROP TABLE IF EXISTS `product_property`;
  CREATE TABLE `product_property` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(30) DEFAULT '' COMMENT '详情属性名称',
    `detail` VARCHAR(255) NOT NULL COMMENT '详情属性',
    `product_id` INT NOT NULL COMMENT '商品id，外键',
    `delete_time` INT DEFAULT NULL,
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  
  INSERT INTO `product_property` VALUES ('1', '品名', '杨梅', '11', null, null);
  INSERT INTO `product_property` VALUES ('2', '口味', '青梅味 雪梨味 黄桃味 菠萝味', '11', null, null);
  INSERT INTO `product_property` VALUES ('3', '产地', '火星', '11', null, null);
  INSERT INTO `product_property` VALUES ('4', '保质期', '180天', '11', null, null);
  INSERT INTO `product_property` VALUES ('5', '品名', '梨子', '2', null, null);
  INSERT INTO `product_property` VALUES ('6', '产地', '金星', '2', null, null);
  INSERT INTO `product_property` VALUES ('7', '净含量', '100g', '2', null, null);
  INSERT INTO `product_property` VALUES ('8', '保质期', '10天', '2', null, null);
  
  
  -- ----------------------------
  -- 用户地址表
  -- ----------------------------
  DROP TABLE IF EXISTS `user_address`;
  CREATE TABLE `user_address` (
    `id` INT NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(30) NOT NULL COMMENT '收获人姓名',
    `mobile` VARCHAR(20) NOT NULL COMMENT '手机号',
    `province` VARCHAR(20) DEFAULT NULL COMMENT '省',
    `city` VARCHAR(20) DEFAULT NULL COMMENT '市',
    `country` VARCHAR(20) DEFAULT NULL COMMENT '区',
    `detail` VARCHAR(100) DEFAULT NULL COMMENT '详细地址',
    `delete_time` INT DEFAULT NULL,
    `user_id` INT NOT NULL COMMENT '外键',
    `update_time` INT DEFAULT NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `user_id` (`user_id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;