ConfigDeviceMapper.xml 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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="cn.oleauto.config.mapper.ConfigDeviceMapper">
  6. <resultMap type="ConfigDevice" id="ConfigDeviceResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="configChannelId" column="config_channel_id" />
  10. <result property="ilk" column="ilk" />
  11. <result property="configDeviceId" column="config_device_id" />
  12. <result property="remark" column="remark" />
  13. <association property="configChannel" javaType="ConfigChannel" resultMap="ConfigChannelResult" />
  14. </resultMap>
  15. <resultMap type="ConfigChannel" id="ConfigChannelResult">
  16. <result property="id" column="config_channel_id" />
  17. <result property="name" column="config_channel_name" />
  18. </resultMap>
  19. <sql id="selectConfigDeviceVoGen">
  20. select id, name, config_channel_id, ilk, config_device_id, remark from config_device d
  21. </sql>
  22. <sql id="selectConfigDeviceVo">
  23. select d.id, d.name, d.config_channel_id, d.ilk, d.config_device_id, d.remark,
  24. c.name config_channel_name
  25. from config_device d
  26. LEFT JOIN config_channel c on d.config_channel_id = c.id
  27. </sql>
  28. <select id="selectConfigDeviceList" parameterType="ConfigDevice" resultMap="ConfigDeviceResult">
  29. <include refid="selectConfigDeviceVo"/>
  30. <where>
  31. <if test="name != null and name != ''"> and d.name like concat('%', #{name}, '%')</if>
  32. <if test="configChannelId != null "> and d.config_channel_id = #{configChannelId}</if>
  33. <if test="ilk != null and ilk != ''"> and d.ilk = #{ilk}</if>
  34. <if test="configDeviceId != null "> and d.config_device_id = #{configDeviceId}</if>
  35. </where>
  36. </select>
  37. <select id="selectConfigDeviceById" parameterType="Long" resultMap="ConfigDeviceResult">
  38. <include refid="selectConfigDeviceVo"/>
  39. where d.id = #{id}
  40. </select>
  41. <insert id="insertConfigDevice" parameterType="ConfigDevice" useGeneratedKeys="true" keyProperty="id">
  42. insert into config_device
  43. <trim prefix="(" suffix=")" suffixOverrides=",">
  44. <if test="name != null and name != ''">name,</if>
  45. <if test="configChannelId != null">config_channel_id,</if>
  46. <if test="ilk != null and ilk != ''">ilk,</if>
  47. <if test="configDeviceId != null">config_device_id,</if>
  48. <if test="remark != null and remark != ''">remark,</if>
  49. </trim>
  50. <trim prefix="values (" suffix=")" suffixOverrides=",">
  51. <if test="name != null and name != ''">#{name},</if>
  52. <if test="configChannelId != null">#{configChannelId},</if>
  53. <if test="ilk != null and ilk != ''">#{ilk},</if>
  54. <if test="configDeviceId != null">#{configDeviceId},</if>
  55. <if test="remark != null and remark != ''">#{remark},</if>
  56. </trim>
  57. </insert>
  58. <update id="updateConfigDevice" parameterType="ConfigDevice">
  59. update config_device
  60. <trim prefix="SET" suffixOverrides=",">
  61. <if test="name != null and name != ''">name = #{name},</if>
  62. <if test="configChannelId != null">config_channel_id = #{configChannelId},</if>
  63. <if test="ilk != null and ilk != ''">ilk = #{ilk},</if>
  64. <if test="configDeviceId != null">config_device_id = #{configDeviceId},</if>
  65. <if test="remark != null and remark != ''">remark = #{remark},</if>
  66. </trim>
  67. where id = #{id}
  68. </update>
  69. <delete id="deleteConfigDeviceById" parameterType="Long">
  70. delete from config_device where id = #{id}
  71. </delete>
  72. <delete id="deleteConfigDeviceByIds" parameterType="String">
  73. delete from config_device where id in
  74. <foreach item="id" collection="array" open="(" separator="," close=")">
  75. #{id}
  76. </foreach>
  77. </delete>
  78. </mapper>