From ca6e8eff220aca334603e22f7a18b1f397ade2bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=83=A5=E5=91=98=E5=91=98?= <7852974+xu_member@user.noreply.gitee.com> Date: Sat, 5 Nov 2022 21:42:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=86=E5=BA=93=E5=88=86=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/mapper/OrderConfigMapper.java | 15 ++++++++++ .../com/yupi/project/mapper/OrderMapper.java | 12 ++++++++ .../project/model/entity/OrderConfigDO.java | 25 +++++++++++++++++ .../yupi/project/model/entity/OrderDO.java | 23 +++++++++++++++ .../resources/mapper/OrderConfigMapper.xml | 22 +++++++++++++++ src/main/resources/mapper/OrderMapper.xml | 15 ++++++++++ src/main/resources/mybatis-config.xml | 20 +++++++++++++ .../service/OrderConfigMapperTest.java | 26 +++++++++++++++++ .../yupi/project/service/OrderMapperTest.java | 28 +++++++++++++++++++ 9 files changed, 186 insertions(+) create mode 100644 src/main/java/com/yupi/project/mapper/OrderConfigMapper.java create mode 100644 src/main/java/com/yupi/project/mapper/OrderMapper.java create mode 100644 src/main/java/com/yupi/project/model/entity/OrderConfigDO.java create mode 100644 src/main/java/com/yupi/project/model/entity/OrderDO.java create mode 100644 src/main/resources/mapper/OrderConfigMapper.xml create mode 100644 src/main/resources/mapper/OrderMapper.xml create mode 100644 src/main/resources/mybatis-config.xml create mode 100644 src/test/java/com/yupi/project/service/OrderConfigMapperTest.java create mode 100644 src/test/java/com/yupi/project/service/OrderMapperTest.java diff --git a/src/main/java/com/yupi/project/mapper/OrderConfigMapper.java b/src/main/java/com/yupi/project/mapper/OrderConfigMapper.java new file mode 100644 index 0000000..09e5bf5 --- /dev/null +++ b/src/main/java/com/yupi/project/mapper/OrderConfigMapper.java @@ -0,0 +1,15 @@ +package com.yupi.project.mapper; + +import com.yupi.project.model.entity.OrderConfigDO; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * @author Administrator + */ +@Mapper +public interface OrderConfigMapper { + + OrderConfigDO selectById(@Param("id") Integer id); + +} \ No newline at end of file diff --git a/src/main/java/com/yupi/project/mapper/OrderMapper.java b/src/main/java/com/yupi/project/mapper/OrderMapper.java new file mode 100644 index 0000000..99cb78d --- /dev/null +++ b/src/main/java/com/yupi/project/mapper/OrderMapper.java @@ -0,0 +1,12 @@ +package com.yupi.project.mapper; +import com.yupi.project.model.entity.OrderDO; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface OrderMapper { + + + + void insert(OrderDO order); + +} \ No newline at end of file diff --git a/src/main/java/com/yupi/project/model/entity/OrderConfigDO.java b/src/main/java/com/yupi/project/model/entity/OrderConfigDO.java new file mode 100644 index 0000000..7810e58 --- /dev/null +++ b/src/main/java/com/yupi/project/model/entity/OrderConfigDO.java @@ -0,0 +1,25 @@ +package com.yupi.project.model.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 订单配置 DO + */ +@Data +public class OrderConfigDO implements Serializable { + + /** + * 编号 + */ + private Integer id; + /** + * 支付超时时间 + * + * 单位:分钟 + */ + private Integer payTimeout; + + // ... 省略 setting/getting 方法 +} \ No newline at end of file diff --git a/src/main/java/com/yupi/project/model/entity/OrderDO.java b/src/main/java/com/yupi/project/model/entity/OrderDO.java new file mode 100644 index 0000000..f2e076b --- /dev/null +++ b/src/main/java/com/yupi/project/model/entity/OrderDO.java @@ -0,0 +1,23 @@ +package com.yupi.project.model.entity; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 订单 DO + * @author Administrator + */ +@Data +public class OrderDO implements Serializable { + + /** + * 订单编号 + */ + private Long id; + /** + * 用户编号 + */ + private Integer userId; + +} \ No newline at end of file diff --git a/src/main/resources/mapper/OrderConfigMapper.xml b/src/main/resources/mapper/OrderConfigMapper.xml new file mode 100644 index 0000000..f152723 --- /dev/null +++ b/src/main/resources/mapper/OrderConfigMapper.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + id, pay_timeout + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/OrderMapper.xml b/src/main/resources/mapper/OrderMapper.xml new file mode 100644 index 0000000..4044c9d --- /dev/null +++ b/src/main/resources/mapper/OrderMapper.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + INSERT INTO orders (id, user_id) + VALUES (#{id}, #{userId}) + + + \ No newline at end of file diff --git a/src/main/resources/mybatis-config.xml b/src/main/resources/mybatis-config.xml new file mode 100644 index 0000000..8b508c6 --- /dev/null +++ b/src/main/resources/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/com/yupi/project/service/OrderConfigMapperTest.java b/src/test/java/com/yupi/project/service/OrderConfigMapperTest.java new file mode 100644 index 0000000..9e368ce --- /dev/null +++ b/src/test/java/com/yupi/project/service/OrderConfigMapperTest.java @@ -0,0 +1,26 @@ +package com.yupi.project.service; + +import com.yupi.project.mapper.OrderConfigMapper; +import com.yupi.project.model.entity.OrderConfigDO; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + + + +@RunWith(SpringRunner.class) +@SpringBootTest +public class OrderConfigMapperTest { + + @Autowired + private OrderConfigMapper orderConfigMapper; + + @Test + public void testSelectById() { + OrderConfigDO orderConfig = orderConfigMapper.selectById(1); + System.out.println(orderConfig); + } + +} \ No newline at end of file diff --git a/src/test/java/com/yupi/project/service/OrderMapperTest.java b/src/test/java/com/yupi/project/service/OrderMapperTest.java new file mode 100644 index 0000000..9ec5c97 --- /dev/null +++ b/src/test/java/com/yupi/project/service/OrderMapperTest.java @@ -0,0 +1,28 @@ +package com.yupi.project.service; + +import com.yupi.project.mapper.OrderMapper; +import com.yupi.project.model.entity.OrderDO; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + + +@RunWith(SpringRunner.class) +@SpringBootTest +public class OrderMapperTest { + + @Autowired + private OrderMapper orderMapper; + + + @Test + public void testInsert() { + OrderDO order = new OrderDO(); + order.setId(2L); + order.setUserId(4); + orderMapper.insert(order); + } + +} \ No newline at end of file