DeviceMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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.prac.simple.mapper.DeviceMapper">
  4. <resultMap id="BaseResultMap" type="com.prac.simple.entity.Device">
  5. <id column="mac" jdbcType="VARCHAR" property="mac" />
  6. <result column="name" jdbcType="VARCHAR" property="name" />
  7. <result column="open" jdbcType="CHAR" property="open" />
  8. <result column="type" jdbcType="CHAR" property="type" />
  9. <result column="description" jdbcType="VARCHAR" property="description" />
  10. <result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
  11. <result column="modifytime" jdbcType="TIMESTAMP" property="modifytime" />
  12. </resultMap>
  13. <sql id="Base_Column_List">
  14. mac, name, open, type, description, createtime, modifytime
  15. </sql>
  16. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  17. select
  18. <include refid="Base_Column_List" />
  19. from device
  20. where mac = #{mac,jdbcType=VARCHAR}
  21. </select>
  22. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  23. delete from device
  24. where mac = #{mac,jdbcType=VARCHAR}
  25. </delete>
  26. <insert id="insert" parameterType="com.prac.simple.entity.Device">
  27. insert into device (mac, name, open,
  28. type, description, createtime,
  29. modifytime)
  30. values (#{mac,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{open,jdbcType=CHAR},
  31. #{type,jdbcType=CHAR}, #{description,jdbcType=VARCHAR}, #{createtime,jdbcType=TIMESTAMP},
  32. #{modifytime,jdbcType=TIMESTAMP})
  33. </insert>
  34. <insert id="insertSelective" parameterType="com.prac.simple.entity.Device">
  35. insert into device
  36. <trim prefix="(" suffix=")" suffixOverrides=",">
  37. <if test="mac != null">
  38. mac,
  39. </if>
  40. <if test="name != null">
  41. name,
  42. </if>
  43. <if test="open != null">
  44. open,
  45. </if>
  46. <if test="type != null">
  47. type,
  48. </if>
  49. <if test="description != null">
  50. description,
  51. </if>
  52. <if test="createtime != null">
  53. createtime,
  54. </if>
  55. <if test="modifytime != null">
  56. modifytime,
  57. </if>
  58. </trim>
  59. <trim prefix="values (" suffix=")" suffixOverrides=",">
  60. <if test="mac != null">
  61. #{mac,jdbcType=VARCHAR},
  62. </if>
  63. <if test="name != null">
  64. #{name,jdbcType=VARCHAR},
  65. </if>
  66. <if test="open != null">
  67. #{open,jdbcType=CHAR},
  68. </if>
  69. <if test="type != null">
  70. #{type,jdbcType=CHAR},
  71. </if>
  72. <if test="description != null">
  73. #{description,jdbcType=VARCHAR},
  74. </if>
  75. <if test="createtime != null">
  76. #{createtime,jdbcType=TIMESTAMP},
  77. </if>
  78. <if test="modifytime != null">
  79. #{modifytime,jdbcType=TIMESTAMP},
  80. </if>
  81. </trim>
  82. </insert>
  83. <update id="updateByPrimaryKeySelective" parameterType="com.prac.simple.entity.Device">
  84. update device
  85. <set>
  86. <if test="name != null">
  87. name = #{name,jdbcType=VARCHAR},
  88. </if>
  89. <if test="open != null">
  90. open = #{open,jdbcType=CHAR},
  91. </if>
  92. <if test="type != null">
  93. type = #{type,jdbcType=CHAR},
  94. </if>
  95. <if test="description != null">
  96. description = #{description,jdbcType=VARCHAR},
  97. </if>
  98. <if test="createtime != null">
  99. createtime = #{createtime,jdbcType=TIMESTAMP},
  100. </if>
  101. <if test="modifytime != null">
  102. modifytime = #{modifytime,jdbcType=TIMESTAMP},
  103. </if>
  104. </set>
  105. where mac = #{mac,jdbcType=VARCHAR}
  106. </update>
  107. <update id="updateByPrimaryKey" parameterType="com.prac.simple.entity.Device">
  108. update device
  109. set name = #{name,jdbcType=VARCHAR},
  110. open = #{open,jdbcType=CHAR},
  111. type = #{type,jdbcType=CHAR},
  112. description = #{description,jdbcType=VARCHAR},
  113. createtime = #{createtime,jdbcType=TIMESTAMP},
  114. modifytime = #{modifytime,jdbcType=TIMESTAMP}
  115. where mac = #{mac,jdbcType=VARCHAR}
  116. </update>
  117. <select id="selectDevice" parameterType="DeviceReq" resultMap="BaseResultMap">
  118. select <include refid="Base_Column_List" />
  119. from device
  120. <where>
  121. <if test="mac != null and mac != ''">
  122. mac like CONCAT('%',#{mac,jdbcType=VARCHAR},'%')
  123. </if>
  124. <if test="name != null and name != ''">
  125. and name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  126. </if>
  127. </where>
  128. <if test="sort != null and sort != ''">
  129. order by ${sort}
  130. <if test="order != null and order != ''">
  131. ${order}
  132. </if>
  133. </if>
  134. </select>
  135. </mapper>