Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
TDengine
提交
2a683c5b
T
TDengine
项目概览
XKZJ_WCL
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2a683c5b
编写于
3月 03, 2021
作者:
Z
zyyang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change
上级
04f06f9d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
26 deletion
+59
-26
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
.../example/springbootdemo/controller/WeatherController.java
+2
-2
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
...om/taosdata/example/springbootdemo/dao/WeatherMapper.java
+6
-4
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
...com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
+7
-10
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
...a/com/taosdata/example/springbootdemo/domain/Weather.java
+32
-7
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
...osdata/example/springbootdemo/service/WeatherService.java
+12
-3
未找到文件。
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/controller/WeatherController.java
浏览文件 @
2a683c5b
...
...
@@ -20,7 +20,7 @@ public class WeatherController {
* @return
*/
@GetMapping
(
"/init"
)
public
boolean
init
()
{
public
int
init
()
{
return
weatherService
.
init
();
}
...
...
@@ -44,7 +44,7 @@ public class WeatherController {
* @return
*/
@PostMapping
(
"/{temperature}/{humidity}"
)
public
int
saveWeather
(
@PathVariable
int
temperature
,
@PathVariable
floa
t
humidity
)
{
public
int
saveWeather
(
@PathVariable
float
temperature
,
@PathVariable
in
t
humidity
)
{
return
weatherService
.
save
(
temperature
,
humidity
);
}
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.java
浏览文件 @
2a683c5b
...
...
@@ -7,15 +7,17 @@ import java.util.List;
public
interface
WeatherMapper
{
int
insert
(
Weather
weather
);
void
createDB
(
);
int
batchInsert
(
List
<
Weather
>
weatherList
);
void
createSuperTable
();
void
createTable
();
List
<
Weather
>
select
(
@Param
(
"limit"
)
Long
limit
,
@Param
(
"offset"
)
Long
offset
);
void
createDB
(
);
int
insert
(
Weather
weather
);
void
createTable
(
);
int
batchInsert
(
List
<
Weather
>
weatherList
);
int
count
();
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/dao/WeatherMapper.xml
浏览文件 @
2a683c5b
...
...
@@ -13,19 +13,16 @@
create database if not exists test;
</update>
<update
id=
"createTable"
>
create table if not exists test.weather(ts timestamp, temp
erature int, humidity float);
<update
id=
"create
Super
Table"
>
create table if not exists test.weather(ts timestamp, temp
orary float, humidity int) tags(location nchar(64), groupId int)
</update>
<
sql
id=
"Base_Column_List
"
>
ts, temperature, humidity
</
sql
>
<
update
id=
"createTable"
parameterType=
"com.taosdata.example.springbootdemo.domain.Weather
"
>
create table test.t#{groupId} using test.weather tags(#{location}, #{groupId})
</
update
>
<select
id=
"select"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from test.weather
order by ts desc
select * from test.weather order by ts desc
<if
test=
"limit != null"
>
limit #{limit,jdbcType=BIGINT}
</if>
...
...
@@ -50,7 +47,7 @@
</select>
<select
id=
"count"
>
select count(*) from test.weather
;
select count(*) from test.weather
</select>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/domain/Weather.java
浏览文件 @
2a683c5b
...
...
@@ -6,12 +6,21 @@ import java.sql.Timestamp;
public
class
Weather
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Timestamp
ts
;
private
float
temperature
;
private
int
humidity
;
private
String
location
;
private
int
groupId
;
private
int
temperature
;
public
Weather
()
{
}
private
float
humidity
;
public
Weather
(
Timestamp
ts
,
float
temperature
,
int
humidity
)
{
this
.
ts
=
ts
;
this
.
temperature
=
temperature
;
this
.
humidity
=
humidity
;
}
public
Timestamp
getTs
()
{
return
ts
;
...
...
@@ -21,19 +30,35 @@ public class Weather {
this
.
ts
=
ts
;
}
public
in
t
getTemperature
()
{
public
floa
t
getTemperature
()
{
return
temperature
;
}
public
void
setTemperature
(
in
t
temperature
)
{
public
void
setTemperature
(
floa
t
temperature
)
{
this
.
temperature
=
temperature
;
}
public
floa
t
getHumidity
()
{
public
in
t
getHumidity
()
{
return
humidity
;
}
public
void
setHumidity
(
floa
t
humidity
)
{
public
void
setHumidity
(
in
t
humidity
)
{
this
.
humidity
=
humidity
;
}
public
String
getLocation
()
{
return
location
;
}
public
void
setLocation
(
String
location
)
{
this
.
location
=
location
;
}
public
int
getGroupId
()
{
return
groupId
;
}
public
void
setGroupId
(
int
groupId
)
{
this
.
groupId
=
groupId
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/example/springbootdemo/service/WeatherService.java
浏览文件 @
2a683c5b
...
...
@@ -5,25 +5,34 @@ import com.taosdata.example.springbootdemo.domain.Weather;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.Random
;
@Service
public
class
WeatherService
{
@Autowired
private
WeatherMapper
weatherMapper
;
private
Random
random
=
new
Random
(
System
.
currentTimeMillis
());
public
boolean
init
()
{
public
int
init
()
{
weatherMapper
.
createDB
();
weatherMapper
.
createSuperTable
();
weatherMapper
.
createTable
();
return
true
;
long
ts
=
System
.
currentTimeMillis
();
int
count
=
0
;
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
count
+=
weatherMapper
.
insert
(
new
Weather
(
new
Timestamp
(
ts
+
(
1000
*
i
)),
30
*
random
.
nextFloat
(),
random
.
nextInt
(
100
)));
}
return
count
;
}
public
List
<
Weather
>
query
(
Long
limit
,
Long
offset
)
{
return
weatherMapper
.
select
(
limit
,
offset
);
}
public
int
save
(
int
temperature
,
floa
t
humidity
)
{
public
int
save
(
float
temperature
,
in
t
humidity
)
{
Weather
weather
=
new
Weather
();
weather
.
setTemperature
(
temperature
);
weather
.
setHumidity
(
humidity
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录