SysNoticeUserReadMapper.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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.aidex.system.mapper.SysNoticeUserReadMapper">
  4. <sql id="sysNoticeUserReadColumns">
  5. notice_id as "noticeId",
  6. user_id as "userId",
  7. is_read as "isRead",
  8. status as "status",
  9. remark as "remark",
  10. id as "id",
  11. create_by as "createBy",
  12. create_dept as "createDept",
  13. create_time as "createTime",
  14. update_by as "updateBy",
  15. update_time as "updateTime",
  16. update_ip as "updateIp",
  17. version as "version",
  18. del_flag as "delFlag"
  19. </sql>
  20. <sql id="sysNoticeUserReadJoins">
  21. </sql>
  22. <select id="get" resultType="SysNoticeUserRead">
  23. SELECT
  24. <include refid="sysNoticeUserReadColumns"/>
  25. FROM sys_notice_user_read a
  26. <include refid="sysNoticeUserReadJoins"/>
  27. WHERE a.id = #{id}
  28. </select>
  29. <select id="findList" resultType="SysNoticeUserRead">
  30. SELECT
  31. <include refid="sysNoticeUserReadColumns"/>
  32. FROM sys_notice_user_read a
  33. <include refid="sysNoticeUserReadJoins"/>
  34. <where>
  35. a.del_flag = #{DEL_FLAG_NORMAL}
  36. <if test="noticeId != null and noticeId != ''">
  37. AND a.notice_id = #{noticeId}
  38. </if>
  39. <if test="userId != null and userId != ''">
  40. AND a.user_id = #{userId}
  41. </if>
  42. <if test="isRead != null and isRead != ''">
  43. AND a.is_read = #{isRead}
  44. </if>
  45. <if test="status != null and status != ''">
  46. AND a.status = #{status}
  47. </if>
  48. </where>
  49. <choose>
  50. <when test="page !=null and page.orderByColumn != null and page.orderByColumn != ''">
  51. ORDER BY ${page.orderByColumn}
  52. </when>
  53. <otherwise>
  54. ORDER BY a.create_time
  55. </otherwise>
  56. </choose>
  57. </select>
  58. <select id="findListWithUnique" resultType="SysNoticeUserRead">
  59. SELECT
  60. a.id
  61. FROM sys_notice_user_read a
  62. <include refid="sysNoticeUserReadJoins"/>
  63. <where>
  64. a.del_flag = #{DEL_FLAG_NORMAL}
  65. <if test="notEqualId != null and notEqualId != ''">
  66. AND id != #{notEqualId}
  67. </if>
  68. </where>
  69. </select>
  70. <insert id="insert">
  71. INSERT INTO sys_notice_user_read(
  72. notice_id,
  73. user_id,
  74. is_read,
  75. status,
  76. remark,
  77. id,
  78. create_by,
  79. create_dept,
  80. create_time,
  81. update_by,
  82. update_time,
  83. update_ip,
  84. version,
  85. del_flag
  86. ) VALUES (
  87. #{noticeId},
  88. #{userId},
  89. #{isRead},
  90. #{status},
  91. #{remark},
  92. #{id},
  93. #{createBy},
  94. #{createDept},
  95. #{createTime},
  96. #{updateBy},
  97. #{updateTime},
  98. #{updateIp},
  99. #{version},
  100. #{delFlag}
  101. )
  102. </insert>
  103. <update id="update">
  104. UPDATE sys_notice_user_read SET
  105. notice_id = #{noticeId},
  106. user_id = #{userId},
  107. is_read = #{isRead},
  108. status = #{status},
  109. remark = #{remark},
  110. update_by = #{updateBy},
  111. update_time = #{updateTime},
  112. update_ip = #{updateIp},
  113. version = version + 1
  114. WHERE id = #{id} and version = #{version}
  115. </update>
  116. <update id="delete">
  117. UPDATE sys_notice_user_read SET
  118. del_flag = #{DEL_FLAG_DELETE}
  119. WHERE id = #{id}
  120. </update>
  121. <delete id="deleteSysNoticeUserReadByIds">
  122. UPDATE sys_notice_user_read SET
  123. del_flag = '1'
  124. WHERE id in
  125. <foreach item="id" collection="array" open="(" separator="," close=")">
  126. #{id}
  127. </foreach>
  128. </delete>
  129. </mapper>