Commit 54df5df0313f251b8d84b77bbc64e4a8bfe86393

Authored by 朱俊杰
1 parent 37a84e66

mapper改用注释方式

src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -203,5 +203,19 @@ public interface DeviceChannelMapper { @@ -203,5 +203,19 @@ public interface DeviceChannelMapper {
203 @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1") 203 @Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
204 List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); 204 List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
205 205
  206 + @Select(" SELECT\n" +
  207 + " channelId,\n" +
  208 + " channelId as id,\n" +
  209 + " deviceId,\n" +
  210 + " parentId,\n" +
  211 + " status,\n" +
  212 + " name as title,\n" +
  213 + " channelId as \"value\",\n" +
  214 + " channelId as \"key\",\n" +
  215 + " channelId,\n" +
  216 + " longitude,\n" +
  217 + " latitude\n" +
  218 + " from device_channel\n" +
  219 + " where deviceId = #{deviceId}")
206 List<DeviceChannelTree> tree(String deviceId); 220 List<DeviceChannelTree> tree(String deviceId);
207 } 221 }
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.xml deleted 100644 → 0
1 -<?xml version="1.0" encoding="UTF-8"?>  
2 -<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
3 -<mapper namespace="com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper">  
4 -  
5 - <!-- 通用查询映射结果 -->  
6 - <resultMap id="treeNodeResultMap" type="com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTreeNode">  
7 - <id column="id" property="id"/>  
8 - <result column="parentId" property="parentId"/>  
9 - <result column="status" property="status"/>  
10 - <result column="title" property="title"/>  
11 - <result column="value" property="value"/>  
12 - <result column="key" property="key"/>  
13 - <result column="deviceId" property="deviceId"/>  
14 - <result column="channelId" property="channelId"/>  
15 - <result column="longitude" property="lng"/>  
16 - <result column="latitude" property="lat"/>  
17 - </resultMap>  
18 -  
19 -  
20 - <select id="tree" resultMap="treeNodeResultMap">  
21 - SELECT  
22 - channelId,  
23 - channelId as id,  
24 - deviceId,  
25 - parentId,  
26 - status,  
27 - name as title,  
28 - channelId as "value",  
29 - channelId as "key",  
30 - channelId,  
31 - longitude,  
32 - latitude  
33 - from device_channel  
34 - where deviceId = #{deviceId}  
35 - </select>  
36 -  
37 -</mapper>  
src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeviceChannelTree.java
@@ -28,6 +28,12 @@ public class DeviceChannelTree extends DeviceChannel implements INode&lt;DeviceChan @@ -28,6 +28,12 @@ public class DeviceChannelTree extends DeviceChannel implements INode&lt;DeviceChan
28 28
29 private String parentName; 29 private String parentName;
30 30
  31 + private String title;
  32 +
  33 + private String key;
  34 +
  35 + private String value;
  36 +
31 /** 37 /**
32 * 子孙节点 38 * 子孙节点
33 */ 39 */
@@ -47,4 +53,13 @@ public class DeviceChannelTree extends DeviceChannel implements INode&lt;DeviceChan @@ -47,4 +53,13 @@ public class DeviceChannelTree extends DeviceChannel implements INode&lt;DeviceChan
47 } 53 }
48 return this.children; 54 return this.children;
49 } 55 }
  56 +
  57 + @Override
  58 + public Boolean getHasChildren() {
  59 + if (children.size() > 0) {
  60 + return true;
  61 + } else {
  62 + return this.hasChildren;
  63 + }
  64 + }
50 } 65 }