ChecklistItemMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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.zhyc.xps.sys.mapper.ChecklistItemMapper">
  4. <resultMap id="ChecklistItemDtoMap" type="com.zhyc.xps.sys.dto.ChecklistItemDto">
  5. <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
  6. <result column="item_id" property="itemId" jdbcType="BIGINT" />
  7. <result column="item_title" property="itemTitle" jdbcType="VARCHAR"/>
  8. <result column="item_code" property="itemCode" jdbcType="VARCHAR"/>
  9. <result column="item_type" property="itemType" jdbcType="BIGINT" />
  10. <result column="item_remark" property="itemRemark" jdbcType="VARCHAR"/>
  11. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  12. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  13. <result column="root_id" property="rootId" jdbcType="BIGINT" />
  14. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
  15. <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
  16. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
  17. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
  18. <result column="sort_no" property="sortNo" jdbcType="BIGINT" />
  19. </resultMap>
  20. <sql id="ChecklistItemDto_Cols">
  21. A.checklist_id,
  22. A.item_id,
  23. A.item_title,
  24. A.item_code,
  25. A.item_type,
  26. A.item_remark,
  27. A.parent_id,
  28. A.is_fixed,
  29. A.root_id,
  30. A.node_left,
  31. A.node_right,
  32. A.node_level,
  33. A.is_leaf,
  34. A.sort_no
  35. </sql>
  36. <!--基于ID查询-->
  37. <select id="getById" resultMap="ChecklistItemDtoMap">
  38. SELECT
  39. <include refid="ChecklistItemDto_Cols"/>
  40. FROM checklist_item AS A
  41. WHERE A.oc_id = #{ocId ,jdbcType=BIGINT}
  42. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  43. AND A.item_id = #{itemId ,jdbcType=BIGINT}
  44. </select>
  45. <!--分页查询-->
  46. <select id="getByPage" parameterType="java.util.Map" resultMap="ChecklistItemDtoMap">
  47. SELECT
  48. <include refid="ChecklistItemDto_Cols"/>
  49. FROM checklist_item AS A
  50. WHERE A.deleted_flag = 0
  51. <if test="ocId != null">
  52. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  53. </if>
  54. <if test="checklistId != null">
  55. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  56. </if>
  57. <if test="keywords != null and keywords != ''">
  58. AND A.item_title like "%"#{keywords}"%"
  59. </if>
  60. <if test="nodeLeft != null and nodeRight != null">
  61. <![CDATA[
  62. AND A.node_left > #{nodeLeft ,jdbcType=BIGINT}
  63. AND A.node_right < #{nodeRight ,jdbcType=BIGINT}
  64. ]]>
  65. </if>
  66. ORDER BY A.sort_no
  67. </select>
  68. <!--列表查询-->
  69. <select id="getByList" parameterType="java.util.Map" resultMap="ChecklistItemDtoMap">
  70. SELECT
  71. <include refid="ChecklistItemDto_Cols"/>
  72. FROM checklist_item AS A
  73. WHERE A.deleted_flag = 0
  74. <if test="ocId != null">
  75. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  76. </if>
  77. <if test="checklistId != null">
  78. AND A.checklist_id = #{checklistId ,jdbcType=BIGINT}
  79. </if>
  80. <if test="keywords != null and keywords != ''">
  81. AND A.item_title like "%"#{keywords}"%"
  82. </if>
  83. <if test="nodeLeft != null and nodeRight != null">
  84. <![CDATA[
  85. AND A.node_left > #{nodeLeft ,jdbcType=BIGINT}
  86. AND A.node_right < #{nodeRight ,jdbcType=BIGINT}
  87. ]]>
  88. </if>
  89. ORDER BY A.sort_no
  90. </select>
  91. <!--列表查询一级结点-->
  92. <select id="getRootByList" parameterType="java.util.Map" resultMap="ChecklistItemDtoMap">
  93. SELECT
  94. <include refid="ChecklistItemDto_Cols"/>
  95. FROM checklist_item AS A
  96. WHERE A.deleted_flag = 0 AND parent_id = 0
  97. <if test="ocId != null">
  98. AND 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="keywords != null and keywords != ''">
  104. AND A.item_title like "%"#{keywords}"%"
  105. </if>
  106. ORDER BY A.sort_no
  107. </select>
  108. <insert id="create" parameterType="com.zhyc.xps.sys.entity.ChecklistItem">
  109. INSERT INTO checklist_item
  110. <trim prefix="(" suffix=")" suffixOverrides=",">
  111. <if test="ocId != null">
  112. oc_id,
  113. </if>
  114. <if test="checklistId != null">
  115. checklist_id,
  116. </if>
  117. <if test="itemId != null">
  118. item_id,
  119. </if>
  120. <if test="itemTitle != null and itemTitle != ''">
  121. item_title,
  122. </if>
  123. <if test="itemCode != null and itemCode != ''">
  124. item_code,
  125. </if>
  126. <if test="itemType != null">
  127. item_type,
  128. </if>
  129. <if test="itemRemark != null and itemRemark != ''">
  130. item_remark,
  131. </if>
  132. <if test="isFixed != null">
  133. is_fixed,
  134. </if>
  135. <if test="parentId != null">
  136. parent_id,
  137. </if>
  138. <if test="rootId != null">
  139. root_id,
  140. </if>
  141. <if test="nodeLeft != null">
  142. node_left,
  143. </if>
  144. <if test="nodeRight != null">
  145. node_right,
  146. </if>
  147. <if test="nodeLevel != null">
  148. node_level,
  149. </if>
  150. <if test="isLeaf != null">
  151. is_leaf,
  152. </if>
  153. <if test="createdBy != null">
  154. created_by,
  155. </if>
  156. <if test="createdAt != null">
  157. created_at,
  158. </if>
  159. </trim>
  160. <trim prefix="values (" suffix=")" suffixOverrides=",">
  161. <if test="ocId != null">
  162. #{ocId ,jdbcType=BIGINT},
  163. </if>
  164. <if test="checklistId != null">
  165. #{checklistId, jdbcType=BIGINT},
  166. </if>
  167. <if test="itemId != null">
  168. #{itemId, jdbcType=BIGINT},
  169. </if>
  170. <if test="itemTitle != null and itemTitle !=''">
  171. #{itemTitle ,jdbcType=VARCHAR},
  172. </if>
  173. <if test="itemCode != null and itemCode !=''">
  174. #{itemCode ,jdbcType=VARCHAR},
  175. </if>
  176. <if test="itemType != null">
  177. #{itemType, jdbcType=BIGINT},
  178. </if>
  179. <if test="itemRemark != null and itemRemark != ''">
  180. #{itemRemark ,jdbcType=VARCHAR},
  181. </if>
  182. <if test="isFixed != null">
  183. #{isFixed ,jdbcType=BIGINT},
  184. </if>
  185. <if test="parentId != null">
  186. #{parentId ,jdbcType=BIGINT},
  187. </if>
  188. <if test="rootId != null">
  189. #{rootId ,jdbcType=BIGINT},
  190. </if>
  191. <if test="nodeLeft != null">
  192. #{nodeLeft ,jdbcType=BIGINT},
  193. </if>
  194. <if test="nodeRight != null">
  195. #{nodeRight ,jdbcType=BIGINT},
  196. </if>
  197. <if test="nodeLevel != null">
  198. #{nodeLevel ,jdbcType=BIGINT},
  199. </if>
  200. <if test="isLeaf != null">
  201. #{isLeaf ,jdbcType=BIGINT},
  202. </if>
  203. <if test="createdBy != null">
  204. #{createdBy ,jdbcType=BIGINT},
  205. </if>
  206. <if test="createdAt != null">
  207. #{createdAt ,jdbcType=TIMESTAMP},
  208. </if>
  209. </trim>
  210. </insert>
  211. <!--更新-->
  212. <update id="update" parameterType="com.zhyc.xps.sys.entity.ChecklistItem">
  213. UPDATE checklist_item
  214. <trim suffixOverrides=",">
  215. <set>
  216. <if test="itemTitle != null and itemTitle != ''">
  217. item_title = #{itemTitle, jdbcType=VARCHAR},
  218. </if>
  219. <if test="itemCode != null and itemCode != ''">
  220. item_code = #{itemCode, jdbcType=VARCHAR},
  221. </if>
  222. <if test="itemType != null">
  223. item_type = #{itemType, jdbcType=BIGINT},
  224. </if>
  225. <if test="itemRemark != null and itemRemark != ''">
  226. item_remark = #{itemRemark, jdbcType=VARCHAR},
  227. </if>
  228. <if test="isFixed != null">
  229. is_fixed = #{isFixed ,jdbcType=BIGINT},
  230. </if>
  231. <if test="parentId != null">
  232. parent_id = #{parentId ,jdbcType=BIGINT},
  233. </if>
  234. <if test="rootId != null">
  235. root_id = #{rootId ,jdbcType=BIGINT},
  236. </if>
  237. <if test="nodeLeft != null">
  238. node_left = #{nodeLeft ,jdbcType=BIGINT},
  239. </if>
  240. <if test="nodeRight != null">
  241. node_right = #{nodeRight ,jdbcType=BIGINT},
  242. </if>
  243. <if test="nodeLevel != null">
  244. node_level = #{nodeLevel ,jdbcType=BIGINT},
  245. </if>
  246. <if test="isLeaf != null">
  247. is_leaf = #{isLeaf ,jdbcType=BIGINT},
  248. </if>
  249. <if test="updatedBy != null ">
  250. updated_by = #{updatedBy ,jdbcType=BIGINT},
  251. </if>
  252. <if test="updatedAt != null">
  253. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  254. </if>
  255. </set>
  256. </trim>
  257. WHERE 1 = 1
  258. <if test="ocId != null">
  259. AND oc_id = #{ocId ,jdbcType=BIGINT}
  260. </if>
  261. <if test="checklistId != null">
  262. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  263. </if>
  264. <if test="itemId != null">
  265. AND item_id = #{itemId ,jdbcType=BIGINT}
  266. </if>
  267. </update>
  268. <!--删除-->
  269. <update id="delete" parameterType="java.util.Map">
  270. UPDATE checklist_item
  271. <trim suffixOverrides=",">
  272. <set>
  273. <if test="deletedFlag != null">
  274. deleted_flag = #{deletedFlag,jdbcType=BIGINT},
  275. </if>
  276. <if test="deletedTime != null">
  277. deleted_time = #{deletedTime,jdbcType=VARCHAR},
  278. </if>
  279. <if test="deletedBy != null">
  280. deleted_by = #{deletedBy,jdbcType=BIGINT},
  281. </if>
  282. </set>
  283. </trim>
  284. WHERE 1 = 1
  285. <if test="ocId != null">
  286. AND oc_id = #{ocId ,jdbcType=BIGINT}
  287. </if>
  288. <if test="checklistId != null">
  289. AND checklist_id = #{checklistId ,jdbcType=BIGINT}
  290. </if>
  291. <if test="itemId != null">
  292. AND item_id = #{itemId ,jdbcType=BIGINT}
  293. </if>
  294. <if test="nodeLeft != null and nodeRight != null">
  295. <![CDATA[
  296. AND node_left >= #{nodeLeft ,jdbcType=BIGINT}
  297. AND node_right <= #{nodeRight ,jdbcType=BIGINT}
  298. ]]>
  299. </if>
  300. </update>
  301. </mapper>