diff --git a/tests/examples/JDBC/mybatisplus-demo/pom.xml b/tests/examples/JDBC/mybatisplus-demo/pom.xml
index e1bbcd9532cd408a6a5b781e1fe413cd469c4e7e..fc1d229330357c2ed5576b965d768ed3634e961a 100644
--- a/tests/examples/JDBC/mybatisplus-demo/pom.xml
+++ b/tests/examples/JDBC/mybatisplus-demo/pom.xml
@@ -103,12 +103,12 @@
prod
-
- true
-
prod
+
+ true
+
diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..3ec9819c9b4ab18a6f8c605bb8e8c7f3f8c7ae01
--- /dev/null
+++ b/tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java
@@ -0,0 +1,23 @@
+package com.taosdata.example.mybatisplusdemo.config;
+
+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 PaginationInterceptor paginationInnerInterceptor() {
+ PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
+ // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求 默认false
+ // paginationInterceptor.setOverflow(false);
+ // 设置最大单页限制数量,默认 500 条,-1 不受限制
+ // paginationInterceptor.setLimit(500);
+ // 开启 count 的 join 优化,只针对部分 left join
+// paginationInterceptor.setCountSqlParser(new JsqlParserCountOptimize(true));
+ return paginationInterceptor;
+
+ }
+
+}
diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
index 50e273103c56da405f790f8d16b792de2827c84c..af688b76f4c637a8642edd4d1e72b671cd2dc894 100644
--- a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
+++ b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
@@ -1,13 +1,12 @@
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.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
diff --git a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
index f724f80979f53517ec8f7da0e8921177ede7afa9..fdd1c39ecaf4bfb9435866f02523c56bada58a5e 100644
--- a/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
+++ b/tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
@@ -1,3 +1,3 @@
spring:
profiles:
- active: @spring.profiles.active@
\ No newline at end of file
+ active: "@spring.profiles.active@"
\ No newline at end of file
diff --git a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java b/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
index ab090d2efbd064ab3ecd70b3896bef961531fcc0..b7787d547708337764faeb0defe70b072cc2466b 100644
--- a/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
+++ b/tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
@@ -1,6 +1,7 @@
package com.taosdata.example.mybatisplusdemo.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taosdata.example.mybatisplusdemo.domain.Weather;
import org.junit.Assert;
import org.junit.Test;
@@ -37,24 +38,11 @@ public class WeatherMapperTest {
weather.setTs(new Timestamp(1605024000000l));
weather.setTemperature(random.nextFloat() * 50);
weather.setHumidity(random.nextInt(100));
- weather.setLocation("wangjing");
+ weather.setLocation("望京");
int affectRows = mapper.insert(weather);
Assert.assertEquals(1, affectRows);
}
- @Test
- public void testDelete() {
- mapper.delete(new QueryWrapper().eq("location", "wangjing"));
- }
-
- @Test
- public void testDeleteByMap() {
- Map map = new HashMap<>();
- map.put("location", "wangjing");
- int affectRows = mapper.deleteByMap(map);
-// Assert.assertEquals(0, affectRows);
- }
-
@Test
public void testSelectOne() {
QueryWrapper wrapper = new QueryWrapper<>();
@@ -87,5 +75,16 @@ public class WeatherMapperTest {
Assert.assertEquals(5, count);
}
+ @Test
+ public void testSelectPage() {
+ Page page = new Page<>(1, 2);
+ Page weatherPage = mapper.selectPage(page, null);
+ System.out.println("total : " + weatherPage.getTotal());
+ System.out.println("pages : " + weatherPage.getPages());
+ for (Weather weather : weatherPage.getRecords()) {
+ System.out.println(weather);
+ }
+ }
+
}
\ No newline at end of file