1
0

SysNoticeUserDao.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.kmall.admin.dao.SysNoticeUserDao">
  4. <resultMap type="com.kmall.admin.entity.SysNoticeUserEntity" id="sysNoticeUserMap">
  5. <result property="id" column="id"/>
  6. <result property="userId" column="user_id"/>
  7. <result property="noticeId" column="notice_id"/>
  8. <result property="status" column="status"/>
  9. <result property="remark" column="remark"/>
  10. </resultMap>
  11. <select id="queryObject" resultType="com.kmall.admin.entity.SysNoticeUserEntity">
  12. select
  13. `id`,
  14. `user_id`,
  15. `notice_id`,
  16. `status`,
  17. `remark`
  18. from sys_notice_user
  19. where id = #{id}
  20. </select>
  21. <select id="queryList" resultType="com.kmall.admin.entity.SysNoticeUserEntity">
  22. select
  23. sys_notice_user.id,
  24. sys_notice_user.user_id,
  25. sys_notice_user.notice_id,
  26. sys_notice_user.status,
  27. sys_notice_user.remark,
  28. sys_user.username user_name,
  29. sys_notice.context notice_content
  30. from sys_notice_user
  31. LEFT JOIN sys_user on sys_notice_user.user_id = sys_user.user_id
  32. LEFT JOIN sys_notice ON sys_notice_user.notice_id = sys_notice.id
  33. WHERE 1=1
  34. <if test="username != null and username.trim() != ''">
  35. AND sys_user.username LIKE concat('%',#{username},'%')
  36. </if>
  37. <choose>
  38. <when test="sidx != null and sidx.trim() != ''">
  39. order by ${sidx} ${order}
  40. </when>
  41. <otherwise>
  42. order by id desc
  43. </otherwise>
  44. </choose>
  45. <if test="offset != null and limit != null">
  46. limit #{offset}, #{limit}
  47. </if>
  48. </select>
  49. <select id="queryTotal" resultType="int">
  50. select count(*) from sys_notice_user
  51. LEFT JOIN sys_user on sys_notice_user.user_id = sys_user.user_id
  52. WHERE 1=1
  53. <if test="username != null and username.trim() != ''">
  54. AND sys_user.username LIKE concat('%',#{username},'%')
  55. </if>
  56. </select>
  57. <insert id="save" parameterType="com.kmall.admin.entity.SysNoticeUserEntity">
  58. insert into sys_notice_user(
  59. `id`,
  60. `user_id`,
  61. `notice_id`,
  62. `status`,
  63. `remark`)
  64. values(
  65. #{id},
  66. #{userId},
  67. #{noticeId},
  68. #{status},
  69. #{remark})
  70. </insert>
  71. <update id="update" parameterType="com.kmall.admin.entity.SysNoticeUserEntity">
  72. update sys_notice_user
  73. <set>
  74. <if test="userId != null">`user_id` = #{userId}, </if>
  75. <if test="noticeId != null">`notice_id` = #{noticeId}, </if>
  76. <if test="status != null">`status` = #{status}, </if>
  77. <if test="remark != null">`remark` = #{remark}</if>
  78. </set>
  79. where id = #{id}
  80. </update>
  81. <delete id="delete">
  82. delete from sys_notice_user where id = #{value}
  83. </delete>
  84. <delete id="deleteBatch">
  85. delete from sys_notice_user where id in
  86. <foreach item="id" collection="array" open="(" separator="," close=")">
  87. #{id}
  88. </foreach>
  89. </delete>
  90. </mapper>