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

change

上级 ae95667b
......@@ -31,7 +31,7 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.1</version>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
......@@ -97,22 +97,5 @@
</plugins>
</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>
package com.taosdata.example.mybatisplusdemo.config;
import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
// @Bean
// public MybatisPlusInterceptor mybatisPlusInterceptor() {
// MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
// return interceptor;
// }
// @Bean
// public ConfigurationCustomizer configurationCustomizer() {
// return configuration -> configuration.setUseDeprecatedExecutor(false);
// }
@Bean
public ConfigurationCustomizer configurationCustomizer() {
return configuration -> configuration.setUseDeprecatedExecutor(false);
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
package com.taosdata.example.mybatisplusdemo.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taosdata.example.mybatisplusdemo.domain.Weather;
import com.taosdata.example.mybatisplusdemo.mapper.WeatherMapper;
......@@ -21,12 +22,15 @@ public class WeatherController {
public List<Weather> findAll() {
Integer total = mapper.selectCount(null);
final int pageSize = 3;
Page<Weather> page = new Page<>(1, pageSize);
Page<Weather> currentPage = mapper.selectPage(page, null);
IPage<Weather> page = new Page<>(1, pageSize);
IPage<Weather> currentPage = mapper.selectPage(page, null);
System.out.println("total : " + currentPage.getTotal());
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();
}
......
......@@ -2,6 +2,7 @@ package com.taosdata.example.mybatisplusdemo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.taosdata.example.mybatisplusdemo.domain.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:
profiles:
active: "@spring.profiles.active@"
\ No newline at end of file
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
package com.taosdata.example.mybatisplusdemo.mapper;
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.taosdata.example.mybatisplusdemo.domain.Weather;
import org.junit.Assert;
......@@ -77,8 +78,13 @@ public class WeatherMapperTest {
@Test
public void testSelectPage() {
Page<Weather> page = new Page<>(1, 2);
Page<Weather> weatherPage = mapper.selectPage(page, null);
// Page<Weather> page = new Page<>(1, 2);
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("pages : " + weatherPage.getPages());
for (Weather weather : weatherPage.getRecords()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册