<sql id="selectZy">
WITH recursive tmp as (
select t1.* from sys_dept t1 WHERE t1.id = #{id}
union all
select t2.* from sys_dept t2 join tmp t3 WHERE t3.id = t2.parent_id
) select * from tmp where dept_type = 5 AND status = 0 AND del_flag = 0
</sql>
<select id="listAllMajor" parameterType="Long" resultType="map">
<include refid="selectZy" />
</select>
<select id="selectBizCourseListByDeptId" parameterType="BizCourse" resultType="map">
select t1.id, t1.title, t1.dept_id as deptId,
t2.dept_name as deptName, t1.create_by as createBy, t1.create_time as createTime,
t1.update_by as updateBy, t1.update_time as updateTime, t1.remark
from biz_course t1
join (
<include refid="selectZy" />
) t2 on t1.dept_id = t2.id
<where>
<if test="title != null and title != ''"> and t1.title like concat('%', #{title}, '%')</if>
<if test="deptId != null "> and t1.dept_id = #{deptId}</if>
</where>
</select>
未经允许不得转载:
红吉他 »
JAVA »
mybatis中include标签传参