DeviceMapper.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.bizmatics.persistence.mapper.DeviceMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.bizmatics.model.Device">
  6. <id column="id" property="id" />
  7. <result column="device_code" property="deviceCode" />
  8. <result column="device_name" property="deviceName" />
  9. <result column="site_id" property="siteId" />
  10. <result column="device_address" property="deviceAddress" />
  11. <result column="device_type" property="deviceType" />
  12. <result column="install_time" property="installTime" />
  13. <result column="creator" property="creator" />
  14. <result column="enable" property="enable" />
  15. </resultMap>
  16. <select id="selectCount" resultType="java.lang.Integer">
  17. select count(1)
  18. from user_site as us
  19. inner join device_status as ds
  20. on us.site_id = ds.site_id
  21. inner join device as d
  22. on us.site_id = d.site_Id
  23. <where>
  24. <if test="userId != null and userId != 0">
  25. and us.user_id = #{userId}
  26. </if>
  27. <if test="siteId != null and siteId != 0">
  28. and us.site_id = #{siteId}
  29. </if>
  30. <if test="deviceStatus != null">
  31. and ds.device_status = #{deviceStatus}
  32. </if>
  33. <if test="startTime != null">
  34. and ds.status_time >= #{startTime}
  35. </if>
  36. <if test="endTime != null">
  37. and ds.status_time &lt;= #{endTime}
  38. </if>
  39. <if test="type != null">
  40. and d.device_type = #{type}
  41. </if>
  42. </where>
  43. </select>
  44. </mapper>