You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
3.0 KiB
65 lines
3.0 KiB
<?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.iteaj.iboot.msn.iot.mapper.DeviceMapper">
|
|
|
|
<!-- 通用查询映射结果 -->
|
|
<resultMap id="BasicMap" type="com.iteaj.iboot.msn.iot.entity.Device">
|
|
<result column="id" property="id" />
|
|
<result column="ip" property="ip" />
|
|
<result column="uid" property="uid" />
|
|
<result column="lat" property="lat" />
|
|
<result column="lon" property="lon" />
|
|
<result column="name" property="name" />
|
|
<result column="port" property="port" />
|
|
<result column="model" property="model" />
|
|
<result column="extend" property="extend" />
|
|
<result column="status" property="status" />
|
|
<result column="address" property="address" />
|
|
<result column="account" property="account" />
|
|
<result column="password" property="password" />
|
|
<result column="device_sn" property="deviceSn" />
|
|
<result column="create_time" property="createTime" />
|
|
<result column="update_time" property="updateTime" />
|
|
<result column="device_type_id" property="deviceTypeId" />
|
|
</resultMap>
|
|
<resultMap id="DeviceDtoMap" type="com.iteaj.iboot.msn.iot.dto.DeviceDto" extends="BasicMap">
|
|
<result property="modelName" column="model_name" />
|
|
<result property="deviceTypeName" column="device_type_name" />
|
|
</resultMap>
|
|
<select id="pageOfDetail" resultMap="DeviceDtoMap">
|
|
select a.*, idm.model model_name, idt.name device_type_name from iot_device a
|
|
left join iot_device_type idt on a.device_type_id=idt.id
|
|
left join iot_device_model idm on a.model=idm.id
|
|
<where>
|
|
<if test="entity.status!=null">
|
|
and a.status = #{entity.status}
|
|
</if>
|
|
<if test="entity.alias!=null">
|
|
and idt.alias = #{entity.alias}
|
|
</if>
|
|
<if test="entity.deviceTypeId!=null">
|
|
and a.device_type_id = #{entity.deviceTypeId}
|
|
</if>
|
|
<if test="entity.deviceSn!=null and entity.deviceSn!=''">
|
|
and a.device_sn like '%${entity.deviceSn}%'
|
|
</if>
|
|
<if test="entity.name!=null and entity.name!=''">
|
|
and a.name like '%${entity.name}%'
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="countCurrentDevice" resultType="com.iteaj.iboot.msn.iot.dto.CurrentDeviceDto">
|
|
select count(1) today, count(status='online' or null) online from iot_device
|
|
</select>
|
|
|
|
<select id="getByUid" resultMap="DeviceDtoMap">
|
|
select * from iot_device where uid=#{uid}
|
|
</select>
|
|
<select id="detailById" resultType="com.iteaj.iboot.msn.iot.dto.DeviceDto">
|
|
select a.*, idm.model model_name, idt.name device_type_name from iot_device a
|
|
left join iot_device_type idt on a.device_type_id=idt.id
|
|
left join iot_device_model idm on a.model=idm.id
|
|
where a.id=#{id}
|
|
</select>
|
|
</mapper>
|