From 640105972eb37ecae3b23f6b240a3536b35afaa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Thu, 3 Mar 2022 22:06:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9B=E5=BB=BAOrderModel=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=A1=A8=EF=BC=8C=E5=B9=B6=E4=BD=BF=E7=94=A8mybatis-g?= =?UTF-8?q?enerator=E7=94=9F=E6=88=90Mappder=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Others/sql/flashsale.sql | 50 +++-- .../flashsale/dao/OrderDOMapper.java | 53 +++++ .../flashsale/dataobject/OrderDO.java | 203 ++++++++++++++++++ .../flashsale/service/model/OrderModel.java | 73 +++++++ src/main/resources/mapping/OrderDOMapper.xml | 146 +++++++++++++ src/main/resources/mybatis-generator.xml | 5 +- 6 files changed, 513 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/cxyxiaomo/flashsale/dao/OrderDOMapper.java create mode 100644 src/main/java/com/cxyxiaomo/flashsale/dataobject/OrderDO.java create mode 100644 src/main/java/com/cxyxiaomo/flashsale/service/model/OrderModel.java create mode 100644 src/main/resources/mapping/OrderDOMapper.xml diff --git a/Others/sql/flashsale.sql b/Others/sql/flashsale.sql index d813b66..372b68a 100644 --- a/Others/sql/flashsale.sql +++ b/Others/sql/flashsale.sql @@ -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 -- ---------------------------- diff --git a/src/main/java/com/cxyxiaomo/flashsale/dao/OrderDOMapper.java b/src/main/java/com/cxyxiaomo/flashsale/dao/OrderDOMapper.java new file mode 100644 index 0000000..0de7dcb --- /dev/null +++ b/src/main/java/com/cxyxiaomo/flashsale/dao/OrderDOMapper.java @@ -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); +} \ No newline at end of file diff --git a/src/main/java/com/cxyxiaomo/flashsale/dataobject/OrderDO.java b/src/main/java/com/cxyxiaomo/flashsale/dataobject/OrderDO.java new file mode 100644 index 0000000..b5bdd9d --- /dev/null +++ b/src/main/java/com/cxyxiaomo/flashsale/dataobject/OrderDO.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/cxyxiaomo/flashsale/service/model/OrderModel.java b/src/main/java/com/cxyxiaomo/flashsale/service/model/OrderModel.java new file mode 100644 index 0000000..f054175 --- /dev/null +++ b/src/main/java/com/cxyxiaomo/flashsale/service/model/OrderModel.java @@ -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; + } +} diff --git a/src/main/resources/mapping/OrderDOMapper.xml b/src/main/resources/mapping/OrderDOMapper.xml new file mode 100644 index 0000000..c607386 --- /dev/null +++ b/src/main/resources/mapping/OrderDOMapper.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + id, user_id, item_id, item_pirce, amount, order_price + + + + + delete from order_info + where id = #{id,jdbcType=VARCHAR} + + + + 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 into order_info + + + id, + + + user_id, + + + item_id, + + + item_pirce, + + + amount, + + + order_price, + + + + + #{id,jdbcType=VARCHAR}, + + + #{userId,jdbcType=INTEGER}, + + + #{itemId,jdbcType=INTEGER}, + + + #{itemPirce,jdbcType=DECIMAL}, + + + #{amount,jdbcType=INTEGER}, + + + #{orderPrice,jdbcType=DECIMAL}, + + + + + + update order_info + + + 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 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} + + \ No newline at end of file diff --git a/src/main/resources/mybatis-generator.xml b/src/main/resources/mybatis-generator.xml index 34248a1..71a1ce4 100644 --- a/src/main/resources/mybatis-generator.xml +++ b/src/main/resources/mybatis-generator.xml @@ -7,7 +7,7 @@ @@ -53,6 +53,9 @@ + + + \ No newline at end of file