集成分表框架sharding-jdbc,内容表拆分

This commit is contained in:
xiongxiaoyang 2020-06-03 08:44:21 +08:00
parent 47b871909f
commit c66905fbea
14 changed files with 144 additions and 10 deletions

View File

@ -266,7 +266,7 @@ int insert(org.mybatis.dynamic.sql.insert.render.InsertStatementProvider&lt
<pre>@Generated(value="org.mybatis.generator.api.MyBatisGenerator") <pre>@Generated(value="org.mybatis.generator.api.MyBatisGenerator")
@SelectProvider(type=org.mybatis.dynamic.sql.util.SqlProviderAdapter.class, @SelectProvider(type=org.mybatis.dynamic.sql.util.SqlProviderAdapter.class,
method="select") method="select")
@Results(id="BookContentResult",value={@Result(column="id",property="id",jdbcType=BIGINT,id=true),@Result(column="index_id",property="indexId",jdbcType=BIGINT),@Result(column="content",property="content",jdbcType=LONGVARCHAR)}) @Results(id="BookContentResult",value={@Result(column="id",property="id",jdbcType=BIGINT,id=true),@Result(column="index_id",property="indexId",jdbcType=BIGINT),@Result(column="content",property="content",jdbcType=VARCHAR)})
java.util.List&lt;<a href="../../../../../com/java2nb/novel/book/entity/BookContent.html" title="com.java2nb.novel.book.entity中的类">BookContent</a>&gt;&nbsp;selectMany(org.mybatis.dynamic.sql.select.render.SelectStatementProvider&nbsp;selectStatement)</pre> java.util.List&lt;<a href="../../../../../com/java2nb/novel/book/entity/BookContent.html" title="com.java2nb.novel.book.entity中的类">BookContent</a>&gt;&nbsp;selectMany(org.mybatis.dynamic.sql.select.render.SelectStatementProvider&nbsp;selectStatement)</pre>
</li> </li>
</ul> </ul>

View File

@ -266,7 +266,7 @@ int&nbsp;insert(org.mybatis.dynamic.sql.insert.render.InsertStatementProvider&lt
<pre>@Generated(value="org.mybatis.generator.api.MyBatisGenerator") <pre>@Generated(value="org.mybatis.generator.api.MyBatisGenerator")
@SelectProvider(type=org.mybatis.dynamic.sql.util.SqlProviderAdapter.class, @SelectProvider(type=org.mybatis.dynamic.sql.util.SqlProviderAdapter.class,
method="select") method="select")
@Results(id="NewsResult",value={@Result(column="id",property="id",jdbcType=BIGINT,id=true),@Result(column="cat_id",property="catId",jdbcType=INTEGER),@Result(column="cat_name",property="catName",jdbcType=VARCHAR),@Result(column="source_name",property="sourceName",jdbcType=VARCHAR),@Result(column="title",property="title",jdbcType=VARCHAR),@Result(column="create_time",property="createTime",jdbcType=TIMESTAMP),@Result(column="create_user_id",property="createUserId",jdbcType=BIGINT),@Result(column="update_time",property="updateTime",jdbcType=TIMESTAMP),@Result(column="update_user_id",property="updateUserId",jdbcType=BIGINT),@Result(column="content",property="content",jdbcType=LONGVARCHAR)}) @Results(id="NewsResult",value={@Result(column="id",property="id",jdbcType=BIGINT,id=true),@Result(column="cat_id",property="catId",jdbcType=INTEGER),@Result(column="cat_name",property="catName",jdbcType=VARCHAR),@Result(column="source_name",property="sourceName",jdbcType=VARCHAR),@Result(column="title",property="title",jdbcType=VARCHAR),@Result(column="create_time",property="createTime",jdbcType=TIMESTAMP),@Result(column="create_user_id",property="createUserId",jdbcType=BIGINT),@Result(column="update_time",property="updateTime",jdbcType=TIMESTAMP),@Result(column="update_user_id",property="updateUserId",jdbcType=BIGINT),@Result(column="content",property="content",jdbcType=VARCHAR)})
java.util.List&lt;<a href="../../../../../com/java2nb/novel/news/entity/News.html" title="com.java2nb.novel.news.entity中的类">News</a>&gt;&nbsp;selectMany(org.mybatis.dynamic.sql.select.render.SelectStatementProvider&nbsp;selectStatement)</pre> java.util.List&lt;<a href="../../../../../com/java2nb/novel/news/entity/News.html" title="com.java2nb.novel.news.entity中的类">News</a>&gt;&nbsp;selectMany(org.mybatis.dynamic.sql.select.render.SelectStatementProvider&nbsp;selectStatement)</pre>
</li> </li>
</ul> </ul>

116
doc/sql/20200603.sql Normal file
View File

@ -0,0 +1,116 @@
DROP TABLE IF EXISTS `book_content0`;
CREATE TABLE `book_content0` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1155 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content1
-- ----------------------------
DROP TABLE IF EXISTS `book_content1`;
CREATE TABLE `book_content1` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=406 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content2
-- ----------------------------
DROP TABLE IF EXISTS `book_content2`;
CREATE TABLE `book_content2` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1222 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content3
-- ----------------------------
DROP TABLE IF EXISTS `book_content3`;
CREATE TABLE `book_content3` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=410 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content4
-- ----------------------------
DROP TABLE IF EXISTS `book_content4`;
CREATE TABLE `book_content4` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1188 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content5
-- ----------------------------
DROP TABLE IF EXISTS `book_content5`;
CREATE TABLE `book_content5` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=416 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content6
-- ----------------------------
DROP TABLE IF EXISTS `book_content6`;
CREATE TABLE `book_content6` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1180 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content7
-- ----------------------------
DROP TABLE IF EXISTS `book_content7`;
CREATE TABLE `book_content7` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=404 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content8
-- ----------------------------
DROP TABLE IF EXISTS `book_content8`;
CREATE TABLE `book_content8` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1134 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';
-- ----------------------------
-- Table structure for book_content9
-- ----------------------------
DROP TABLE IF EXISTS `book_content9`;
CREATE TABLE `book_content9` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
`index_id` bigint(20) DEFAULT NULL COMMENT '目录ID',
`content` mediumtext COMMENT '小说章节内容',
PRIMARY KEY (`id`),
UNIQUE KEY `key_uq_indexId` (`index_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=415 DEFAULT CHARSET=utf8mb4 COMMENT='小说内容表';

View File

@ -46,6 +46,21 @@
<version>${redisson.version}</version> <version>${redisson.version}</version>
</dependency> </dependency>
<!-- 分库分表-->
<!-- sharding jdbc依赖 -->
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>${sharding.jdbc.version}</version>
</dependency>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-namespace</artifactId>
<version>${sharding.jdbc.version}</version>
</dependency>
</dependencies> </dependencies>

View File

@ -25,7 +25,7 @@ public final class BookContentDynamicSqlSupport {
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT); public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR); public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
public BookContent() { public BookContent() {
super("book_content"); super("book_content");

View File

@ -48,7 +48,7 @@ public interface BookContentMapper {
@Results(id="BookContentResult", value = { @Results(id="BookContentResult", value = {
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT), @Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR) @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
}) })
List<BookContent> selectMany(SelectStatementProvider selectStatement); List<BookContent> selectMany(SelectStatementProvider selectStatement);

View File

@ -14,6 +14,9 @@ mybatis:
logging: logging:
config: classpath:logback-boot.xml config: classpath:logback-boot.xml
spring:
main:
allow-bean-definition-overriding: true
feign: feign:
httpclient: httpclient:

View File

@ -24,7 +24,7 @@ public final class BookContentDynamicSqlSupport {
public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT); public final SqlColumn<Long> indexId = column("index_id", JDBCType.BIGINT);
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR); public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
public BookContent() { public BookContent() {
super("book_content"); super("book_content");

View File

@ -54,7 +54,7 @@ public interface BookContentMapper {
@Results(id="BookContentResult", value = { @Results(id="BookContentResult", value = {
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT), @Result(column="index_id", property="indexId", jdbcType=JdbcType.BIGINT),
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR) @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
}) })
List<BookContent> selectMany(SelectStatementProvider selectStatement); List<BookContent> selectMany(SelectStatementProvider selectStatement);

View File

@ -60,7 +60,7 @@ public final class NewsDynamicSqlSupport {
public final SqlColumn<Long> updateUserId = column("update_user_id", JDBCType.BIGINT); public final SqlColumn<Long> updateUserId = column("update_user_id", JDBCType.BIGINT);
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR); public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
public News() { public News() {
super("news"); super("news");

View File

@ -61,7 +61,7 @@ public interface NewsMapper {
@Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT), @Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_user_id", property="updateUserId", jdbcType=JdbcType.BIGINT), @Result(column="update_user_id", property="updateUserId", jdbcType=JdbcType.BIGINT),
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR) @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
}) })
List<News> selectMany(SelectStatementProvider selectStatement); List<News> selectMany(SelectStatementProvider selectStatement);

View File

@ -61,7 +61,7 @@ public final class NewsDynamicSqlSupport {
public final SqlColumn<Long> updateUserId = column("update_user_id", JDBCType.BIGINT); public final SqlColumn<Long> updateUserId = column("update_user_id", JDBCType.BIGINT);
public final SqlColumn<String> content = column("content", JDBCType.LONGVARCHAR); public final SqlColumn<String> content = column("content", JDBCType.VARCHAR);
public News() { public News() {
super("news"); super("news");

View File

@ -55,7 +55,7 @@ public interface NewsMapper {
@Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT), @Result(column="create_user_id", property="createUserId", jdbcType=JdbcType.BIGINT),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_user_id", property="updateUserId", jdbcType=JdbcType.BIGINT), @Result(column="update_user_id", property="updateUserId", jdbcType=JdbcType.BIGINT),
@Result(column="content", property="content", jdbcType=JdbcType.LONGVARCHAR) @Result(column="content", property="content", jdbcType=JdbcType.VARCHAR)
}) })
List<News> selectMany(SelectStatementProvider selectStatement); List<News> selectMany(SelectStatementProvider selectStatement);