ChecklistMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  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.common.mapper.ChecklistMapper">
  5. <resultMap id="ChecklistDtoResultMap" type="com.zhyc.xps.common.dto.ChecklistDto">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--单位ID-->
  7. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" /><!--清单ID-->
  8. <result column="checklist_cat_id" property="checklistCatId" jdbcType="BIGINT" />
  9. <result column="checklist_cat_title" property="checklistCatTitle" jdbcType="VARCHAR" />
  10. <result column="checklist_type_id" property="checklistTypeId" jdbcType="BIGINT" />
  11. <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
  12. <result column="checklist_desc" property="checklistDesc" jdbcType="VARCHAR" />
  13. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  14. <result column="issued_at" property="issuedAt" jdbcType="TIMESTAMP"/>
  15. <result column="author" property="author" jdbcType="VARCHAR" />
  16. <result column="status" property="status" jdbcType="BIGINT" />
  17. <result column="version" property="version" jdbcType="VARCHAR" />
  18. <result column="issued_account_id" property="issuedAccountId" jdbcType="BIGINT" />
  19. <result column="issued_account_name" property="issuedAccountName" jdbcType="VARCHAR" />
  20. </resultMap>
  21. <sql id="ChecklistDto_Cols">
  22. A.oc_id,
  23. A.checklist_id,
  24. A.checklist_cat_id,
  25. B.checklist_cat_title,
  26. A.checklist_type_id,
  27. A.checklist_desc,
  28. A.checklist_title,
  29. A.is_fixed,
  30. C.account_name AS issued_account_name,
  31. A.issued_by AS issued_account_id,
  32. A.issued_at,
  33. A.author,
  34. A.status,
  35. A.version
  36. </sql>
  37. <!--根据ID获取信息-->
  38. <select id="getById" resultMap="ChecklistDtoResultMap">
  39. SELECT
  40. <include refid="ChecklistDto_Cols"/>
  41. FROM checklist AS A
  42. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  43. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  44. WHERE A.deleted_flag = 0
  45. <if test="ocId != null">
  46. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  47. </if>
  48. <if test="checklistId !=null">
  49. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  50. </if>
  51. </select>
  52. <!--根据ID获取信息-->
  53. <select id="getByChecklistId" resultMap="ChecklistDtoResultMap">
  54. SELECT
  55. <include refid="ChecklistDto_Cols"/>
  56. FROM checklist AS A
  57. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  58. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  59. WHERE A.deleted_flag = 0
  60. <if test="checklistId !=null">
  61. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  62. </if>
  63. </select>
  64. <!--获取列表-->
  65. <select id="getByList" resultMap="ChecklistDtoResultMap" parameterType="java.util.Map">
  66. SELECT
  67. <include refid="ChecklistDto_Cols"/>
  68. FROM checklist AS A
  69. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  70. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  71. WHERE A.deleted_flag = 0
  72. <if test="ocId != null">
  73. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  74. </if>
  75. <if test="checklistId !=null">
  76. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  77. </if>
  78. <if test="keywords != null and keywords != ''">
  79. AND A.checklist_title like "%"#{keywords}"%"
  80. </if>
  81. <if test="checklistTypeId != null">
  82. AND A.checklist_type_id = #{checklistTypeId ,jdbcType=BIGINT}
  83. </if>
  84. <if test="status != null">
  85. AND A.status = #{status ,jdbcType=BIGINT}
  86. </if>
  87. ORDER BY A.checklist_id
  88. </select>
  89. <!--分页获取-->
  90. <select id="getByPage" resultMap="ChecklistDtoResultMap" parameterType="java.util.Map">
  91. SELECT
  92. <include refid="ChecklistDto_Cols"/>
  93. FROM checklist AS A
  94. LEFT JOIN checklist_cat AS B ON (A.oc_id = B.oc_id AND A.checklist_cat_id = B.checklist_cat_id)
  95. LEFT JOIN account AS C ON (A.oc_id = C.oc_id AND A.issued_by = C.account_id)
  96. WHERE A.deleted_flag = 0
  97. <if test="ocId != null">
  98. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  99. </if>
  100. <if test="checklistId !=null">
  101. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  102. </if>
  103. <if test="checklistCatId != null">
  104. AND A.checklist_cat_id = #{checklistCatId, jdbcType=BIGINT}
  105. </if>
  106. <if test="keywords != null and keywords != ''">
  107. AND A.checklist_title like "%"#{keywords}"%"
  108. </if>
  109. <if test="checklistTypeId != null">
  110. AND A.checklist_type_id = #{checklistTypeId ,jdbcType=BIGINT}
  111. </if>
  112. <if test="status != null">
  113. AND A.status = #{status ,jdbcType=BIGINT}
  114. </if>
  115. ORDER BY A.checklist_id
  116. </select>
  117. <!--Create-->
  118. <insert id="create" parameterType="com.zhyc.xps.common.entity.Checklist" keyProperty="checklistId">
  119. INSERT INTO checklist
  120. <trim prefix="(" suffix=")" suffixOverrides=",">
  121. <if test="ocId != null">
  122. oc_id,
  123. </if>
  124. <if test="checklistId != null">
  125. checklist_id,
  126. </if>
  127. <if test="checklistCatId != null">
  128. checklist_cat_id,
  129. </if>
  130. <if test="checklistTypeId != null">
  131. checklist_type_id,
  132. </if>
  133. <if test="checklistTitle != null and checklistTitle!=''">
  134. checklist_title,
  135. </if>
  136. <if test="checklistDesc != null and checklistDesc != ''">
  137. checklist_desc,
  138. </if>
  139. <if test="isFixed != null">
  140. is_fixed,
  141. </if>
  142. <if test="issuedBy != null">
  143. issued_by,
  144. </if>
  145. <if test="issuedAt != null">
  146. issued_at,
  147. </if>
  148. <if test="author != null and author != ''">
  149. author,
  150. </if>
  151. <if test="status != null">
  152. status,
  153. </if>
  154. <if test="version != null and version != ''">
  155. version,
  156. </if>
  157. <if test="createdBy != null">
  158. created_by,
  159. </if>
  160. <if test="createdAt != null">
  161. created_at,
  162. </if>
  163. </trim>
  164. <trim prefix="values (" suffix=")" suffixOverrides=",">
  165. <if test="ocId != null">
  166. #{ocId ,jdbcType=BIGINT},
  167. </if>
  168. <if test="checklistId != null">
  169. #{checklistId ,jdbcType=BIGINT},
  170. </if>
  171. <if test="checklistCatId != null">
  172. #{checklistCatId ,jdbcType=BIGINT},
  173. </if>
  174. <if test="checklistTypeId != null">
  175. #{checklistTypeId ,jdbcType=BIGINT},
  176. </if>
  177. <if test="checklistTitle != null and checklistTitle!=''">
  178. #{checklistTitle ,jdbcType=VARCHAR},
  179. </if>
  180. <if test="checklistDesc != null and checklistDesc != ''">
  181. #{checklistDesc ,jdbcType=VARCHAR},
  182. </if>
  183. <if test="isFixed != null">
  184. #{isFixed ,jdbcType=BIGINT},
  185. </if>
  186. <if test="issuedBy != null">
  187. #{issuedBy ,jdbcType=BIGINT},
  188. </if>
  189. <if test="issuedAt != null">
  190. #{issuedAt ,jdbcType=TIMESTAMP},
  191. </if>
  192. <if test="author != null and author != ''">
  193. #{author ,jdbcType=VARCHAR},
  194. </if>
  195. <if test="status != null">
  196. #{status ,jdbcType=BIGINT},
  197. </if>
  198. <if test="version != null and version != ''">
  199. #{version ,jdbcType=VARCHAR},
  200. </if>
  201. <if test="createdBy != null">
  202. #{createdBy ,jdbcType=BIGINT},
  203. </if>
  204. <if test="createdAt != null">
  205. #{createdAt ,jdbcType=TIMESTAMP},
  206. </if>
  207. </trim>
  208. </insert>
  209. <!--更新-->
  210. <update id="update" parameterType="com.zhyc.xps.common.entity.Checklist">
  211. UPDATE checklist
  212. <trim suffixOverrides=",">
  213. <set>
  214. <if test="checklistCatId != null">
  215. checklist_cat_id = #{checklistCatId ,jdbcType=BIGINT},
  216. </if>
  217. <if test="checklistTypeId != null">
  218. checklist_type_id = #{checklistTypeId ,jdbcType=BIGINT},
  219. </if>
  220. <if test="checklistTitle != null">
  221. checklist_title =#{checklistTitle ,jdbcType=VARCHAR},
  222. </if>
  223. <if test="checklistDesc != null and checklistDesc != ''">
  224. checklist_desc = #{checklistDesc ,jdbcType=VARCHAR},
  225. </if>
  226. <if test="isFixed != null">
  227. is_fixed = #{isFixed ,jdbcType=BIGINT},
  228. </if>
  229. <if test="issuedBy != null">
  230. issued_by = #{issuedBy ,jdbcType=BIGINT},
  231. </if>
  232. <if test="issuedAt != null">
  233. issued_at = #{issuedAt ,jdbcType=TIMESTAMP},
  234. </if>
  235. <if test="author != null and author != ''">
  236. author = #{author ,jdbcType=VARCHAR},
  237. </if>
  238. <if test="status != null">
  239. status = #{status ,jdbcType=BIGINT},
  240. </if>
  241. <if test="version != null and version != ''">
  242. version = #{version ,jdbcType=VARCHAR},
  243. </if>
  244. <if test="updatedBy != null">
  245. updated_by = #{updatedBy ,jdbcType=BIGINT},
  246. </if>
  247. <if test="updatedAt != null">
  248. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  249. </if>
  250. </set>
  251. </trim>
  252. WHERE 1 = 1
  253. <if test="ocId != null">
  254. AND oc_id = #{ocId ,jdbcType=BIGINT}
  255. </if>
  256. <if test="checklistId != null">
  257. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  258. </if>
  259. </update>
  260. <!--删除 -->
  261. <update id="delete" parameterType="java.util.Map">
  262. UPDATE checklist
  263. <trim suffixOverrides=",">
  264. <set>
  265. <if test="deletedBy != null">
  266. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  267. </if>
  268. <if test="deletedAt != null">
  269. deleted_at = #{deletedAt ,jdbcType=DATE},
  270. </if>
  271. <if test="deletedFlag != null">
  272. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  273. </if>
  274. </set>
  275. </trim>
  276. WHERE deleted_flag = 0
  277. <if test="ocId != null">
  278. AND oc_id = #{ocId ,jdbcType=BIGINT}
  279. </if>
  280. <if test="checklistId != null ">
  281. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  282. </if>
  283. </update>
  284. </mapper>