SpringBoot实战——微信点餐系统

1、初始化项目

  引入模块

  

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

2、application.properties

 (1)改成application.yml,yml可读性较强 编辑较为简单

 (2)添加数据库配置

  

spring:
  datasource:
    url: http://localhost:3036/sell?useUnicode=true&&characterEncoding=utf-8
    driver-class-name: com.mysql.jdbc.Driver
    username: root
    password: root
  jpa:
    show-sql: true
  freemarker:
    allow-request-override: false
    cache: false
    check-template-location: true
    charset: utf-8
    content-type: text/html
    suffix: .ftl
    template-loader-path: classpath:/templates/

3、创建数据库

CREATE TABLE `order_detail` (
  `detail_id` varchar(32) NOT NULL,
  `order_id` varchar(32) NOT NULL,
  `product_id` varchar(32) NOT NULL COMMENT 商品id,
  `product_name` varchar(32) NOT NULL COMMENT 商品名称,
  `product_price` decimal(8,2) NOT NULL COMMENT 商品价格,
  `prodiuct_quantity` int(11) NOT NULL COMMENT 商品数量,
  `product_icon` varchar(512) DEFAULT NULL COMMENT 商品小图,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 修改时间,
  PRIMARY KEY (`detail_id`),
  KEY `idx_order_id` (`order_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT=订单详情表;

CREATE TABLE `order_master` (
  `order_id` varchar(32) NOT NULL,
  `buyer_name` varchar(32) NOT NULL COMMENT 买家名字,
  `buyer_phone` varchar(32) NOT NULL COMMENT 买家电话,
  `buyer_address` varchar(32) NOT NULL COMMENT 买家地址,
  `buyer_openid` varchar(64) NOT NULL COMMENT 买家微信openId,
  `buyer_amount` decimal(8,2) NOT NULL COMMENT 订单总额,
  `buyer_status` tinyint(3) NOT NULL DEFAULT 0 COMMENT 订单状态,默认0新下单,
  `pay_status` tinyint(3) NOT NULL DEFAULT 0 COMMENT 支付状态,默认0未支付,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 修改时间,
  PRIMARY KEY (`order_id`),
  KEY `idx_buyer_openid` (`buyer_openid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT=订单表;

CREATE TABLE `product_category` (
  `category_id` int(11) NOT NULL AUTO_INCREMENT,
  `category_name` varchar(64) NOT NULL COMMENT 类别名称,
  `category_type` int(11) NOT NULL COMMENT 类名编号,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,
  PRIMARY KEY (`category_id`),
  UNIQUE KEY `uqe_category_type` (`category_type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT=类别表;

CREATE TABLE `product_info` (
  `product_id` varchar(32) NOT NULL,
  `product_name` varchar(64) NOT NULL COMMENT ‘产品名称,
  `product_price` decimal(8,2) NOT NULL COMMENT ‘价格,
  `product_stock` int(11) NOT NULL COMMENT ‘库存,
  `product_description` varchar(64) DEFAULT NULL COMMENT ‘描述,
  `product_icon` varchar(512) DEFAULT NULL COMMENT ‘图标,
  `product_type` int(11) NOT NULL COMMENT ‘产品类型,
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ‘创建时间,
  `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘更新时间,
  PRIMARY KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT=‘产品表;

 

SpringBoot实战——微信点餐系统

上一篇:微信小程序的Web API接口设计及常见接口实现


下一篇:微信商户号-产品中心找不到企业付款