WatchAccelerometerDataMapper.xml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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.WatchAccelerometerDataMapper">
  6. <resultMap id="BaseResultMap" type="com.fs.watch.domain.WatchAccelerometerData">
  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="x" column="json_data.x" jdbcType="OTHER" typeHandler="com.fs.watch.handler.ArrayTypeHandler"/>
  10. <result property="y" column="json_data.y" jdbcType="OTHER" typeHandler="com.fs.watch.handler.ArrayTypeHandler"/>
  11. <result property="z" column="json_data.z" jdbcType="OTHER" typeHandler="com.fs.watch.handler.ArrayTypeHandler"/>
  12. <result property="createTime" column="create_time" jdbcType="VARCHAR"/>
  13. </resultMap>
  14. <sql id="Base_Column_List">
  15. id, device_id, json_data.x, json_data.y, json_data.z, create_time
  16. </sql>
  17. <update id="insert" parameterType="com.fs.watch.domain.WatchAccelerometerData">
  18. INSERT INTO watch_accelerometer_data
  19. <trim prefix="(" suffix=")" suffixOverrides=",">
  20. <if test="data.id != null and data.id != ''">
  21. id,
  22. </if>
  23. <if test="data.deviceId != null and data.deviceId != ''">
  24. device_id,
  25. </if>
  26. <if test="data.x != null">
  27. `json_data.x`,
  28. </if>
  29. <if test="data.y != null">
  30. `json_data.y`,
  31. </if>
  32. <if test="data.z != null">
  33. `json_data.z`,
  34. </if>
  35. <if test="data.createTime != null and data.createTime != ''">
  36. create_time,
  37. </if>
  38. </trim>
  39. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  40. <if test="data.id != null and data.id != ''">
  41. #{data.id},
  42. </if>
  43. <if test="data.deviceId != null and data.deviceId != ''">
  44. #{data.deviceId},
  45. </if>
  46. <if test="data.x != null">
  47. #{data.x, typeHandler=com.fs.watchApi.handler.ArrayTypeHandler},
  48. </if>
  49. <if test="data.y != null">
  50. #{data.y, typeHandler=com.fs.watchApi.handler.ArrayTypeHandler},
  51. </if>
  52. <if test="data.z != null">
  53. #{data.z, typeHandler=com.fs.watchApi.handler.ArrayTypeHandler},
  54. </if>
  55. <if test="data.createTime != null and data.createTime != ''">
  56. #{data.createTime},
  57. </if>
  58. </trim>
  59. </update>
  60. <select id="queryByCreateTime" resultType="java.lang.Integer">
  61. SELECT COUNT(*) FROM watch_accelerometer_data WHERE create_time = #{createTime}
  62. </select>
  63. <select id="getLastByDeviceId" resultMap="BaseResultMap">
  64. select * from watch_accelerometer_data where device_id like #{deviceId} order by create_time desc limit 1
  65. </select>
  66. </mapper>