NoticeMapper.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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="org.springblade.modules.desk.mapper.NoticeMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="noticeResultMap" type="org.springblade.modules.desk.entity.Notice">
  6. <result column="id" property="id"/>
  7. <result column="create_user" property="createUser"/>
  8. <result column="create_time" property="createTime"/>
  9. <result column="update_user" property="updateUser"/>
  10. <result column="update_time" property="updateTime"/>
  11. <result column="status" property="status"/>
  12. <result column="is_deleted" property="isDeleted"/>
  13. <result column="release_time" property="releaseTime"/>
  14. <result column="title" property="title"/>
  15. <result column="content" property="content"/>
  16. <result column="type" property="type"/>
  17. <result column="dept_id" property="deptId"/>
  18. <result column="role_id" property="roleId"/>
  19. <result column="target_ids" property="targetIds"/>
  20. <result column="read_ids" property="readIds"/>
  21. <result column="business_type" property="businessType"/>
  22. </resultMap>
  23. <!-- 通用查询映射结果 -->
  24. <resultMap id="noticeVOResultMap" type="org.springblade.modules.desk.vo.NoticeVO">
  25. <result column="id" property="id"/>
  26. <result column="create_user" property="createUser"/>
  27. <result column="create_time" property="createTime"/>
  28. <result column="update_user" property="updateUser"/>
  29. <result column="update_time" property="updateTime"/>
  30. <result column="status" property="status"/>
  31. <result column="is_deleted" property="isDeleted"/>
  32. <result column="release_time" property="releaseTime"/>
  33. <result column="title" property="title"/>
  34. <result column="content" property="content"/>
  35. </resultMap>
  36. <select id="topList" resultMap="noticeResultMap">
  37. select * from blade_notice limit #{number}
  38. </select>
  39. <select id="selectMyNoticePage" resultMap="noticeVOResultMap">
  40. SELECT
  41. n.*,
  42. d.dict_value AS categoryName
  43. FROM
  44. blade_notice n
  45. LEFT JOIN ( SELECT * FROM blade_dict WHERE CODE = 'notice' ) d ON n.category = d.dict_key
  46. WHERE
  47. n.is_deleted = 0 and n.tenant_id = #{notice.tenantId}
  48. <if test="notice.currentUserId!=null">
  49. AND n.target_ids like '%${notice.currentUserId}%'
  50. </if>
  51. <if test="notice.title!=null">
  52. and n.title like concat(concat('%', #{notice.title}), '%')
  53. </if>
  54. <if test="notice.category!=null">
  55. and n.category = #{notice.category}
  56. </if>
  57. <if test="notice.hadRead!=null">
  58. <if test="notice.hadRead==0">
  59. and ( n.read_ids not like '%${notice.currentUserId}%' or n.read_ids is null )
  60. </if>
  61. <if test="notice.hadRead==1">
  62. and n.read_ids like '%${notice.currentUserId}%'
  63. </if>
  64. </if>
  65. <if test="notice.id!=null">
  66. and n.id = #{notice.id}
  67. </if>
  68. ORDER BY n.create_time DESC
  69. </select>
  70. <select id="selectNoticePage" resultMap="noticeVOResultMap">
  71. select n.* from blade_notice n where n.is_deleted = 0 and n.create_user = #{notice.currentUserId}
  72. <if test="notice.title!=null">
  73. and n.title like concat(concat('%', #{notice.title}), '%')
  74. </if>
  75. <if test="notice.category!=null">
  76. and n.category = #{notice.category}
  77. </if>
  78. ORDER BY n.create_time DESC
  79. </select>
  80. </mapper>