一、OrderModel

 1 package com.miaoshaProject.service.model;
 2 
 3 import java.math.BigDecimal;
 4 
 5 /**
 6  * @Author wangshuo
 7  * @Date 2022/4/20, 8:45
 8  * 用户下单的交易模型
 9  */
10 public class OrderModel {
11 
12     //String类型id
13     private String id;
14 
15     private Integer userId;
16 
17     private Integer itemId;
18 
19     //商品数量
20     private Integer amount;
21 
22     //订单金额
23     private BigDecimal orderPrice;
24 
25     //冗余一个字段  购买商品的单价
26     private BigDecimal itemPrice;
27 
28     public String getId() {
29         return id;
30     }
31 
32     public void setId(String id) {
33         this.id = id;
34     }
35 
36     public Integer getUserId() {
37         return userId;
38     }
39 
40     public void setUserId(Integer userId) {
41         this.userId = userId;
42     }
43 
44     public Integer getItemId() {
45         return itemId;
46     }
47 
48     public void setItemId(Integer itemId) {
49         this.itemId = itemId;
50     }
51 
52     public Integer getAmount() {
53         return amount;
54     }
55 
56     public void setAmount(Integer amount) {
57         this.amount = amount;
58     }
59 
60     public BigDecimal getOrderPrice() {
61         return orderPrice;
62     }
63 
64     public void setOrderPrice(BigDecimal orderPrice) {
65         this.orderPrice = orderPrice;
66     }
67 
68     public BigDecimal getItemPrice() {
69         return itemPrice;
70     }
71 
72     public void setItemPrice(BigDecimal itemPrice) {
73         this.itemPrice = itemPrice;
74     }
75 }

 

二、sql

/*
 Navicat Premium Data Transfer

 Source Server         : testOne
 Source Server Type    : MySQL
 Source Server Version : 80028
 Source Host           : localhost:3306
 Source Schema         : miaosha

 Target Server Type    : MySQL
 Target Server Version : 80028
 File Encoding         : 65001

 Date: 20/04/2022 09:31:23
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for order_info
-- ----------------------------
DROP TABLE IF EXISTS `order_info`;
CREATE TABLE `order_info`  (
  `id` varchar(32) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `user_id` int(0) NOT NULL DEFAULT 0,
  `item_id` int(0) NOT NULL DEFAULT 0,
  `item_price` decimal(10, 2) NOT NULL DEFAULT 0.00,
  `amount` int(0) NOT NULL DEFAULT 0,
  `order_price` decimal(10, 2) NOT NULL DEFAULT 0.00,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;

SET FOREIGN_KEY_CHECKS = 1;

三、mybatis-generator.xml

        <!--订单表-->
        <table tableName="order_info" domainObjectName="OrderDO"
               enableCountByExample="false" enableUpdateByExample="false"
               enableDeleteByExample="false" enableSelectByExample="false"
               selectByExampleQueryId="false" enableInsert="true"
               enableDeleteByPrimaryKey="false"></table>