LeadingGroupMapper.xml 11 KB

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