WatchDeviceAccountMapper.xml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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.WatchDeviceAccountMapper">
  6. <resultMap type="WatchDeviceAccount" id="WatchDeviceAccountResult">
  7. <result property="id" column="id" />
  8. <result property="deviceId" column="device_id" />
  9. <result property="account" column="account" />
  10. <result property="password" column="password" />
  11. </resultMap>
  12. <sql id="selectWatchDeviceAccountVo">
  13. select id, device_id, account, password from watch_device_account
  14. </sql>
  15. <select id="selectWatchDeviceAccountList" parameterType="WatchDeviceAccount" resultMap="WatchDeviceAccountResult">
  16. <include refid="selectWatchDeviceAccountVo"/>
  17. <where>
  18. <if test="deviceId != null "> and device_id = #{deviceId}</if>
  19. <if test="account != null and account != ''"> and account = #{account}</if>
  20. <if test="password != null and password != ''"> and password = #{password}</if>
  21. </where>
  22. </select>
  23. <select id="selectWatchDeviceAccountById" parameterType="Long" resultMap="WatchDeviceAccountResult">
  24. <include refid="selectWatchDeviceAccountVo"/>
  25. where id = #{id}
  26. </select>
  27. <select id="selectWatchDeviceAccountByDeviceId" resultType="com.fs.watch.domain.WatchDeviceAccount">
  28. <include refid="selectWatchDeviceAccountVo"/>
  29. where device_id like #{deviceId}
  30. </select>
  31. <insert id="insertWatchDeviceAccount" parameterType="WatchDeviceAccount" useGeneratedKeys="true" keyProperty="id">
  32. insert into watch_device_account
  33. <trim prefix="(" suffix=")" suffixOverrides=",">
  34. <if test="deviceId != null">device_id,</if>
  35. <if test="account != null">account,</if>
  36. <if test="password != null">password,</if>
  37. </trim>
  38. <trim prefix="values (" suffix=")" suffixOverrides=",">
  39. <if test="deviceId != null">#{deviceId},</if>
  40. <if test="account != null">#{account},</if>
  41. <if test="password != null">#{password},</if>
  42. </trim>
  43. </insert>
  44. <update id="updateWatchDeviceAccount" parameterType="WatchDeviceAccount">
  45. update watch_device_account
  46. <trim prefix="SET" suffixOverrides=",">
  47. <if test="deviceId != null">device_id = #{deviceId},</if>
  48. <if test="account != null">account = #{account},</if>
  49. <if test="password != null">password = #{password},</if>
  50. </trim>
  51. where id = #{id}
  52. </update>
  53. <delete id="deleteWatchDeviceAccountById" parameterType="Long">
  54. delete from watch_device_account where id = #{id}
  55. </delete>
  56. <delete id="deleteWatchDeviceAccountByIds" parameterType="String">
  57. delete from watch_device_account where id in
  58. <foreach item="id" collection="array" open="(" separator="," close=")">
  59. #{id}
  60. </foreach>
  61. </delete>
  62. </mapper>