BizMissionDocMapper.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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="cn.tr.module.smart.common.repository.BizMissionDocRepository">
  6. <resultMap id="MissionDoc" type="cn.tr.module.smart.common.po.BizMissionDocPO">
  7. <result property="id" column="id"/>
  8. <result property="type" column="type"/>
  9. <result property="title" column="title"/>
  10. <result property="source" column="source"/>
  11. <result property="image" column="image"/>
  12. <result property="imageId" column="image_id"/>
  13. <result property="content" column="content"/>
  14. <result property="phase" column="phase"/>
  15. <result property="intervalMinDay" column="interval_min_day"/>
  16. <result property="intervalMaxDay" column="interval_max_day"/>
  17. <result property="tenantId" column="tenant_id"/>
  18. <result property="createTime" column="create_time"/>
  19. <result property="createBy" column="create_by"/>
  20. <result property="updateTime" column="update_time"/>
  21. <result property="updateBy" column="update_by"/>
  22. <result property="version" column="version"/>
  23. <result property="md5" column="md5"/>
  24. <result property="contentMd5" column="content_md5"/>
  25. <result property="deleted" column="deleted"/>
  26. <result property="squareDocId" column="square_doc_id"/>
  27. </resultMap>
  28. <sql id="baseColumn">
  29. id, type, title, source, image,image_id, content, phase, interval_min_day, interval_max_day, tenant_id, create_time, create_by, update_time, update_by, version, md5, content_md5, deleted, square_doc_id
  30. </sql>
  31. <select id="selectBizMissionDocById" resultMap="MissionDoc">
  32. SELECT
  33. <include refid="baseColumn"/>
  34. FROM biz_mission_doc
  35. where id = #{id ,jdbcType=VARCHAR} and deleted = 0
  36. </select>
  37. <select id="selectOneBySquareId" resultMap="MissionDoc">
  38. SELECT
  39. <include refid="baseColumn"/>
  40. FROM biz_mission_doc
  41. where
  42. square_doc_id = #{squareId ,jdbcType=VARCHAR}
  43. and deleted = 0
  44. order by create_time desc
  45. limit 1
  46. </select>
  47. <update id="updateBizMissionDocById">
  48. UPDATE biz_mission_doc
  49. <set>
  50. <if test="type != null">
  51. type = #{type ,jdbcType=VARCHAR},
  52. </if>
  53. <if test="title != null">
  54. title = #{title ,jdbcType=VARCHAR},
  55. </if>
  56. <if test="source != null">
  57. source = #{source ,jdbcType=VARCHAR},
  58. </if>
  59. <if test="image != null">
  60. image = #{image ,jdbcType=VARCHAR},
  61. </if>
  62. <if test="imageId != null">
  63. image_id = #{imageId ,jdbcType=VARCHAR},
  64. </if>
  65. <if test="content != null">
  66. content = #{content ,jdbcType=VARCHAR},
  67. </if>
  68. <if test="phase != null">
  69. phase = #{phase ,jdbcType=VARCHAR},
  70. </if>
  71. <if test="intervalMinDay != null">
  72. interval_min_day = #{intervalMinDay ,jdbcType=BIGINT},
  73. </if>
  74. <if test="intervalMaxDay != null">
  75. interval_max_day = #{intervalMaxDay ,jdbcType=BIGINT},
  76. </if>
  77. <if test="tenantId != null">
  78. tenant_id = #{tenantId ,jdbcType=VARCHAR},
  79. </if>
  80. <if test="updateTime != null">
  81. update_time = #{updateTime ,jdbcType=TIMESTAMP},
  82. </if>
  83. <if test="updateBy != null">
  84. update_by = #{updateBy ,jdbcType=VARCHAR},
  85. </if>
  86. <if test="version != null">
  87. version = #{version ,jdbcType=BIGINT},
  88. </if>
  89. <if test="md5 != null">
  90. md5 = #{md5 ,jdbcType=VARCHAR},
  91. </if>
  92. <if test="contentMd5 != null">
  93. content_md5 = #{contentMd5 ,jdbcType=VARCHAR},
  94. </if>
  95. <if test="deleted != null">
  96. deleted = #{deleted ,jdbcType=BIT},
  97. </if>
  98. <if test="squareDocId != null">
  99. square_doc_id = #{squareDocId ,jdbcType=VARCHAR},
  100. </if>
  101. </set>
  102. where id = #{id ,jdbcType=VARCHAR}
  103. </update>
  104. <update id="updateDeletedById">
  105. UPDATE biz_mission_doc
  106. SET deleted = 1
  107. WHERE id IN
  108. <foreach collection="ids" item="id" open="(" separator="," close=")">
  109. #{id}
  110. </foreach>
  111. </update>
  112. <select id="selectBizDeptAndDocByDeptIdList" resultType="cn.tr.module.smart.wx.controller.vo.BizDeptAndDocVO">
  113. select bdd.dept_id as deptId,
  114. bd.name as deptName,
  115. bmd.id as docId,
  116. bmd.type as type,
  117. bmd.title as title,
  118. bmd.source as source,
  119. bmd.image as image,
  120. bmd.content as content,
  121. bmd.image_id as imageId,
  122. bmd.phase as phase,
  123. bmd.interval_min_day as intervalMinDay,
  124. bmd.interval_max_day as intervalMaxDay,
  125. bmd.create_time as create_time,
  126. bmd.create_by as create_by,
  127. bmd.update_time as update_time,
  128. bmd.update_by as update_by,
  129. bmd.is_share as isShare,
  130. bmd.square_doc_id as squareDocId
  131. from biz_doc_dept bdd
  132. join biz_mission_doc bmd on
  133. bdd.doc_id = bmd.id
  134. join biz_dept bd on
  135. bd.id = bdd.dept_id
  136. <where>
  137. and deleted = 0
  138. <if test="query.deptId != null and query.deptId != ''">
  139. and bdd.dept_id = #{query.deptId ,jdbcType=VARCHAR}
  140. </if>
  141. <if test="query.time != null">
  142. and #{query.time} BETWEEN bmd.interval_min_day AND bmd.interval_max_day
  143. </if>
  144. <if test="query.phase != null and query.phase != ''">
  145. and bmd.phase = #{query.phase,jdbcType=VARCHAR}
  146. </if>
  147. <if test="query.title != null and query.title != ''">
  148. and bmd.title like concat('%',#{query.title,jdbcType=VARCHAR},'%')
  149. </if>
  150. </where>
  151. </select>
  152. <select id="queryAllUnlink" resultType="cn.tr.module.smart.web.vo.BizDeptUnlinkDocVO">
  153. SELECT
  154. bmd.ID AS docId,
  155. bmd.TYPE,
  156. bmd.title,
  157. bmd.SOURCE,
  158. bmd.CONTENT,
  159. bmd.phase,
  160. bmd.create_time,
  161. bmd.update_time,
  162. bmd.create_by,
  163. bmd.update_by
  164. FROM
  165. biz_mission_doc bmd
  166. <where>
  167. and bmd.deleted = 0
  168. and bmd.title is not null
  169. <if test="query.condition != null and query.condition != ''">
  170. and bmd.title like concat('%',#{query.condition,jdbcType=VARCHAR},'%')
  171. </if>
  172. <if test="!query.isLink">
  173. <if test="query.deptId != null and query.deptId != ''">
  174. AND NOT EXISTS ( SELECT 1 FROM biz_doc_dept bdd WHERE bdd.doc_id = bmd.ID AND bdd.dept_id = #{query.deptId})
  175. </if>
  176. </if>
  177. <if test="query.isLink">
  178. <if test="query.deptId != null and query.deptId != ''">
  179. AND EXISTS ( SELECT 1 FROM biz_doc_dept bdd WHERE bdd.doc_id = bmd.ID AND bdd.dept_id = #{query.deptId} )
  180. </if>
  181. </if>
  182. </where>
  183. </select>
  184. </mapper>