iot-gateway/src/main/resources/mappers/iotMappers/DeviceMapper.xml

88 lines
4.2 KiB
XML
Raw Normal View History

<?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.zsc.edu.gateway.modules.iot.device.repo.DeviceRepository">
<resultMap id="BaseResultMap" type="com.zsc.edu.gateway.modules.iot.device.vo.DeviceVo">
<id column="id" property="id"/>
<result column="name" property="name"/>
<result column="online" property="online"/>
<result column="state" property="state"/>
<result column="hardware_version" property="hardwareVersion"/>
<result column="firmware_version" property="firmwareVersion"/>
<result column="factory_id" property="factoryId"/>
<result column="client_id" property="clientId"/>
<result column="product_id" property="productId"/>
<result column="extend_params" property="extendParams"/>
<result column="properties" property="properties"/>
<result column="create_by" jdbcType="VARCHAR" property="deviceCreateBy"/>
<result column="update_by" jdbcType="VARCHAR" property="deviceUpdateBy"/>
<result column="create_time" jdbcType="DATE" property="deviceCreateTime"/>
<result column="update_time" jdbcType="DATE" property="deviceUpdateTime"/>
<result column="remark" jdbcType="VARCHAR" property="deviceRemark"/>
<result column="name" property="name"/>
<result column="type_string" jdbcType="VARCHAR" property="typeString"/>
<result column="model" property="model"/>
<result column="link" property="link"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="create_time" jdbcType="DATE" property="createTime"/>
<result column="update_time" jdbcType="DATE" property="updateTime"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<collection property="params" ofType="com.zsc.edu.gateway.modules.iot.tsl.entity.Param" autoMapping="true"
columnPrefix="param_">
<id column="id" property="id"/>
<result column="data_type" property="dataType"/>
<result column="uint" property="uint"/>
<result column="type" property="type"/>
<result column="identifier" property="identifier"/>
<result column="name" property="name"/>
<result column="remark" property="remark"/>
</collection>
</resultMap>
<select id="query" resultMap="BaseResultMap">
select d.*,p.*,
ip.id as param_id,ip.data_type as param_data_type,ip.uint as param_uint,ip.type as param_type,ip.identifier as
param_identifier,ip.name as param_name,ip.remark as param_remark
from iot_device d
left join iot_product p on d.product_id = p.id
left join iot_product_param pp on p.id = pp.product_id
left join iot_param ip on pp.param_id = ip.id
<where>
<if test="query.name != null and query.name != ''">
and d.name = #{query.name}
</if>
<if test="query.clientId != null and query.clientId != ''">
and d.client_id = #{query.clientId}
</if>
<if test="query.productId != null">
and d.product_id = #{query.productId}
</if>
<if test="query.status != null">
and d.status = #{query.status}
</if>
<if test="query.isOnline != null">
and d.online = #{query.isOnline}
</if>
</where>
</select>
<select id="findById" resultMap="BaseResultMap">
select d.*,
p.*,
ip.id as param_id,
ip.data_type as param_data_type,
ip.uint as param_uint,
ip.type as param_type,
ip.identifier as param_identifier,
ip.name as param_name,
ip.remark as param_remark
from iot_device d
left join iot_product p on d.product_id = p.id
left join iot_product_param pp on pp.product_id = p.id
left join iot_param ip on pp.param_id = ip.id
where d.id = #{id}
</select>
</mapper>