|
@@ -14,21 +14,36 @@
|
|
|
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
|
</resultMap>
|
|
|
|
|
|
- <select id="getList" resultMap="BaseResultMap">
|
|
|
+ <sql id="getList_mysql">
|
|
|
with recursive cte as (
|
|
|
- select * from sys_dept
|
|
|
- <where>
|
|
|
- <if test="deptQuery.pid != null and deptQuery.pid != ''">
|
|
|
- and pid = #{deptQuery.pid}
|
|
|
- </if>
|
|
|
- <if test="deptQuery.name != null and deptQuery.name != ''">
|
|
|
- and name like concat('%',#{deptQuery.name},'%')
|
|
|
- </if>
|
|
|
- </where>
|
|
|
- UNION
|
|
|
- select sm.* from sys_dept sm, cte where sm.id = cte.pid
|
|
|
+ select * from sys_dept
|
|
|
+ <where>
|
|
|
+ <include refid="deptWheres"></include>
|
|
|
+ </where>
|
|
|
+ UNION
|
|
|
+ select sm.* from sys_dept sm, cte where sm.id = cte.pid
|
|
|
)
|
|
|
select * from cte order by sort asc
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="getList_oracle">
|
|
|
+ SELECT * FROM SYS_DEPT
|
|
|
+ START WITH
|
|
|
+ <include refid="deptWheres"></include>
|
|
|
+ CONNECT BY PRIOR pid = id
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <sql id="deptWheres">
|
|
|
+ <if test="deptQuery.pid != null and deptQuery.pid != ''">
|
|
|
+ and pid = #{deptQuery.pid}
|
|
|
+ </if>
|
|
|
+ <if test="deptQuery.name != null and deptQuery.name != ''">
|
|
|
+ and name like concat('%',#{deptQuery.name},'%')
|
|
|
+ </if>
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="getList" resultMap="BaseResultMap">
|
|
|
+ <include refid="getList_mysql"></include>
|
|
|
</select>
|
|
|
|
|
|
|