DocDirMapper.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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.sys.mapper.DocDirMapper">
  5. <resultMap id="BaseResultMap" type="com.zhyc.xps.sys.entity.DocDir">
  6. <result column="oc_id" property="ocId" jdbcType="BIGINT" /><!--ID-->
  7. <result column="dir_id" property="dirId" jdbcType="BIGINT" /><!--目录ID-->
  8. <result column="dir_title" property="dirTitle" jdbcType="VARCHAR"/>
  9. <result column="dir_desc" property="dirDesc" jdbcType="VARCHAR"/>
  10. <result column="parent_id" property="parentId" jdbcType="BIGINT" />
  11. <result column="is_fixed" property="isFixed" jdbcType="BIGINT" />
  12. <result column="node_left" property="nodeLeft" jdbcType="BIGINT" />
  13. <result column="node_right" property="nodeRight" jdbcType="BIGINT" />
  14. <result column="node_level" property="nodeLevel" jdbcType="BIGINT" />
  15. <result column="is_leaf" property="isLeaf" jdbcType="BIGINT" />
  16. </resultMap>
  17. <sql id="DocDir_Cols">
  18. A.oc_id,
  19. A.dir_id,
  20. A.dir_title,
  21. A.dir_desc,
  22. A.parent_id,
  23. A.is_fixed,
  24. A.node_left,
  25. A.node_right,
  26. A.node_level,
  27. A.is_leaf
  28. </sql>
  29. <!--基于ID查询-->
  30. <select id="getById" resultMap="BaseResultMap">
  31. SELECT
  32. <include refid="DocDir_Cols"/>
  33. FROM doc_dir AS A
  34. WHERE 1 = 1 AND A.deleted_flag = 0
  35. <if test="ocId != null">
  36. AND A.oc_id = #{ocId ,jdbcType=BIGINT}
  37. </if>
  38. <if test="dirId !=null">
  39. AND A.dir_id = #{dirId ,jdbcType=BIGINT}
  40. </if>
  41. </select>
  42. <!--列表查询-->
  43. <select id="getByPage" resultMap="BaseResultMap" parameterType="java.util.Map">
  44. SELECT
  45. <include refid="DocDir_Cols"/>
  46. FROM doc_dir AS A
  47. WHERE 1 = 1 AND A.deleted_flag = 0
  48. <if test="ocId != null">
  49. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  50. </if>
  51. <if test="nodeLeft != null and nodeRight != null">
  52. <![CDATA[
  53. AND A.node_left > #{nodeLeft ,jdbcType=BIGINT}
  54. AND A.node_right < #{nodeRight ,jdbcType=BIGINT}
  55. ]]>
  56. </if>
  57. <if test="keywords != null and keywords != ''">
  58. AND A.dir_title like "%"#{keyword}"%"
  59. </if>
  60. ORDER BY A.created_at DESC
  61. </select>
  62. <!--列表查询-->
  63. <select id="getByList" resultMap="BaseResultMap" parameterType="java.util.Map">
  64. SELECT
  65. <include refid="DocDir_Cols"/>
  66. FROM doc_dir AS A
  67. WHERE 1 = 1 AND A.deleted_flag = 0
  68. <if test="ocId != null">
  69. AND A.oc_id = #{ocId, jdbcType=BIGINT}
  70. </if>
  71. <if test="nodeLeft != null and nodeRight != null">
  72. <![CDATA[
  73. AND A.node_left > #{nodeLeft ,jdbcType=BIGINT}
  74. AND A.node_right < #{nodeRight ,jdbcType=BIGINT}
  75. ]]>
  76. </if>
  77. <if test="keywords != null and keywords != ''">
  78. AND A.dir_title like "%"#{keywords}"%"
  79. </if>
  80. order by A.created_at DESC
  81. </select>
  82. <!--Create-->
  83. <insert id="create" parameterType="com.zhyc.xps.sys.entity.DocDir">
  84. INSERT INTO doc_dir
  85. <trim prefix="(" suffix=")" suffixOverrides=",">
  86. <if test="ocId != null">
  87. oc_id,
  88. </if>
  89. <if test="dirId != null">
  90. dir_id,
  91. </if>
  92. <if test="dirTitle != null and dirTitle!=''">
  93. dir_title,
  94. </if>
  95. <if test="dirDesc != null and dirDesc != ''">
  96. dir_desc,
  97. </if>
  98. <if test="parentId != null">
  99. parent_id,
  100. </if>
  101. <if test="isFixed != null">
  102. is_fixed,
  103. </if>
  104. <if test="nodeLeft != null">
  105. node_left,
  106. </if>
  107. <if test="nodeRight != null">
  108. node_right,
  109. </if>
  110. <if test="nodeLevel != null">
  111. node_level,
  112. </if>
  113. <if test="isLeaf != null">
  114. is_leaf,
  115. </if>
  116. <if test="createdBy != null">
  117. created_by,
  118. </if>
  119. <if test="createdAt != null">
  120. created_at,
  121. </if>
  122. </trim>
  123. <trim prefix="values (" suffix=")" suffixOverrides=",">
  124. <if test="ocId != null">
  125. #{ocId ,jdbcType=BIGINT},
  126. </if>
  127. <if test="dirId != null">
  128. #{dirId ,jdbcType=BIGINT},
  129. </if>
  130. <if test="dirTitle != null and dirTitle != ''">
  131. #{dirTitle ,jdbcType=VARCHAR},
  132. </if>
  133. <if test="dirDesc != null and dirDesc != ''">
  134. #{dirDesc ,jdbcType=VARCHAR},
  135. </if>
  136. <if test="parentId != null">
  137. #{parentId ,jdbcType=BIGINT},
  138. </if>
  139. <if test="isFixed != null">
  140. #{isFixed ,jdbcType=BIGINT},
  141. </if>
  142. <if test="nodeLeft != null">
  143. #{nodeLeft ,jdbcType=BIGINT},
  144. </if>
  145. <if test="nodeRight != null">
  146. #{nodeRight ,jdbcType=BIGINT},
  147. </if>
  148. <if test="nodeLevel != null">
  149. #{nodeLevel ,jdbcType=BIGINT},
  150. </if>
  151. <if test="isLeaf != null">
  152. #{isLeaf ,jdbcType=BIGINT},
  153. </if>
  154. <if test="createdBy != null">
  155. #{createdBy ,jdbcType=BIGINT},
  156. </if>
  157. <if test="createdAt != null">
  158. #{createdAt ,jdbcType=TIMESTAMP},
  159. </if>
  160. </trim>
  161. </insert>
  162. <!--更新-->
  163. <update id="update" parameterType="com.zhyc.xps.sys.entity.DocDir">
  164. UPDATE doc_dir
  165. <trim suffixOverrides=",">
  166. <set>
  167. <if test="dirTitle != null and dirTitle != ''">
  168. dir_title =#{dirTitle ,jdbcType=VARCHAR},
  169. </if>
  170. <if test="dirDesc != null and dirDesc != ''">
  171. dir_desc = #{dirDesc ,jdbcType=VARCHAR},
  172. </if>
  173. <if test="parentId != null">
  174. parent_id = #{parentId ,jdbcType=BIGINT},
  175. </if>
  176. <if test="isFixed != null">
  177. is_fixed = #{isFixed ,jdbcType=BIGINT},
  178. </if>
  179. <if test="nodeLeft != null">
  180. node_left = #{nodeLeft ,jdbcType=BIGINT},
  181. </if>
  182. <if test="nodeRight != null">
  183. node_right = #{nodeRight ,jdbcType=BIGINT},
  184. </if>
  185. <if test="nodeLevel != null">
  186. node_level = #{nodeLevel ,jdbcType=BIGINT},
  187. </if>
  188. <if test="isLeaf != null">
  189. is_leaf = #{isLeaf ,jdbcType=BIGINT},
  190. </if>
  191. <if test="updatedBy != null">
  192. updated_by = #{updatedBy ,jdbcType=BIGINT},
  193. </if>
  194. <if test="updatedAt != null">
  195. updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
  196. </if>
  197. </set>
  198. </trim>
  199. WHERE 1 = 1
  200. <if test="dirId != null">
  201. AND dir_id = #{dirId ,jdbcType=BIGINT}
  202. </if>
  203. <if test="ocId != null">
  204. AND oc_id = #{ocId ,jdbcType=BIGINT}
  205. </if>
  206. </update>
  207. <!--删除 -->
  208. <update id="delete" parameterType="java.util.Map">
  209. UPDATE doc_dir
  210. <trim suffixOverrides=",">
  211. <set>
  212. <if test="dirId != null">
  213. dir_id = #{dirId ,jdbcType=BIGINT},
  214. </if>
  215. <if test="deletedBy != null">
  216. deleted_by = #{deletedBy ,jdbcType=BIGINT},
  217. </if>
  218. <if test="deletedAt != null">
  219. deleted_at = #{deletedAt ,jdbcType=DATE},
  220. </if>
  221. <if test="deletedFlag != null">
  222. deleted_flag = #{deletedFlag ,jdbcType=BIGINT},
  223. </if>
  224. </set>
  225. </trim>
  226. WHERE 1 = 1 AND deleted_flag = 0
  227. <if test="ocId != null">
  228. AND oc_id = #{ocId,jdbcType=BIGINT}
  229. </if>
  230. <if test="dirId != null ">
  231. AND dir_id = #{dirId ,jdbcType=BIGINT}
  232. </if>
  233. </update>
  234. </mapper>