提交 7ffbb655 编写于 作者: Z zyyang

modified the springboot demo

上级 83ba94b6
......@@ -64,6 +64,8 @@
<groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId>
<version>2.0.20</version>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/src/main/resources/taos-jdbcdriver-2.0.20-dist.jar</systemPath>-->
</dependency>
<dependency>
......
......@@ -10,4 +10,4 @@ public class SpringbootdemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootdemoApplication.class, args);
}
}
}
\ No newline at end of file
......@@ -60,7 +60,7 @@ public class WeatherController {
}
@GetMapping("/avg")
public Map avg() {
public List<Weather> avg() {
return weatherService.avg();
}
......
......@@ -24,6 +24,6 @@ public interface WeatherMapper {
List<String> getSubTables();
Map avg();
List<Weather> avg();
}
......@@ -5,7 +5,7 @@
<resultMap id="BaseResultMap" type="com.taosdata.example.springbootdemo.domain.Weather">
<id column="ts" jdbcType="TIMESTAMP" property="ts"/>
<result column="temperature" jdbcType="INTEGER" property="temperature"/>
<result column="temperature" jdbcType="FLOAT" property="temperature"/>
<result column="humidity" jdbcType="FLOAT" property="humidity"/>
</resultMap>
......@@ -18,7 +18,7 @@
</update>
<update id="createSuperTable">
create table if not exists test.weather(ts timestamp, temperature float, humidity int) tags(location nchar(64), groupId int)
create table if not exists test.weather(ts timestamp, temperature float, humidity float) tags(location nchar(64), groupId int)
</update>
<update id="createTable" parameterType="com.taosdata.example.springbootdemo.domain.Weather">
......@@ -47,7 +47,13 @@
select count(*) from test.weather
</select>
<select id="avg" resultType="map">
<resultMap id="avgResultSet" type="com.taosdata.example.springbootdemo.domain.Weather">
<id column="ts" jdbcType="TIMESTAMP" property="ts" />
<result column="avg(temperature)" jdbcType="FLOAT" property="temperature" />
<result column="avg(humidity)" jdbcType="FLOAT" property="humidity" />
</resultMap>
<select id="avg" resultMap="avgResultSet">
select avg(temperature), avg(humidity)from test.weather interval(1m)
</select>
......
......@@ -9,14 +9,14 @@ public class Weather {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss.SSS", timezone = "GMT+8")
private Timestamp ts;
private float temperature;
private int humidity;
private float humidity;
private String location;
private int groupId;
public Weather() {
}
public Weather(Timestamp ts, float temperature, int humidity) {
public Weather(Timestamp ts, float temperature, float humidity) {
this.ts = ts;
this.temperature = temperature;
this.humidity = humidity;
......@@ -38,11 +38,11 @@ public class Weather {
this.temperature = temperature;
}
public int getHumidity() {
public float getHumidity() {
return humidity;
}
public void setHumidity(int humidity) {
public void setHumidity(float humidity) {
this.humidity = humidity;
}
......
......@@ -55,7 +55,7 @@ public class WeatherService {
return weatherMapper.getSubTables();
}
public Map avg() {
public List<Weather> avg() {
return weatherMapper.avg();
}
}
# datasource config - JDBC-JNI
spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username=root
spring.datasource.password=taosdata
# datasource config - JDBC-RESTful
#spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
#spring.datasource.url=jdbc:TAOS-RS://master:6041/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
#spring.datasource.driver-class-name=com.taosdata.jdbc.TSDBDriver
#spring.datasource.url=jdbc:TAOS://127.0.0.1:6030/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
#spring.datasource.username=root
#spring.datasource.password=taosdata
# datasource config - JDBC-RESTful
spring.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
spring.datasource.url=jdbc:TAOS-RS://master:6041/test?timezone=UTC-8&charset=UTF-8&locale=en_US.UTF-8
spring.datasource.username=root
spring.datasource.password=taosdata
spring.datasource.druid.initial-size=5
spring.datasource.druid.min-idle=5
spring.datasource.druid.max-active=5
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册