Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3ae555de
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3ae555de
编写于
11月 14, 2020
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
ee814ac8
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
26 deletion
+47
-26
tests/examples/JDBC/mybatisplus-demo/pom.xml
tests/examples/JDBC/mybatisplus-demo/pom.xml
+3
-3
tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java
...ata/example/mybatisplusdemo/config/MybatisPlusConfig.java
+23
-0
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
.../mybatisplus-demo/src/main/resources/application-prod.yml
+7
-8
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
.../JDBC/mybatisplus-demo/src/main/resources/application.yml
+1
-1
tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
...ata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
+13
-14
未找到文件。
tests/examples/JDBC/mybatisplus-demo/pom.xml
浏览文件 @
3ae555de
...
...
@@ -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>
...
...
tests/examples/JDBC/mybatisplus-demo/src/main/java/com/taosdata/example/mybatisplusdemo/config/MybatisPlusConfig.java
0 → 100644
浏览文件 @
3ae555de
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
;
}
}
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application-prod.yml
浏览文件 @
3ae555de
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
...
...
tests/examples/JDBC/mybatisplus-demo/src/main/resources/application.yml
浏览文件 @
3ae555de
spring
:
profiles
:
active
:
@
spring.profiles.active@
\ No newline at end of file
active
:
"
@spring.profiles.active@"
\ No newline at end of file
tests/examples/JDBC/mybatisplus-demo/src/test/java/com/taosdata/example/mybatisplusdemo/mapper/WeatherMapperTest.java
浏览文件 @
3ae555de
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
(
1605024000000
l
));
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录