ConfigDeviceMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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.ufo.project.config.mapper.ConfigDeviceMapper">
  6. <resultMap type="ConfigDevice" id="ConfigDeviceResult">
  7. <result property="id" column="id" />
  8. <result property="name" column="name" />
  9. <result property="tp" column="tp" />
  10. <result property="brand" column="brand" />
  11. <result property="model" column="model" />
  12. <result property="serialNumber" column="serial_number" />
  13. <result property="status" column="status" />
  14. <result property="installDate" column="install_date" />
  15. <result property="configChannelId" column="config_channel_id" />
  16. <result property="configStationId" column="config_station_id" />
  17. <result property="configDeviceId" column="config_device_id" />
  18. <result property="remark" column="remark" />
  19. </resultMap>
  20. <sql id="selectConfigDeviceVo">
  21. select id, name, tp, brand, model, serial_number, status, install_date, config_channel_id, config_station_id, config_device_id, remark from config_device
  22. </sql>
  23. <select id="selectConfigDeviceList" parameterType="ConfigDevice" resultMap="ConfigDeviceResult">
  24. <include refid="selectConfigDeviceVo"/>
  25. <where>
  26. <if test="configStationId != null"> and config_station_id = #{configStationId}</if>
  27. <if test="configChannelId != null"> and config_channel_id = #{configChannelId}</if>
  28. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  29. <if test="configDeviceId != null"> and config_device_id = #{configDeviceId}</if>
  30. </where>
  31. order by id desc
  32. </select>
  33. <select id="selectConfigDeviceById" parameterType="Long" resultMap="ConfigDeviceResult">
  34. <include refid="selectConfigDeviceVo"/>
  35. where id = #{id}
  36. </select>
  37. <select id="selectConfigDeviceByIds" parameterType="Long" resultMap="ConfigDeviceResult">
  38. <include refid="selectConfigDeviceVo"/>
  39. where id in
  40. <foreach item="id" collection="array" open="(" separator="," close=")">
  41. #{id}
  42. </foreach>
  43. </select>
  44. <select id="selectConfigDeviceByChannelIds" parameterType="Long" resultMap="ConfigDeviceResult">
  45. <include refid="selectConfigDeviceVo"/>
  46. where config_channel_id in
  47. <foreach item="channelId" collection="array" open="(" separator="," close=")">
  48. #{channelId}
  49. </foreach>
  50. order by id asc
  51. </select>
  52. <insert id="insertConfigDevice" parameterType="ConfigDevice" useGeneratedKeys="true" keyProperty="id">
  53. insert into config_device
  54. <trim prefix="(" suffix=")" suffixOverrides=",">
  55. <if test="name != null and name != ''">name,</if>
  56. <if test="tp != null and tp != ''">tp,</if>
  57. <if test="brand != null and brand != ''">brand,</if>
  58. <if test="model != null and model != ''">model,</if>
  59. <if test="serialNumber != null and serialNumber != ''">serial_number,</if>
  60. <if test="status != null and status != ''">status,</if>
  61. <if test="installDate != null">install_date,</if>
  62. <if test="configChannelId != null">config_channel_id,</if>
  63. <if test="configStationId != null">config_station_id,</if>
  64. <if test="configDeviceId != null">config_device_id,</if>
  65. <if test="remark != null and remark != ''">remark,</if>
  66. </trim>
  67. <trim prefix="values (" suffix=")" suffixOverrides=",">
  68. <if test="name != null and name != ''">#{name},</if>
  69. <if test="tp != null and tp != ''">#{tp},</if>
  70. <if test="brand != null and brand != ''">#{brand},</if>
  71. <if test="model != null and model != ''">#{model},</if>
  72. <if test="serialNumber != null and serialNumber != ''">#{serialNumber},</if>
  73. <if test="status != null and status != ''">#{status},</if>
  74. <if test="installDate != null">#{installDate},</if>
  75. <if test="configChannelId != null">#{configChannelId},</if>
  76. <if test="configStationId != null">#{configStationId},</if>
  77. <if test="configDeviceId != null">#{configDeviceId},</if>
  78. <if test="remark != null and remark != ''">#{remark},</if>
  79. </trim>
  80. </insert>
  81. <update id="updateConfigDevice" parameterType="ConfigDevice">
  82. update config_device
  83. <trim prefix="SET" suffixOverrides=",">
  84. <if test="name != null and name != ''">name = #{name},</if>
  85. <if test="tp != null and tp != ''">tp = #{tp},</if>
  86. <if test="brand != null and brand != ''">brand = #{brand},</if>
  87. <if test="model != null and model != ''">model = #{model},</if>
  88. <if test="serialNumber != null and serialNumber != ''">serial_number = #{serialNumber},</if>
  89. <if test="status != null and status != ''">status = #{status},</if>
  90. <if test="installDate != null">install_date = #{installDate},</if>
  91. <if test="configChannelId != null">config_channel_id = #{configChannelId},</if>
  92. <if test="configStationId != null">config_station_id = #{configStationId},</if>
  93. <if test="configDeviceId != null">config_device_id = #{configDeviceId},</if>
  94. <if test="remark != null and remark != ''">remark = #{remark},</if>
  95. update_time = CURRENT_TIMESTAMP,
  96. </trim>
  97. where id = #{id}
  98. </update>
  99. <delete id="deleteConfigDeviceById" parameterType="Long">
  100. delete from config_device where id = #{id}
  101. </delete>
  102. <delete id="deleteConfigDeviceByIds" parameterType="Long">
  103. delete from config_device where id in
  104. <foreach item="id" collection="array" open="(" separator="," close=")">
  105. #{id}
  106. </foreach>
  107. </delete>
  108. </mapper>