Explorar el Código

验证tdengine链接测试

lengfaqiang hace 2 años
padre
commit
da2bf9517f

+ 5 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/dao/tdengine/SlopeDataMapper.java

@@ -3,6 +3,8 @@ package com.sckw.slope.detection.dao.tdengine;
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
@@ -13,8 +15,11 @@ import java.util.List;
  */
 @DS("td")
 @Mapper
+@Repository
 public interface SlopeDataMapper {
 
+    @Select("select * from slope_data")
     List<SlopeData> selectAll();
 
+    List<SlopeData> selectList();
 }

+ 4 - 0
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/TdengineDemoService.java

@@ -1,5 +1,6 @@
 package com.sckw.slope.detection.service;
 
+import com.alibaba.fastjson2.JSONObject;
 import com.sckw.slope.detection.dao.tdengine.SlopeDataMapper;
 import com.sckw.slope.detection.model.dos.tdengine.SlopeData;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,5 +20,8 @@ public class TdengineDemoService {
 
     public void tdengineDemo() {
         List<SlopeData> list = slopeDataMapper.selectAll();
+        System.out.println(JSONObject.toJSONString(list));
+        List<SlopeData> list1 = slopeDataMapper.selectList();
+        System.out.println(JSONObject.toJSONString(list1));
     }
 }

+ 3 - 4
slope-modules/slope-detection/src/main/resources/mapper/tdengine/SlopeDataMapper.xml

@@ -2,9 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.sckw.slope.detection.dao.tdengine.SlopeDataMapper">
 
-    <select id="selectAll" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
-        SELECT ts, raw_id as rawId, device_id as deviceId, item_name AS itemName, item_value AS itemValue, create_time AS createTime, id, name
-        FROM devices.slope_data
-
+    <select id="selectList" resultType="com.sckw.slope.detection.model.dos.tdengine.SlopeData">
+<!--        ts, raw_id , device_id, item_name as itemName, item_value as itemValue, create_time as createTime-->
+        SELECT * FROM slope_data
     </select>
 </mapper>