ConfigStationDeviceMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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.ConfigStationDeviceMapper">
  6. <resultMap type="ConfigStationDevice" id="ConfigStationDeviceResult">
  7. <result property="id" column="id" />
  8. <result property="stationId" column="station_id" />
  9. <result property="stationName" column="station_name" />
  10. <result property="deviceName" column="device_name" />
  11. <result property="deviceType" column="device_type" />
  12. <result property="brand" column="brand" />
  13. <result property="model" column="model" />
  14. <result property="serialNumber" column="serial_number" />
  15. <result property="status" column="status" />
  16. <result property="installDate" column="install_date" />
  17. <result property="createBy" column="create_by" />
  18. <result property="createTime" column="create_time" />
  19. <result property="updateBy" column="update_by" />
  20. <result property="updateTime" column="update_time" />
  21. <result property="remark" column="remark" />
  22. </resultMap>
  23. <sql id="selectConfigStationDeviceVo">
  24. select t.id, t.station_id, s.station_name, t.device_name, t.device_type, t.brand, t.model, t.serial_number, t.status, t.install_date, t.create_by, t.create_time, t.update_by, t.update_time, t.remark from config_station_device t left join config_station s on s.id = t.station_id
  25. </sql>
  26. <select id="selectConfigStationDeviceList" parameterType="ConfigStationDevice" resultMap="ConfigStationDeviceResult">
  27. <include refid="selectConfigStationDeviceVo"/>
  28. <where>
  29. <if test="stationId != null"> and t.station_id = #{stationId}</if>
  30. <if test="deviceName != null and deviceName != ''"> and t.device_name like concat('%', #{deviceName}, '%')</if>
  31. <if test="deviceType != null"> and t.device_type = #{deviceType}</if>
  32. <if test="brand != null and brand != ''"> and t.brand like concat('%', #{brand}, '%')</if>
  33. <if test="model != null and model != ''"> and t.model like concat('%', #{model}, '%')</if>
  34. <if test="serialNumber != null and serialNumber != ''"> and t.serial_number like concat('%', #{serialNumber}, '%')</if>
  35. <if test="status != null"> and t.status = #{status}</if>
  36. </where>
  37. order by t.id desc
  38. </select>
  39. <select id="selectConfigStationDeviceById" parameterType="Long" resultMap="ConfigStationDeviceResult">
  40. <include refid="selectConfigStationDeviceVo"/>
  41. where t.id = #{id}
  42. </select>
  43. <insert id="insertConfigStationDevice" parameterType="ConfigStationDevice" useGeneratedKeys="true" keyProperty="id">
  44. insert into config_station_device (station_id, device_name, device_type, brand, model, serial_number, status, install_date, create_by, create_time, update_by, update_time, remark)
  45. values (#{stationId}, #{deviceName}, #{deviceType}, #{brand}, #{model}, #{serialNumber}, #{status}, #{installDate}, #{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})
  46. </insert>
  47. <update id="updateConfigStationDevice" parameterType="ConfigStationDevice">
  48. update config_station_device
  49. <trim prefix="SET" suffixOverrides=",">
  50. <if test="stationId != null">station_id = #{stationId},</if>
  51. <if test="deviceName != null">device_name = #{deviceName},</if>
  52. <if test="deviceType != null">device_type = #{deviceType},</if>
  53. <if test="brand != null">brand = #{brand},</if>
  54. <if test="model != null">model = #{model},</if>
  55. <if test="serialNumber != null">serial_number = #{serialNumber},</if>
  56. <if test="status != null">status = #{status},</if>
  57. <if test="installDate != null">install_date = #{installDate},</if>
  58. <if test="updateBy != null">update_by = #{updateBy},</if>
  59. <if test="updateTime != null">update_time = #{updateTime},</if>
  60. <if test="remark != null">remark = #{remark},</if>
  61. </trim>
  62. where id = #{id}
  63. </update>
  64. <delete id="deleteConfigStationDeviceById" parameterType="Long">
  65. delete from config_station_device where id = #{id}
  66. </delete>
  67. <delete id="deleteConfigStationDeviceByIds" parameterType="Long">
  68. delete from config_station_device where id in
  69. <foreach item="id" collection="array" open="(" separator="," close=")">
  70. #{id}
  71. </foreach>
  72. </delete>
  73. </mapper>