DeviceLogMapper.xml 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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.ruoyi.taiye.mapper.DeviceLogMapper">
  6. <resultMap type="DeviceLog" id="DeviceLogResult">
  7. <result property="deviceLogId" column="device_log_id" />
  8. <result property="deviceId" column="device_id" />
  9. <result property="deviceName" column="device_name" />
  10. <result property="content" column="content" />
  11. <result property="status" column="status" />
  12. <result property="createBy" column="create_by" />
  13. <result property="createTime" column="create_time" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="remark" column="remark" />
  17. </resultMap>
  18. <sql id="selectDeviceLogVo">
  19. select device_log_id, device_id, device_name, content, status, create_by, create_time, update_by, update_time, remark from device_log
  20. </sql>
  21. <select id="selectDeviceLogList" parameterType="DeviceLog" resultMap="DeviceLogResult">
  22. <include refid="selectDeviceLogVo"/>
  23. <where>
  24. <if test="deviceId != null and deviceId != ''"> and device_id = #{deviceId}</if>
  25. <if test="deviceName != null and deviceName != ''"> and device_name like concat('%', #{deviceName}, '%')</if>
  26. </where>
  27. order by create_time desc
  28. </select>
  29. <select id="selectDeviceLogByDeviceLogId" parameterType="Long" resultMap="DeviceLogResult">
  30. <include refid="selectDeviceLogVo"/>
  31. where device_log_id = #{deviceLogId}
  32. </select>
  33. <insert id="insertDeviceLog" parameterType="DeviceLog">
  34. insert into device_log
  35. <trim prefix="(" suffix=")" suffixOverrides=",">
  36. <if test="deviceLogId != null">device_log_id,</if>
  37. <if test="deviceId != null and deviceId != ''">device_id,</if>
  38. <if test="deviceName != null and deviceName != ''">device_name,</if>
  39. <if test="content != null and content != ''">content,</if>
  40. <if test="status != null and status != ''">status,</if>
  41. <if test="createBy != null">create_by,</if>
  42. <if test="createTime != null">create_time,</if>
  43. <if test="updateBy != null">update_by,</if>
  44. <if test="updateTime != null">update_time,</if>
  45. <if test="remark != null">remark,</if>
  46. </trim>
  47. <trim prefix="values (" suffix=")" suffixOverrides=",">
  48. <if test="deviceLogId != null">#{deviceLogId},</if>
  49. <if test="deviceId != null and deviceId != ''">#{deviceId},</if>
  50. <if test="deviceName != null and deviceName != ''">#{deviceName},</if>
  51. <if test="content != null and content != ''">#{content},</if>
  52. <if test="status != null and status != ''">#{status},</if>
  53. <if test="createBy != null">#{createBy},</if>
  54. <if test="createTime != null">#{createTime},</if>
  55. <if test="updateBy != null">#{updateBy},</if>
  56. <if test="updateTime != null">#{updateTime},</if>
  57. <if test="remark != null">#{remark},</if>
  58. </trim>
  59. </insert>
  60. <update id="updateDeviceLog" parameterType="DeviceLog">
  61. update device_log
  62. <trim prefix="SET" suffixOverrides=",">
  63. <if test="deviceId != null and deviceId != ''">device_id = #{deviceId},</if>
  64. <if test="deviceName != null and deviceName != ''">device_name = #{deviceName},</if>
  65. <if test="content != null and content != ''">content = #{content},</if>
  66. <if test="status != null and status != ''">status = #{status},</if>
  67. <if test="createBy != null">create_by = #{createBy},</if>
  68. <if test="createTime != null">create_time = #{createTime},</if>
  69. <if test="updateBy != null">update_by = #{updateBy},</if>
  70. <if test="updateTime != null">update_time = #{updateTime},</if>
  71. <if test="remark != null">remark = #{remark},</if>
  72. </trim>
  73. where device_log_id = #{deviceLogId}
  74. </update>
  75. <delete id="deleteDeviceLogByDeviceLogId" parameterType="Long">
  76. delete from device_log where device_log_id = #{deviceLogId}
  77. </delete>
  78. <delete id="deleteDeviceLogByDeviceLogIds" parameterType="String">
  79. delete from device_log where device_log_id in
  80. <foreach item="deviceLogId" collection="array" open="(" separator="," close=")">
  81. #{deviceLogId}
  82. </foreach>
  83. </delete>
  84. <delete id="cleanUpDataFromAWeekAgo">
  85. delete from device_log where DATE(create_time) &lt;= DATE(DATE_SUB(NOW(),INTERVAL 7 DAY));
  86. </delete>
  87. </mapper>