Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_50753323
TDengine
提交
dee7d93b
T
TDengine
项目概览
qq_50753323
/
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,发现更多精彩内容 >>
提交
dee7d93b
编写于
9月 08, 2020
作者:
Z
zyyang-taosdata
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update springbootDemo
上级
0dbef3bc
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
401 addition
and
8 deletion
+401
-8
tests/examples/JDBC/springbootdemo/pom.xml
tests/examples/JDBC/springbootdemo/pom.xml
+19
-1
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
...jdbc/springbootdemo/controller/RainStationController.java
+28
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java
...ata/jdbc/springbootdemo/controller/WeatherController.java
+8
-4
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
.../com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
+15
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
...a/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
+44
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
.../com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
+9
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
...a/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
+11
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
...ava/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
+8
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
...java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
+21
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml
...va/com/taosdata/jdbc/springbootdemo/dao/WeatherMapper.xml
+0
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
...om/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
+28
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
...ava/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
+64
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
...om/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
+43
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
.../com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
+27
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java
...java/com/taosdata/jdbc/springbootdemo/domain/Weather.java
+3
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
...sdata/jdbc/springbootdemo/service/RainStationService.java
+72
-0
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java
.../taosdata/jdbc/springbootdemo/service/WeatherService.java
+0
-2
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
.../springbootdemo/src/main/resources/application.properties
+1
-1
未找到文件。
tests/examples/JDBC/springbootdemo/pom.xml
浏览文件 @
dee7d93b
...
...
@@ -63,7 +63,7 @@
<dependency>
<groupId>
com.taosdata.jdbc
</groupId>
<artifactId>
taos-jdbcdriver
</artifactId>
<version>
2.0.
2
</version>
<version>
2.0.
4
</version>
</dependency>
<dependency>
...
...
@@ -76,6 +76,24 @@
</dependencies>
<build>
<resources>
<resource>
<directory>
src/main/resources
</directory>
<includes>
<include>
**/*.properties
</include>
<include>
**/*.xml
</include>
</includes>
<filtering>
true
</filtering>
</resource>
<resource>
<directory>
src/main/java
</directory>
<includes>
<include>
**/*.properties
</include>
<include>
**/*.xml
</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>
org.springframework.boot
</groupId>
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/RainStationController.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.controller
;
import
com.taosdata.jdbc.springbootdemo.domain.Rainfall
;
import
com.taosdata.jdbc.springbootdemo.service.RainStationService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
@RestController
@RequestMapping
(
"/rainstation"
)
public
class
RainStationController
{
@Autowired
private
RainStationService
service
;
@GetMapping
(
"/init"
)
public
boolean
init
()
{
service
.
init
();
service
.
createTable
();
return
true
;
}
@PostMapping
(
"/insert"
)
public
int
insert
(
@RequestBody
Rainfall
rainfall
){
return
service
.
insert
(
rainfall
);
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/controller/WeatherController.java
浏览文件 @
dee7d93b
...
...
@@ -16,43 +16,47 @@ public class WeatherController {
/**
* create database and table
*
* @return
*/
@GetMapping
(
"/init"
)
public
boolean
init
(){
public
boolean
init
()
{
return
weatherService
.
init
();
}
/**
* Pagination Query
*
* @param limit
* @param offset
* @return
*/
@GetMapping
(
"/{limit}/{offset}"
)
public
List
<
Weather
>
queryWeather
(
@PathVariable
Long
limit
,
@PathVariable
Long
offset
){
public
List
<
Weather
>
queryWeather
(
@PathVariable
Long
limit
,
@PathVariable
Long
offset
)
{
return
weatherService
.
query
(
limit
,
offset
);
}
/**
* upload single weather info
*
* @param temperature
* @param humidity
* @return
*/
@PostMapping
(
"/{temperature}/{humidity}"
)
public
int
saveWeather
(
@PathVariable
int
temperature
,
@PathVariable
float
humidity
){
public
int
saveWeather
(
@PathVariable
int
temperature
,
@PathVariable
float
humidity
)
{
return
weatherService
.
save
(
temperature
,
humidity
);
}
/**
* upload multi weather info
*
* @param weatherList
* @return
*/
@PostMapping
(
"/batch"
)
public
int
batchSaveWeather
(
@RequestBody
List
<
Weather
>
weatherList
){
public
int
batchSaveWeather
(
@RequestBody
List
<
Weather
>
weatherList
)
{
return
weatherService
.
save
(
weatherList
);
}
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.dao
;
import
java.util.Map
;
public
interface
DatabaseMapper
{
int
createDatabase
(
String
dbname
);
int
dropDatabase
(
String
dbname
);
int
creatDatabaseWithParameters
(
Map
<
String
,
String
>
map
);
int
useDatabase
(
String
dbname
);
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/DatabaseMapper.xml
0 → 100644
浏览文件 @
dee7d93b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.taosdata.jdbc.springbootdemo.dao.DatabaseMapper"
>
<update
id=
"createDatabase"
parameterType=
"java.lang.String"
>
create database if not exists ${dbname}
</update>
<update
id=
"dropDatabase"
parameterType=
"java.lang.String"
>
DROP database if exists ${dbname}
</update>
<update
id=
"creatDatabaseWithParameters"
parameterType=
"map"
>
CREATE database if not EXISTS ${dbname}
<if
test=
"keep != null"
>
KEEP ${keep}
</if>
<if
test=
"days != null"
>
DAYS ${days}
</if>
<if
test=
"replica != null"
>
REPLICA ${replica}
</if>
<if
test=
"cache != null"
>
cache ${cache}
</if>
<if
test=
"blocks != null"
>
blocks ${blocks}
</if>
<if
test=
"minrows != null"
>
minrows ${minrows}
</if>
<if
test=
"maxrows != null"
>
maxrows ${maxrows}
</if>
</update>
<update
id=
"useDatabase"
parameterType=
"java.lang.String"
>
use ${dbname}
</update>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.dao
;
import
java.util.Map
;
public
interface
RainfallMapper
{
int
save
(
Map
<
String
,
Object
>
map
);
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/RainfallMapper.xml
0 → 100644
浏览文件 @
dee7d93b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.taosdata.jdbc.springbootdemo.dao.RainfallMapper"
>
<insert
id=
"save"
parameterType=
"map"
>
INSERT INTO ${table} using ${dbname}.${stable} tags(#{values.station_code}, #{values.station_name}) (ts, name, code, rainfall) values (#{values.ts}, #{values.name}, #{values.code}, #{values.rainfall})
</insert>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.dao
;
import
com.taosdata.jdbc.springbootdemo.domain.TableMetadata
;
public
interface
TableMapper
{
boolean
createSTable
(
TableMetadata
tableMetadata
);
}
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/dao/TableMapper.xml
0 → 100644
浏览文件 @
dee7d93b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.taosdata.jdbc.springbootdemo.dao.TableMapper"
>
<update
id=
"createSTable"
parameterType=
"com.taosdata.jdbc.springbootdemo.domain.TableMetadata"
>
create table if not exists ${dbname}.${tablename}
<foreach
collection=
"fields"
item=
"field"
index=
"index"
open=
"("
close=
")"
separator=
","
>
${field.name} ${field.type}
</foreach>
TAGS
<foreach
collection=
"tags"
item=
"tag"
index=
"index"
open=
"("
close=
")"
separator=
","
>
${tag.name} ${tag.type}
</foreach>
</update>
<update
id=
"dropTable"
parameterType=
"java.lang.String"
>
drop ${tablename}
</update>
</mapper>
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/
resources/mapper
/WeatherMapper.xml
→
tests/examples/JDBC/springbootdemo/src/main/
java/com/taosdata/jdbc/springbootdemo/dao
/WeatherMapper.xml
浏览文件 @
dee7d93b
文件已移动
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/FieldMetadata.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.domain
;
public
class
FieldMetadata
{
private
String
name
;
private
String
type
;
public
FieldMetadata
(
String
name
,
String
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Rainfall.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.sql.Timestamp
;
public
class
Rainfall
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Timestamp
ts
;
private
String
name
;
private
String
code
;
private
float
rainfall
;
private
String
station_code
;
private
String
station_name
;
public
Timestamp
getTs
()
{
return
ts
;
}
public
void
setTs
(
Timestamp
ts
)
{
this
.
ts
=
ts
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
float
getRainfall
()
{
return
rainfall
;
}
public
void
setRainfall
(
float
rainfall
)
{
this
.
rainfall
=
rainfall
;
}
public
String
getStation_code
()
{
return
station_code
;
}
public
void
setStation_code
(
String
station_code
)
{
this
.
station_code
=
station_code
;
}
public
String
getStation_name
()
{
return
station_name
;
}
public
void
setStation_name
(
String
station_name
)
{
this
.
station_name
=
station_name
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TableMetadata.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.domain
;
import
java.util.List
;
public
class
TableMetadata
{
private
String
dbname
;
private
String
tablename
;
private
List
<
FieldMetadata
>
fields
;
private
List
<
TagMetadata
>
tags
;
public
String
getDbname
()
{
return
dbname
;
}
public
void
setDbname
(
String
dbname
)
{
this
.
dbname
=
dbname
;
}
public
String
getTablename
()
{
return
tablename
;
}
public
void
setTablename
(
String
tablename
)
{
this
.
tablename
=
tablename
;
}
public
List
<
FieldMetadata
>
getFields
()
{
return
fields
;
}
public
void
setFields
(
List
<
FieldMetadata
>
fields
)
{
this
.
fields
=
fields
;
}
public
List
<
TagMetadata
>
getTags
()
{
return
tags
;
}
public
void
setTags
(
List
<
TagMetadata
>
tags
)
{
this
.
tags
=
tags
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/TagMetadata.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.domain
;
public
class
TagMetadata
{
private
String
name
;
private
String
type
;
public
TagMetadata
(
String
name
,
String
type
)
{
this
.
name
=
name
;
this
.
type
=
type
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
}
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/domain/Weather.java
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.domain
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
java.sql.Timestamp
;
public
class
Weather
{
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss.SSS"
,
timezone
=
"GMT+8"
)
private
Timestamp
ts
;
private
int
temperature
;
...
...
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/RainStationService.java
0 → 100644
浏览文件 @
dee7d93b
package
com.taosdata.jdbc.springbootdemo.service
;
import
com.taosdata.jdbc.springbootdemo.dao.DatabaseMapper
;
import
com.taosdata.jdbc.springbootdemo.dao.RainfallMapper
;
import
com.taosdata.jdbc.springbootdemo.dao.TableMapper
;
import
com.taosdata.jdbc.springbootdemo.domain.FieldMetadata
;
import
com.taosdata.jdbc.springbootdemo.domain.Rainfall
;
import
com.taosdata.jdbc.springbootdemo.domain.TableMetadata
;
import
com.taosdata.jdbc.springbootdemo.domain.TagMetadata
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
RainStationService
{
@Autowired
private
DatabaseMapper
databaseMapper
;
@Autowired
private
TableMapper
tableMapper
;
@Autowired
private
RainfallMapper
rainfallMapper
;
public
boolean
init
()
{
databaseMapper
.
dropDatabase
(
"rainstation"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"dbname"
,
"rainstation"
);
map
.
put
(
"keep"
,
"36500"
);
map
.
put
(
"days"
,
"30"
);
map
.
put
(
"blocks"
,
"4"
);
databaseMapper
.
creatDatabaseWithParameters
(
map
);
databaseMapper
.
useDatabase
(
"rainstation"
);
return
true
;
}
public
boolean
createTable
()
{
TableMetadata
tableMetadata
=
new
TableMetadata
();
tableMetadata
.
setDbname
(
"rainstation"
);
tableMetadata
.
setTablename
(
"monitoring"
);
List
<
FieldMetadata
>
fields
=
new
ArrayList
<>();
fields
.
add
(
new
FieldMetadata
(
"ts"
,
"timestamp"
));
fields
.
add
(
new
FieldMetadata
(
"name"
,
"NCHAR(10)"
));
fields
.
add
(
new
FieldMetadata
(
"code"
,
" BINARY(8)"
));
fields
.
add
(
new
FieldMetadata
(
"rainfall"
,
"float"
));
tableMetadata
.
setFields
(
fields
);
List
<
TagMetadata
>
tags
=
new
ArrayList
<>();
tags
.
add
(
new
TagMetadata
(
"station_code"
,
"BINARY(8)"
));
tags
.
add
(
new
TagMetadata
(
"station_name"
,
"NCHAR(10)"
));
tableMetadata
.
setTags
(
tags
);
tableMapper
.
createSTable
(
tableMetadata
);
return
true
;
}
public
int
insert
(
Rainfall
rainfall
)
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"dbname"
,
"rainstation"
);
map
.
put
(
"table"
,
"S_53646"
);
map
.
put
(
"stable"
,
"monitoring"
);
map
.
put
(
"values"
,
rainfall
);
return
rainfallMapper
.
save
(
map
);
}
}
\ No newline at end of file
tests/examples/JDBC/springbootdemo/src/main/java/com/taosdata/jdbc/springbootdemo/service/WeatherService.java
浏览文件 @
dee7d93b
...
...
@@ -14,10 +14,8 @@ public class WeatherService {
private
WeatherMapper
weatherMapper
;
public
boolean
init
()
{
weatherMapper
.
createDB
();
weatherMapper
.
createTable
();
return
true
;
}
...
...
tests/examples/JDBC/springbootdemo/src/main/resources/application.properties
浏览文件 @
dee7d93b
# datasource config
spring.datasource.driver-class-name
=
com.taosdata.jdbc.TSDBDriver
spring.datasource.url
=
jdbc:TAOS://1
27.0.0.1
:6030/log
spring.datasource.url
=
jdbc:TAOS://1
92.168.236.137
:6030/log
spring.datasource.username
=
root
spring.datasource.password
=
taosdata
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录