提交 3ae555de 编写于 作者: Z zyyang

change

上级 ee814ac8
......@@ -103,12 +103,12 @@
</profile>
<profile>
<id>prod</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<spring.profiles.active>prod</spring.profiles.active>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
......
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;
}
}
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
......
spring:
profiles:
active: @spring.profiles.active@
\ No newline at end of file
active: "@spring.profiles.active@"
\ No newline at end of file
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<Weather>().eq("location", "wangjing"));
}
@Test
public void testDeleteByMap() {
Map<String, Object> map = new HashMap<>();
map.put("location", "wangjing");
int affectRows = mapper.deleteByMap(map);
// Assert.assertEquals(0, affectRows);
}
@Test
public void testSelectOne() {
QueryWrapper<Weather> wrapper = new QueryWrapper<>();
......@@ -87,5 +75,16 @@ public class WeatherMapperTest {
Assert.assertEquals(5, count);
}
@Test
public void testSelectPage() {
Page<Weather> page = new Page<>(1, 2);
Page<Weather> 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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册