SnapshotMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  4. <mapper namespace="com.zhyc.xps.aqpt.mapper.SnapshotMapper">
  5. <resultMap id="ExtResultMap" type="com.zhyc.xps.aqpt.dto.SnapshotDto" >
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" />
  7. <result column="snapshot_id" property="snapshotId" jdbcType="BIGINT" />
  8. <result column="snapshot_title" property="snapshotTitle" jdbcType="VARCHAR" />
  9. <result column="snapshot_remark" property="snapshotRemark" jdbcType="VARCHAR" />
  10. <result column="status" property="status" jdbcType="BIGINT" />
  11. <result column="submit_group_id" property="submitGroupId" jdbcType="BIGINT" />
  12. <result column="submit_account_id" property="submitAccountId" jdbcType="BIGINT" />
  13. <result column="submit_time" property="submitTime" jdbcType="TIMESTAMP"/>
  14. <result column="submit_group_name" property="submitGroupName" jdbcType="VARCHAR"/>
  15. <result column="submit_account_name" property="submitAccountName" jdbcType="VARCHAR"/>
  16. <result column="handle_group_id" property="handleGroupId" jdbcType="BIGINT" />
  17. <result column="handle_account_id" property="handleAccountId" jdbcType="BIGINT" />
  18. <result column="handle_time" property="handleTime" jdbcType="TIMESTAMP"/>
  19. <result column="handle_group_name" property="handleGroupName" jdbcType="VARCHAR" />
  20. <result column="handle_account_name" property="handleAccountName" jdbcType="VARCHAR" />
  21. </resultMap>
  22. <sql id="Ext_Column_List">
  23. A.snapshot_id,
  24. A.snapshot_title,
  25. A.snapshot_remark,
  26. A.status,
  27. A.submit_group_id,
  28. B.group_name AS submit_group_name,
  29. A.submit_account_id,
  30. C.account_name AS submit_account_name,
  31. A.submit_time,
  32. A.handle_group_id,
  33. D.group_name AS handle_group_name,
  34. A.handle_account_id,
  35. E.account_name AS handle_account_name,
  36. A.handle_time,
  37. N.file_url,
  38. A.created_by,
  39. A.created_at,
  40. A.updated_by,
  41. A.updated_at
  42. </sql>
  43. <!--根据ID获取-->
  44. <select id="getById" resultMap="ExtResultMap">
  45. SELECT
  46. <include refid="Ext_Column_List"/>
  47. FROM snapshot AS A
  48. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.submit_group_id = B.group_id)
  49. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.submit_account_id = C.account_id)
  50. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.submit_group_id = D.group_id)
  51. LEFT JOIN account AS E ON (A.oc_id = E.oc_id AND A.submit_account_id = E.account_id)
  52. LEFT JOIN snapshot_attach AS M ON (A.oc_id = M.oc_id AND A.snapshot_id = M.snapshot_id AND A.danger_id = M.file_id)
  53. LEFT JOIN doc_file AS N ON (M.oc_id = N.oc_id AND M.file_id = N.file_id )
  54. WHERE 1 = 1
  55. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  56. AND A.snapshot_id = #{snapshotId, jdbcType=BIGINT}
  57. </select>
  58. <!--分页查询-->
  59. <select id="getByPage" parameterType="java.util.Map" resultMap="ExtResultMap">
  60. SELECT
  61. <include refid="Ext_Column_List"/>
  62. FROM snapshot AS A
  63. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.submit_group_id = B.group_id)
  64. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.submit_account_id = C.account_id)
  65. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.submit_group_id = D.group_id)
  66. LEFT JOIN account AS E ON (A.oc_id = E.oc_id AND A.submit_account_id = E.account_id)
  67. LEFT JOIN snapshot_attach AS M ON (A.oc_id = M.oc_id AND A.snapshot_id = M.snapshot_id AND A.danger_id = M.file_id)
  68. LEFT JOIN doc_file AS N ON (M.oc_id = N.oc_id AND M.file_id = N.file_id )
  69. WHERE 1 = 1 AND A.deleted_flag = 0
  70. <if test="ocId != null">
  71. AND A.oc_id = #{ocId}
  72. </if>
  73. <if test="keyword != null and keyword != ''">
  74. AND (A.snapshot_title LIKE "%"#{keyword}"%" OR
  75. C.account_name LIKE "%"#{keyword}"%" OR
  76. E.account_name LIKE "%"#{keyword}"%" )
  77. </if>
  78. <if test="status != null">
  79. AND A.status = #{status}
  80. </if>
  81. ORDER BY A.snapshot_id ASC
  82. </select>
  83. <!--获取列表-->
  84. <select id="getByList" parameterType="java.util.Map" resultMap="ExtResultMap" >
  85. SELECT
  86. <include refid="Ext_Column_List"/>
  87. FROM snapshot AS A
  88. LEFT JOIN s_group AS B ON (A.oc_id = B.oc_id AND A.submit_group_id = B.group_id)
  89. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.submit_account_id = C.account_id)
  90. LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.submit_group_id = D.group_id)
  91. LEFT JOIN account AS E ON (A.oc_id = E.oc_id AND A.submit_account_id = E.account_id)
  92. LEFT JOIN snapshot_attach AS M ON (A.oc_id = M.oc_id AND A.snapshot_id = M.snapshot_id AND A.danger_id = M.file_id)
  93. LEFT JOIN doc_file AS N ON (M.oc_id = N.oc_id AND M.file_id = N.file_id )
  94. WHERE 1 = 1 AND A.deleted_flag = 0
  95. <if test="ocId != null">
  96. AND A.oc_id = #{ocId}
  97. </if>
  98. <if test="keywords != null and keywords != ''">
  99. AND (A.snapshot_title LIKE "%"#{keywords}"%" OR
  100. C.account_name LIKE "%"#{keywords}"%" OR
  101. E.account_name LIKE "%"#{keywords}"%" )
  102. </if>
  103. <if test="status != null">
  104. AND A.status = #{status}
  105. </if>
  106. ORDER BY A.snapshot_id ASC
  107. </select>
  108. <!--新增Insert-->
  109. <insert id="create" useGeneratedKeys="true" keyProperty="snapshotId" parameterType="com.zhyc.xps.aqpt.entity.Snapshot">
  110. INSERT INTO snapshot
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. <if test="snapshotId != null">
  113. snapshot_id,
  114. </if>
  115. <if test="snapshotTitle != null and snapshotTile!=''">
  116. snapshot_title,
  117. </if>
  118. <if test="snapshotRemark != null and snapshotRemark!=''">
  119. snapshot_remark,
  120. </if>
  121. <if test="submitGroupId != null">
  122. submit_group_id,
  123. </if>
  124. <if test="status != null">
  125. status,
  126. </if>
  127. <if test="submitAccountId != null">
  128. submit_account_id,
  129. </if>
  130. <if test="submitTime != null">
  131. submit_time,
  132. </if>
  133. <if test="handleGroupId != null">
  134. handle_group_id,
  135. </if>
  136. <if test="handleAccountId != null">
  137. handle_account_id,
  138. </if>
  139. <if test="submitTime != null">
  140. handle_time,
  141. </if>
  142. <if test="createdBy != null">
  143. created_by,
  144. </if>
  145. <if test="createdAt != null">
  146. created_at,
  147. </if>
  148. </trim>
  149. <trim prefix="values (" suffix=")" suffixOverrides=",">
  150. <if test="snapshotId != null">
  151. #{snapshotId,jdbcType=BIGINT},
  152. </if>
  153. <if test="snapshotTitle!= null and snapshotTitle != ''">
  154. #{snapshotTitle,jdbcType=VARCHAR},
  155. </if>
  156. <if test="snapshotRemark != null and snapshotRemark != ''">
  157. #{snapshotRemark,jdbcType=VARCHAR},
  158. </if>
  159. <if test="status != null">
  160. #{status ,jdbcType=BIGINT},
  161. </if>
  162. <if test="submitGroupId != null">
  163. #{submitGroupId,jdbcType=BIGINT},
  164. </if>
  165. <if test="submitAccountId != null">
  166. #{submitAccountId,jdbcType=BIGINT},
  167. </if>
  168. <if test="submitTime != null">
  169. #{submitTime ,jdbcType=TIMESTAMP},
  170. </if>
  171. <if test="handleGroupId != null">
  172. #{handleGroupId ,jdbcType=BIGINT},
  173. </if>
  174. <if test="handleAccountId != null">
  175. #{handleAccountId ,jdbcType=BIGINT},
  176. </if>
  177. <if test="handleTime != null">
  178. #{handleTime ,jdbcType=TIMESTAMP},
  179. </if>
  180. <if test="createdBy != null">
  181. #{createdBy,jdbcType=BIGINT},
  182. </if>
  183. <if test="createdAt != null">
  184. #{createdAt,jdbcType=DATE},
  185. </if>
  186. </trim>
  187. </insert>
  188. <!--Update更新-->
  189. <update id="update" parameterType="com.zhyc.xps.aqpt.entity.Snapshot">
  190. UPDATE snapshot
  191. <trim suffixOverrides=",">
  192. <set>
  193. <if test="snapshotTitle!= null and snapshotTitle != ''">
  194. snapshot_title = #{snapshotTitle,jdbcType=VARCHAR},
  195. </if>
  196. <if test="snapshotRemark != null and snapshotRemark != ''">
  197. snapshot_remark = #{snapshotRemark,jdbcType=VARCHAR},
  198. </if>
  199. <if test="status != null">
  200. status = #{status ,jdbcType=BIGINT},
  201. </if>
  202. <if test="handleGroupId != null">
  203. handle_group_id = #{handleGroupId,jdbcType=BIGINT},
  204. </if>
  205. <if test="handleAccountId != null">
  206. handle_account_id = #{handleAccountId,jdbcType=BIGINT},
  207. </if>
  208. <if test="handleTime != null">
  209. handle_time = #{handleTime ,jdbcType=TIMESTAMP},
  210. </if>
  211. <if test="updatedBy != null">
  212. updated_by = #{updatedBy,jdbcType=BIGINT},
  213. </if>
  214. <if test="updatedAt != null">
  215. updated_at = #{updatedAt,jdbcType=DATE},
  216. </if>
  217. </set>
  218. </trim>
  219. WHERE snapshot_id = #{snapshotId, jdbcType=BIGINT}
  220. </update>
  221. <!--删除 -->
  222. <update id="delete" parameterType="java.util.Map">
  223. UPDATE snapshot
  224. <trim suffixOverrides=",">
  225. <set>
  226. <if test="deletedBy != null">
  227. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  228. </if>
  229. <if test="deletedAt != null">
  230. deleted_at = #{deletedAt ,jdbcType=DATE},
  231. </if>
  232. <if test="deletedFlag != null">
  233. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  234. </if>
  235. </set>
  236. </trim>
  237. WHERE snapshot_id = #{snapshotId, jdbcType=BIGINT}
  238. </update>
  239. </mapper>