提交 5349141d 编写于 作者: Z zyyang

change

上级 ae95667b
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.1</version> <version>3.1.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
...@@ -97,22 +97,5 @@ ...@@ -97,22 +97,5 @@
</plugins> </plugins>
</build> </build>
<profiles>
<profile>
<id>dev</id>
<properties>
<spring.profiles.active>dev</spring.profiles.active>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</project> </project>
package com.taosdata.example.mybatisplusdemo.config; package com.taosdata.example.mybatisplusdemo.config;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer; import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class MybatisPlusConfig { public class MybatisPlusConfig {
@Bean // @Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() { // public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor; // return interceptor;
} // }
// @Bean
// public ConfigurationCustomizer configurationCustomizer() {
// return configuration -> configuration.setUseDeprecatedExecutor(false);
// }
@Bean @Bean
public ConfigurationCustomizer configurationCustomizer() { public PaginationInterceptor paginationInterceptor() {
return configuration -> configuration.setUseDeprecatedExecutor(false); return new PaginationInterceptor();
} }
} }
package com.taosdata.example.mybatisplusdemo.controller; package com.taosdata.example.mybatisplusdemo.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taosdata.example.mybatisplusdemo.domain.Weather; import com.taosdata.example.mybatisplusdemo.domain.Weather;
import com.taosdata.example.mybatisplusdemo.mapper.WeatherMapper; import com.taosdata.example.mybatisplusdemo.mapper.WeatherMapper;
...@@ -21,12 +22,15 @@ public class WeatherController { ...@@ -21,12 +22,15 @@ public class WeatherController {
public List<Weather> findAll() { public List<Weather> findAll() {
Integer total = mapper.selectCount(null); Integer total = mapper.selectCount(null);
final int pageSize = 3; final int pageSize = 3;
Page<Weather> page = new Page<>(1, pageSize); IPage<Weather> page = new Page<>(1, pageSize);
Page<Weather> currentPage = mapper.selectPage(page, null);
IPage<Weather> currentPage = mapper.selectPage(page, null);
System.out.println("total : " + currentPage.getTotal()); System.out.println("total : " + currentPage.getTotal());
System.out.println("pages : " + currentPage.getPages()); System.out.println("pages : " + currentPage.getPages());
System.out.println("countId : " + currentPage.getCountId());
System.out.println("maxLimit: " + currentPage.getMaxLimit()); // System.out.println("countId : " + currentPage.getCountId());
// System.out.println("maxLimit: " + currentPage.getMaxLimit());
return currentPage.getRecords(); return currentPage.getRecords();
} }
......
...@@ -2,6 +2,7 @@ package com.taosdata.example.mybatisplusdemo.mapper; ...@@ -2,6 +2,7 @@ package com.taosdata.example.mybatisplusdemo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.taosdata.example.mybatisplusdemo.domain.Weather; import com.taosdata.example.mybatisplusdemo.domain.Weather;
public interface WeatherMapper extends BaseMapper<Weather> { public interface WeatherMapper extends BaseMapper<Weather> {
......
spring:
datasource:
driver-class-name: org.h2.Driver
schema: classpath:db/schema-taos.sql
data: classpath:db/data-taos.sql
url: jdbc:h2:mem:test
user: root
password: test
\ No newline at end of file
spring:
datasource:
# driver-class-name: com.taosdata.jdbc.TSDBDriver
# url: jdbc:TAOS://localhost:6030/mp_test
# user: root
# password: taosdata
# charset: UTF-8
# locale: en_US.UTF-8
# timezone: UTC-8
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://master:3306/test?useSSL=false
username: root
password: 123456
logging:
level:
com:
taosdata:
example:
mybatisplusdemo:
mapper: debug
spring: spring:
profiles: datasource:
active: "@spring.profiles.active@" # driver-class-name: com.taosdata.jdbc.TSDBDriver
\ No newline at end of file # url: jdbc:TAOS://localhost:6030/mp_test
# user: root
# password: taosdata
# charset: UTF-8
# locale: en_US.UTF-8
# timezone: UTC-8
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://master:3306/test?useSSL=false
username: root
password: 123456
logging:
level:
com:
taosdata:
example:
mybatisplusdemo:
mapper: debug
package com.taosdata.example.mybatisplusdemo.mapper; package com.taosdata.example.mybatisplusdemo.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taosdata.example.mybatisplusdemo.domain.Weather; import com.taosdata.example.mybatisplusdemo.domain.Weather;
import org.junit.Assert; import org.junit.Assert;
...@@ -77,8 +78,13 @@ public class WeatherMapperTest { ...@@ -77,8 +78,13 @@ public class WeatherMapperTest {
@Test @Test
public void testSelectPage() { public void testSelectPage() {
Page<Weather> page = new Page<>(1, 2); // Page<Weather> page = new Page<>(1, 2);
Page<Weather> weatherPage = mapper.selectPage(page, null);
IPage page = new Page(1, 2);
IPage<Weather> weatherPage = mapper.selectPage(page, null);
// Page<Weather> weatherPage = mapper.selectPage(page, null);
System.out.println("total : " + weatherPage.getTotal()); System.out.println("total : " + weatherPage.getTotal());
System.out.println("pages : " + weatherPage.getPages()); System.out.println("pages : " + weatherPage.getPages());
for (Weather weather : weatherPage.getRecords()) { for (Weather weather : weatherPage.getRecords()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册