1
0
mirror of https://gitee.com/coder-xiaomo/flashsale synced 2025-01-10 11:48:14 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

创建OrderModel和数据表,并使用mybatis-generator生成Mappder文件

This commit is contained in:
程序员小墨 2022-03-03 22:06:09 +08:00
parent 544cd6b69e
commit 640105972e
6 changed files with 513 additions and 17 deletions

View File

@ -11,7 +11,7 @@
Target Server Version : 50726
File Encoding : 65001
Date: 03/03/2022 18:37:04
Date: 03/03/2022 22:01:38
*/
SET NAMES utf8mb4;
@ -34,21 +34,21 @@ CREATE TABLE `item_info` (
-- ----------------------------
-- Records of item_info
-- ----------------------------
INSERT INTO `item_info` VALUES (1, 'item-h7p0wt-22680', 22.00, '0sddhs4aeowc26638j5fp2ox', 0, 'https://domain.com/pic/190ghi.jpg');
INSERT INTO `item_info` VALUES (2, '电视机', 1800.00, '一台电视机', 0, 'https://domain.com/pic/television.png');
INSERT INTO `item_info` VALUES (3, '电冰箱', 2800.00, '一台电冰箱', 0, 'https://domain.com/pic/电冰箱.png');
INSERT INTO `item_info` VALUES (4, '空调', 3600.00, '一台空调', 0, 'https://domain.com/pic/空调.png');
INSERT INTO `item_info` VALUES (5, 'item-2xmm6g-5492', 235.00, 'lsudsf67ghobos3q1olbwx27', 0, 'https://domain.com/pic/1fvojf.jpg');
INSERT INTO `item_info` VALUES (6, 'item-wlx9gu-1220', 270.00, '3q234qqp3wwo53mtdv0qjuvg', 0, 'https://domain.com/pic/tkxc5q.jpg');
INSERT INTO `item_info` VALUES (7, 'item-cqru11-3487', 259.00, '04q6lopvj3ubb4458k4wldok', 0, 'https://domain.com/pic/nxmx2h.jpg');
INSERT INTO `item_info` VALUES (8, 'item-7f7qa1-5168', 314.00, 'jqkgc5ks2r9e2k8za3zs9rlc', 0, 'https://domain.com/pic/gvwtzd.jpg');
INSERT INTO `item_info` VALUES (9, 'item-i8flrb-7649', 129.00, 'i0m9w2x5w4gugeq7hlyp8nqx', 0, 'https://domain.com/pic/rz85vu.jpg');
INSERT INTO `item_info` VALUES (10, 'item-epo4p3-8545', 40.00, 'x71zeodg46ziiid7pgfag4bc', 0, 'https://domain.com/pic/o0f3uk.jpg');
INSERT INTO `item_info` VALUES (11, 'item-o7iiuj-1056', 322.00, 'fm3r99ko038jbfhy5cg7kwp8', 0, 'https://domain.com/pic/u0rjr8.jpg');
INSERT INTO `item_info` VALUES (12, 'item-fi7q7p-11366', 24.00, '18e54me0cdbqt8n9mxjnisf8', 0, 'https://domain.com/pic/eetb26.jpg');
INSERT INTO `item_info` VALUES (13, 'item-9lwcps-12165', 9.00, 'hlxnhcfak89wengpsnehgtqs', 0, 'https://domain.com/pic/r9yxmi.jpg');
INSERT INTO `item_info` VALUES (14, 'item-pgdbqk-12664', 151.00, 'irydvab5wixg59c7scgt50yh', 0, 'https://domain.com/pic/xvfgwv.jpg');
INSERT INTO `item_info` VALUES (15, 'item-0lq98b-13424', 164.00, 'vwz4rsb4qhsnjs3phos35415', 0, 'https://domain.com/pic/9qhi3l.jpg');
INSERT INTO `item_info` VALUES (1, 'item-h7p0wt-22680', 22.00, '0sddhs4aeowc26638j5fp2ox', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (2, '电视机', 1800.00, '一台电视机', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (3, '电冰箱', 2800.00, '一台电冰箱', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (4, '空调', 3600.00, '一台空调', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (5, 'item-2xmm6g-5492', 235.00, 'lsudsf67ghobos3q1olbwx27', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (6, 'item-wlx9gu-1220', 270.00, '3q234qqp3wwo53mtdv0qjuvg', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (7, 'item-cqru11-3487', 259.00, '04q6lopvj3ubb4458k4wldok', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (8, 'item-7f7qa1-5168', 314.00, 'jqkgc5ks2r9e2k8za3zs9rlc', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (9, 'item-i8flrb-7649', 129.00, 'i0m9w2x5w4gugeq7hlyp8nqx', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (10, 'item-epo4p3-8545', 40.00, 'x71zeodg46ziiid7pgfag4bc', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (11, 'item-o7iiuj-1056', 322.00, 'fm3r99ko038jbfhy5cg7kwp8', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (12, 'item-fi7q7p-11366', 24.00, '18e54me0cdbqt8n9mxjnisf8', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (13, 'item-9lwcps-12165', 9.00, 'hlxnhcfak89wengpsnehgtqs', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (14, 'item-pgdbqk-12664', 151.00, 'irydvab5wixg59c7scgt50yh', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
INSERT INTO `item_info` VALUES (15, 'item-0lq98b-13424', 164.00, 'vwz4rsb4qhsnjs3phos35415', 0, 'https://ns-strategy.cdn.bcebos.com/ns-strategy/upload/fc_big_pic/part-00015-3050.jpg');
-- ----------------------------
-- Table structure for item_stock
@ -82,6 +82,24 @@ INSERT INTO `item_stock` VALUES (13, 351, 13);
INSERT INTO `item_stock` VALUES (14, 117, 14);
INSERT INTO `item_stock` VALUES (15, 34, 15);
-- ----------------------------
-- Table structure for order_info
-- ----------------------------
DROP TABLE IF EXISTS `order_info`;
CREATE TABLE `order_info` (
`id` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`user_id` int(11) NOT NULL DEFAULT 0,
`item_id` int(11) NOT NULL,
`item_pirce` decimal(10, 2) NOT NULL,
`amount` int(255) NOT NULL,
`order_price` decimal(10, 2) NOT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of order_info
-- ----------------------------
-- ----------------------------
-- Table structure for user_info
-- ----------------------------

View File

@ -0,0 +1,53 @@
package com.cxyxiaomo.flashsale.dao;
import com.cxyxiaomo.flashsale.dataobject.OrderDO;
public interface OrderDOMapper {
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
int deleteByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
int insert(OrderDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
int insertSelective(OrderDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
OrderDO selectByPrimaryKey(String id);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
int updateByPrimaryKeySelective(OrderDO record);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table order_info
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
int updateByPrimaryKey(OrderDO record);
}

View File

@ -0,0 +1,203 @@
package com.cxyxiaomo.flashsale.dataobject;
import java.math.BigDecimal;
public class OrderDO {
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private String id;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.user_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private Integer userId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.item_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private Integer itemId;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.item_pirce
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private BigDecimal itemPirce;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.amount
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private Integer amount;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column order_info.order_price
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
private BigDecimal orderPrice;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.id
*
* @return the value of order_info.id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public String getId() {
return id;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.id
*
* @param id the value for order_info.id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setId(String id) {
this.id = id == null ? null : id.trim();
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.user_id
*
* @return the value of order_info.user_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public Integer getUserId() {
return userId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.user_id
*
* @param userId the value for order_info.user_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setUserId(Integer userId) {
this.userId = userId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.item_id
*
* @return the value of order_info.item_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public Integer getItemId() {
return itemId;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.item_id
*
* @param itemId the value for order_info.item_id
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setItemId(Integer itemId) {
this.itemId = itemId;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.item_pirce
*
* @return the value of order_info.item_pirce
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public BigDecimal getItemPirce() {
return itemPirce;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.item_pirce
*
* @param itemPirce the value for order_info.item_pirce
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setItemPirce(BigDecimal itemPirce) {
this.itemPirce = itemPirce;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.amount
*
* @return the value of order_info.amount
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public Integer getAmount() {
return amount;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.amount
*
* @param amount the value for order_info.amount
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setAmount(Integer amount) {
this.amount = amount;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column order_info.order_price
*
* @return the value of order_info.order_price
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public BigDecimal getOrderPrice() {
return orderPrice;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column order_info.order_price
*
* @param orderPrice the value for order_info.order_price
*
* @mbg.generated Thu Mar 03 22:04:45 CST 2022
*/
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
}

View File

@ -0,0 +1,73 @@
package com.cxyxiaomo.flashsale.service.model;
import java.math.BigDecimal;
// 用户下单的交易模型
public class OrderModel {
// 交易号
private String id;
// 用户id
private Integer userId;
// 购买的商品Id
private Integer itemId;
// 购买商品的单价
private BigDecimal itemPrice;
// 购买数量
private Integer amount;
// 购买金额
private BigDecimal orderPrice;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getItemId() {
return itemId;
}
public void setItemId(Integer itemId) {
this.itemId = itemId;
}
public BigDecimal getItemPrice() {
return itemPrice;
}
public void setItemPrice(BigDecimal itemPrice) {
this.itemPrice = itemPrice;
}
public Integer getAmount() {
return amount;
}
public void setAmount(Integer amount) {
this.amount = amount;
}
public BigDecimal getOrderPrice() {
return orderPrice;
}
public void setOrderPrice(BigDecimal orderPrice) {
this.orderPrice = orderPrice;
}
}

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cxyxiaomo.flashsale.dao.OrderDOMapper">
<resultMap id="BaseResultMap" type="com.cxyxiaomo.flashsale.dataobject.OrderDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="user_id" jdbcType="INTEGER" property="userId" />
<result column="item_id" jdbcType="INTEGER" property="itemId" />
<result column="item_pirce" jdbcType="DECIMAL" property="itemPirce" />
<result column="amount" jdbcType="INTEGER" property="amount" />
<result column="order_price" jdbcType="DECIMAL" property="orderPrice" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
id, user_id, item_id, item_pirce, amount, order_price
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
select
<include refid="Base_Column_List" />
from order_info
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
delete from order_info
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.cxyxiaomo.flashsale.dataobject.OrderDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
insert into order_info (id, user_id, item_id,
item_pirce, amount, order_price
)
values (#{id,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, #{itemId,jdbcType=INTEGER},
#{itemPirce,jdbcType=DECIMAL}, #{amount,jdbcType=INTEGER}, #{orderPrice,jdbcType=DECIMAL}
)
</insert>
<insert id="insertSelective" parameterType="com.cxyxiaomo.flashsale.dataobject.OrderDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
insert into order_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="itemId != null">
item_id,
</if>
<if test="itemPirce != null">
item_pirce,
</if>
<if test="amount != null">
amount,
</if>
<if test="orderPrice != null">
order_price,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=INTEGER},
</if>
<if test="itemId != null">
#{itemId,jdbcType=INTEGER},
</if>
<if test="itemPirce != null">
#{itemPirce,jdbcType=DECIMAL},
</if>
<if test="amount != null">
#{amount,jdbcType=INTEGER},
</if>
<if test="orderPrice != null">
#{orderPrice,jdbcType=DECIMAL},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.cxyxiaomo.flashsale.dataobject.OrderDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
update order_info
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=INTEGER},
</if>
<if test="itemId != null">
item_id = #{itemId,jdbcType=INTEGER},
</if>
<if test="itemPirce != null">
item_pirce = #{itemPirce,jdbcType=DECIMAL},
</if>
<if test="amount != null">
amount = #{amount,jdbcType=INTEGER},
</if>
<if test="orderPrice != null">
order_price = #{orderPrice,jdbcType=DECIMAL},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.cxyxiaomo.flashsale.dataobject.OrderDO">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Mar 03 22:04:45 CST 2022.
-->
update order_info
set user_id = #{userId,jdbcType=INTEGER},
item_id = #{itemId,jdbcType=INTEGER},
item_pirce = #{itemPirce,jdbcType=DECIMAL},
amount = #{amount,jdbcType=INTEGER},
order_price = #{orderPrice,jdbcType=DECIMAL}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>

View File

@ -7,7 +7,7 @@
<context id="DB2Tables" targetRuntime="MyBatis3">
<!-- 数据库链接地址账号密码 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://127.0.0.1:3306/flashsale?serverTimezone=Asia/Shanghai"
connectionURL="jdbc:mysql://127.0.0.1:3306/flashsale?serverTimezone=Asia/Shanghai&amp;useSSL=false"
userId="root"
password="111111">
</jdbcConnection>
@ -53,6 +53,9 @@
<!--<table tableName="item_stock" domainObjectName="ItemStockDO" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"></table>-->
<!--<table tableName="order_info" domainObjectName="OrderDO" enableCountByExample="false"-->
<!-- enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"-->
<!-- selectByExampleQueryId="false"></table>-->
</context>
</generatorConfiguration>