<?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.hzs.activity.base.mapper.AcBaseAuthorityMapper">

    <!-- 向上校验安置关系 -->
    <select id="checkPlaceParent" resultType="int">
        select count(1)
        from cu_member cm
        where cm.del_flag = 0
        and cm.member_code in
        <foreach collection="topCodeList" item="items" open="(" close=")" separator=",">
            #{items}
        </foreach>
        start with cm.pk_id = #{pkMember}
        connect by cm.pk_id = prior cm.pk_place_parent
    </select>

    <!-- 向上校验血缘关系 -->
    <select id="checkParent" resultType="int">
        select count(1)
        from cu_member cm
        where cm.del_flag = 0
        and cm.member_code in
        <foreach collection="topCodeList" item="items" open="(" close=")" separator=",">
            #{items}
        </foreach>
        start with cm.pk_id = #{pkMember}
        connect by cm.pk_id = prior cm.pk_parent
    </select>

    <!-- 查询权限列表 -->
    <select id="listAuthority" resultType="com.hzs.common.domain.activity.base.AcBaseAuthority">
        select aba.*
        from AC_BASE_AUTHORITY aba
        where aba.del_flag = 0
          and aba.pk_base_id = #{pkBaseId}
    </select>

</mapper>
