<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.casic.missiles.mapper.system.SystemDeptMapper">
<select id="treeByDept" resultType="com.casic.missiles.core.node.ZTreeNode">
select id,pid as pId,simple_name as name,id as "deptId", pids as pIds
(
CASE
WHEN (pId = '0' OR pId IS NULL) THEN
'true'
ELSE
'false'
END
) as isOpen from sys_dept
<where>
and del_flag = '0'
<if test='pid != null and pid != ""'>
and ( pids like
<include refid="deptid_sql"/>
)
</if>
<if test='deptType != null and deptType != ""'>
and dept_type = #{deptType}
</if>
<if test="tips != null and tips != ''">
and tips = #{tips}
</if>
</where>
ORDER BY pid,num
</select>
<sql id="deptid_sql" databaseId="mysql">
CONCAT
('%[',
#{pid,jdbcType=VARCHAR},
']%'
)
</sql>
<sql id="deptid_sql" databaseId="pgsql">
CONCAT
('%[',
#{pid,jdbcType=VARCHAR},
']%'
)
</sql>
<sql id="deptid_sql" databaseId="oracle">
'%[' ||
#{pid,jdbcType=VARCHAR}
||
']%'
</sql>
</mapper>