mapper改用注释方式
parent
37a84e6691
commit
54df5df031
|
@ -203,5 +203,19 @@ public interface DeviceChannelMapper {
|
||||||
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
|
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
|
||||||
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
||||||
|
|
||||||
|
@Select(" SELECT\n" +
|
||||||
|
" channelId,\n" +
|
||||||
|
" channelId as id,\n" +
|
||||||
|
" deviceId,\n" +
|
||||||
|
" parentId,\n" +
|
||||||
|
" status,\n" +
|
||||||
|
" name as title,\n" +
|
||||||
|
" channelId as \"value\",\n" +
|
||||||
|
" channelId as \"key\",\n" +
|
||||||
|
" channelId,\n" +
|
||||||
|
" longitude,\n" +
|
||||||
|
" latitude\n" +
|
||||||
|
" from device_channel\n" +
|
||||||
|
" where deviceId = #{deviceId}")
|
||||||
List<DeviceChannelTree> tree(String deviceId);
|
List<DeviceChannelTree> tree(String deviceId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
<?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.genersoft.iot.vmp.storager.dao.DeviceChannelMapper">
|
|
||||||
|
|
||||||
<!-- 通用查询映射结果 -->
|
|
||||||
<resultMap id="treeNodeResultMap" type="com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTreeNode">
|
|
||||||
<id column="id" property="id"/>
|
|
||||||
<result column="parentId" property="parentId"/>
|
|
||||||
<result column="status" property="status"/>
|
|
||||||
<result column="title" property="title"/>
|
|
||||||
<result column="value" property="value"/>
|
|
||||||
<result column="key" property="key"/>
|
|
||||||
<result column="deviceId" property="deviceId"/>
|
|
||||||
<result column="channelId" property="channelId"/>
|
|
||||||
<result column="longitude" property="lng"/>
|
|
||||||
<result column="latitude" property="lat"/>
|
|
||||||
</resultMap>
|
|
||||||
|
|
||||||
|
|
||||||
<select id="tree" resultMap="treeNodeResultMap">
|
|
||||||
SELECT
|
|
||||||
channelId,
|
|
||||||
channelId as id,
|
|
||||||
deviceId,
|
|
||||||
parentId,
|
|
||||||
status,
|
|
||||||
name as title,
|
|
||||||
channelId as "value",
|
|
||||||
channelId as "key",
|
|
||||||
channelId,
|
|
||||||
longitude,
|
|
||||||
latitude
|
|
||||||
from device_channel
|
|
||||||
where deviceId = #{deviceId}
|
|
||||||
</select>
|
|
||||||
|
|
||||||
</mapper>
|
|
|
@ -28,6 +28,12 @@ public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChan
|
||||||
|
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子孙节点
|
* 子孙节点
|
||||||
*/
|
*/
|
||||||
|
@ -47,4 +53,13 @@ public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChan
|
||||||
}
|
}
|
||||||
return this.children;
|
return this.children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean getHasChildren() {
|
||||||
|
if (children.size() > 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return this.hasChildren;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue