forked from yudaocode/SpringBoot-Labs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
YunaiV
committed
Nov 11, 2019
1 parent
6e4f257
commit 00b9bb8
Showing
22 changed files
with
510 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...rc/main/java/cn/iocoder/springboot/lab18/shardingdatasource/dataobject/OrderConfigDO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cn.iocoder.springboot.lab18.shardingdatasource.dataobject; | ||
|
||
/** | ||
* 订单配置 DO | ||
*/ | ||
public class OrderConfigDO { | ||
|
||
/** | ||
* 编号 | ||
*/ | ||
private Integer id; | ||
/** | ||
* 支付超时时间 | ||
* | ||
* 单位:分钟 | ||
*/ | ||
private Integer payTimeout; | ||
|
||
public Integer getId() { | ||
return id; | ||
} | ||
|
||
public OrderConfigDO setId(Integer id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public Integer getPayTimeout() { | ||
return payTimeout; | ||
} | ||
|
||
public OrderConfigDO setPayTimeout(Integer payTimeout) { | ||
this.payTimeout = payTimeout; | ||
return this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...rc/main/java/cn/iocoder/springboot/lab18/shardingdatasource/mapper/OrderConfigMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package cn.iocoder.springboot.lab18.shardingdatasource.mapper; | ||
|
||
import cn.iocoder.springboot.lab18.shardingdatasource.dataobject.OrderConfigDO; | ||
import org.apache.ibatis.annotations.Param; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface OrderConfigMapper { | ||
|
||
OrderConfigDO selectById(@Param("id") Integer id); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
.../src/main/resources/mapper/UserMapper.xml → ...in/resources/mapper/OrderConfigMapper.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
lab-18/lab-18-sharding-datasource-01/src/main/resources/sql/db.sql
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
lab-18/lab-18-sharding-datasource-01/src/main/resources/sql/lab18_orders_0.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
SET NAMES utf8mb4; | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_0 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_0`; | ||
CREATE TABLE `orders_0` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_2 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_2`; | ||
CREATE TABLE `orders_2` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_4 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_4`; | ||
CREATE TABLE `orders_4` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_6 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_6`; | ||
CREATE TABLE `orders_6` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
|
||
-- ---------------------------- | ||
-- Table structure for order_config | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `order_config`; | ||
CREATE TABLE `order_config` ( | ||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号', | ||
`pay_timeout` int(11) DEFAULT NULL COMMENT '支付超时时间;单位:分钟', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4; | ||
|
||
SET FOREIGN_KEY_CHECKS = 1; | ||
|
44 changes: 44 additions & 0 deletions
44
lab-18/lab-18-sharding-datasource-01/src/main/resources/sql/lab18_orders_1.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
SET NAMES utf8mb4; | ||
SET FOREIGN_KEY_CHECKS = 0; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_1 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_1`; | ||
CREATE TABLE `orders_1` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=400675304294580226 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_3 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_3`; | ||
CREATE TABLE `orders_3` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_5 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_5`; | ||
CREATE TABLE `orders_5` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
-- ---------------------------- | ||
-- Table structure for orders_7 | ||
-- ---------------------------- | ||
DROP TABLE IF EXISTS `orders_7`; | ||
CREATE TABLE `orders_7` ( | ||
`id` bigint(11) NOT NULL AUTO_INCREMENT COMMENT '订单编号', | ||
`user_id` int(16) DEFAULT NULL COMMENT '用户编号', | ||
PRIMARY KEY (`id`) | ||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='订单表'; | ||
|
||
SET FOREIGN_KEY_CHECKS = 1; |
24 changes: 24 additions & 0 deletions
24
...est/java/cn/iocoder/springboot/lab18/shardingdatasource/mapper/OrderConfigMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.iocoder.springboot.lab18.shardingdatasource.mapper; | ||
|
||
import cn.iocoder.springboot.lab18.shardingdatasource.Application; | ||
import cn.iocoder.springboot.lab18.shardingdatasource.dataobject.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(classes = Application.class) | ||
public class OrderConfigMapperTest { | ||
|
||
@Autowired | ||
private OrderConfigMapper orderConfigMapper; | ||
|
||
@Test | ||
public void testSelectById() { | ||
OrderConfigDO orderConfig = orderConfigMapper.selectById(1); | ||
System.out.println(orderConfig); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.