<?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.xzx.gc.role.mapper.CoreOrgMapper"> 
 | 
    <select id="queryAllOrgCode" parameterType="java.util.List" resultType="java.lang.String"> 
 | 
        select code from core_org where id in 
 | 
        <foreach collection="orgIds" index="index" item="id" open="(" separator="," close=")"> 
 | 
            #{id} 
 | 
        </foreach> 
 | 
    </select> 
 | 
    <select id="getRoot" resultType="com.xzx.gc.entity.CoreOrg"> 
 | 
        select * 
 | 
        from core_org 
 | 
        where parent_org_id is null 
 | 
    </select> 
 | 
    <select id="queryOrgByUser" resultType="com.xzx.gc.entity.CoreOrg"> 
 | 
        select * 
 | 
        from core_org 
 | 
        where id in 
 | 
              (select org_id 
 | 
               from core_user_role 
 | 
               where user_id = #{userId} 
 | 
               group by org_id) and del_flag = 0 
 | 
        order by id desc 
 | 
    </select> 
 | 
    <select id="queryByCondtion" resultType="com.xzx.gc.entity.CoreOrg"> 
 | 
        select 
 | 
        o.* 
 | 
        from core_org o where 1=1 and del_flag = 0 
 | 
        <if test="code != null and code != ''"> 
 | 
            and  o.code like concat("%",#{code},"%") 
 | 
        </if> 
 | 
        <if test="name != null and name != ''"> 
 | 
            and  o.name like concat("%",#{name},"%") 
 | 
        </if> 
 | 
        <if test="type != null and type != ''"> 
 | 
            and  o.name like concat("%",#{type},"%") 
 | 
        </if> 
 | 
        <if test="parentOrgId != null and parentOrgId != ''"> 
 | 
            and  o.parent_org_id = concat("%",#{parentOrgId},"%") 
 | 
        </if> 
 | 
    </select> 
 | 
</mapper> 
 |