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

3 years ago
  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.iteaj.iboot.msn.iot.mapper.DeviceMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BasicMap" type="com.iteaj.iboot.msn.iot.entity.Device">
  6. <result column="id" property="id" />
  7. <result column="ip" property="ip" />
  8. <result column="uid" property="uid" />
  9. <result column="lat" property="lat" />
  10. <result column="lon" property="lon" />
  11. <result column="name" property="name" />
  12. <result column="port" property="port" />
  13. <result column="model" property="model" />
  14. <result column="extend" property="extend" />
  15. <result column="status" property="status" />
  16. <result column="address" property="address" />
  17. <result column="account" property="account" />
  18. <result column="password" property="password" />
  19. <result column="device_sn" property="deviceSn" />
  20. <result column="create_time" property="createTime" />
  21. <result column="update_time" property="updateTime" />
  22. <result column="device_type_id" property="deviceTypeId" />
  23. </resultMap>
  24. <resultMap id="DeviceDtoMap" type="com.iteaj.iboot.msn.iot.dto.DeviceDto" extends="BasicMap">
  25. <result property="modelName" column="model_name" />
  26. <result property="deviceTypeName" column="device_type_name" />
  27. </resultMap>
  28. <select id="pageOfDetail" resultMap="DeviceDtoMap">
  29. select a.*, idm.model model_name, idt.name device_type_name from iot_device a
  30. left join iot_device_type idt on a.device_type_id=idt.id
  31. left join iot_device_model idm on a.model=idm.id
  32. <where>
  33. <if test="entity.status!=null">
  34. and a.status = #{entity.status}
  35. </if>
  36. <if test="entity.alias!=null">
  37. and idt.alias = #{entity.alias}
  38. </if>
  39. <if test="entity.deviceTypeId!=null">
  40. and a.device_type_id = #{entity.deviceTypeId}
  41. </if>
  42. <if test="entity.deviceSn!=null and entity.deviceSn!=''">
  43. and a.device_sn like '%${entity.deviceSn}%'
  44. </if>
  45. <if test="entity.name!=null and entity.name!=''">
  46. and a.name like '%${entity.name}%'
  47. </if>
  48. </where>
  49. </select>
  50. <select id="countCurrentDevice" resultType="com.iteaj.iboot.msn.iot.dto.CurrentDeviceDto">
  51. select count(1) today, count(status='online' or null) online from iot_device
  52. </select>
  53. <select id="getByUid" resultMap="DeviceDtoMap">
  54. select * from iot_device where uid=#{uid}
  55. </select>
  56. <select id="detailById" resultType="com.iteaj.iboot.msn.iot.dto.DeviceDto">
  57. select a.*, idm.model model_name, idt.name device_type_name from iot_device a
  58. left join iot_device_type idt on a.device_type_id=idt.id
  59. left join iot_device_model idm on a.model=idm.id
  60. where a.id=#{id}
  61. </select>
  62. </mapper>