WatchDeviceDataMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.watch.mapper.WatchDeviceDataMapper">
  6. <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchDeviceData">
  7. <result property="id" column="id" jdbcType="OTHER" typeHandler="com.fs.watch.handler.UUIDTypeHandler"/>
  8. <result property="deviceId" column="device_id" jdbcType="VARCHAR"/>
  9. <result property="model" column="model" jdbcType="VARCHAR"/>
  10. <result property="version" column="version" jdbcType="VARCHAR"/>
  11. <result property="ble" column="ble" jdbcType="VARCHAR"/>
  12. <result property="sim" column="SIM" jdbcType="VARCHAR"/>
  13. <result property="isBind" column="isBind" jdbcType="BOOLEAN"/>
  14. <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. id,device_id,model,
  18. version,ble,SIM,isBind,create_time
  19. </sql>
  20. <!-- 查询设备的插入时间 -->
  21. <select id="queryByCreateTime" resultType="java.lang.Integer">
  22. SELECT COUNT(*)
  23. FROM watch_device_data
  24. WHERE create_time = #{createTime}
  25. </select>
  26. <update id="insert" parameterType="com.fs.watch.domain.WatchDeviceData">
  27. INSERT INTO watch_device_data
  28. <trim prefix="(" suffix=")" suffixOverrides=",">
  29. <if test="data.id != null">
  30. id,
  31. </if>
  32. <if test="data.deviceId != null and data.deviceId!=''">
  33. device_id,
  34. </if>
  35. <if test="data.model != null and data.model!=''">
  36. model,
  37. </if>
  38. <if test="data.version != null and data.version!=''">
  39. version,
  40. </if>
  41. <if test="data.ble != null and data.ble!=''">
  42. ble,
  43. </if>
  44. <if test="data.SIM != null and data.SIM!=''">
  45. SIM,
  46. </if>
  47. <if test="data.isBind != null and data.isBind!=''">
  48. isBind,
  49. </if>
  50. <if test="data.createTime != null">
  51. create_time,
  52. </if>
  53. </trim>
  54. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  55. <if test="data.id != null">
  56. #{data.id},
  57. </if>
  58. <if test="data.deviceId != null and data.deviceId!=''">
  59. #{data.deviceId},
  60. </if>
  61. <if test="data.model != null and data.model!=''">
  62. #{data.model},
  63. </if>
  64. <if test="data.version != null and data.version!=''">
  65. #{data.version},
  66. </if>
  67. <if test="data.ble != null and data.ble!=''">
  68. #{data.ble},
  69. </if>
  70. <if test="data.SIM != null and data.SIM!=''">
  71. #{data.SIM},
  72. </if>
  73. <if test="data.isBind != null and data.isBind!=''">
  74. #{data.isBind},
  75. </if>
  76. <if test="data.createTime != null">
  77. #{data.createTime},
  78. </if>
  79. </trim>
  80. </update>
  81. <update id="upadate">
  82. update watch_device_data
  83. <trim prefix="SET" suffixOverrides=",">
  84. <if test="data.model != null and data.model !=''">model = #{data.model},</if>
  85. <if test="data.version != null and data.version !=''">version = #{data.version},</if>
  86. <if test="data.ble != null and data.ble !=''">ble = #{data.ble},</if>
  87. <if test="data.sim != null and data.sim !=''">SIM = #{data.sim},</if>
  88. <if test="data.isBind != null">isBind = #{data.isBind},</if>
  89. </trim>
  90. where device_id = #{data.deviceId}
  91. </update>
  92. <delete id="deleteByDeviceId">
  93. ALTER TABLE watch_device_data DELETE WHERE device_id = #{deviceId}
  94. </delete>
  95. <update id="updateByDeviceId">
  96. ALTER TABLE watch.watch_device_data UPDATE
  97. <trim prefix="" suffixOverrides=",">
  98. <if test="data.model != null and data.model !=''">model = #{data.model},</if>
  99. <if test="data.version != null and data.version !=''">version = #{data.version},</if>
  100. <if test="data.ble != null and data.ble !=''">ble = #{data.ble},</if>
  101. <if test="data.sim != null and data.sim !=''">SIM = #{data.sim},</if>
  102. <if test="data.isBind != null">isBind = #{data.isBind},</if>
  103. </trim>
  104. WHERE device_id = #{data.deviceId}
  105. </update>
  106. <select id="getByDeviceId" resultMap="BaseResultMap">
  107. select id,device_id,model,
  108. version,ble,SIM,isBind,create_time from watch_device_data where device_id = #{deviceId}
  109. </select>
  110. <select id="getListByDeviceId" resultMap="BaseResultMap">
  111. select id,device_id,model,
  112. version,ble,SIM,isBind,create_time from watch_device_data where device_id in #{deviceIds}
  113. </select>
  114. <select id="existsByDeviceId" resultType="java.lang.Integer">
  115. SELECT COUNT(1)
  116. FROM watch_device_data
  117. WHERE device_id = #{deviceId}
  118. </select>
  119. </mapper>