<?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="cn.ey.biz.module.system.dal.mapper.permission.RoleCodeblockMapper">

    <!-- 自定义ORM映射规则 -->
    <resultMap id="CodeBlockUserGpn" type="cn.ey.biz.module.system.controller.admin.codeblock.vo.CodeBlockUserGpnVO">
        <result column="gpn" property="gpn"/>
        <result column="code_block" property="codeBlock"/>
    </resultMap>


    <select id="getCodeLockUserGpnList" resultMap="CodeBlockUserGpn">
        SELECT
        us.gpn,
        block.code_block
        FROM
        system_users us
        LEFT JOIN system_user_data_role ro ON ro.user_id = us.id
        LEFT JOIN system_data_role dr ON dr.id = ro.role_id
        LEFT JOIN system_role_codeblock block ON block.role_id = ro.role_id
        WHERE
        us.deleted=0
        and ro.deleted=0
        and dr.deleted=0
        and block.deleted=0
        <if test="app != null and app != ''">
            and dr.app=#{app}
        </if>
        <if test="list !=null and list.size() > 0">
            and block.code_block IN
            <foreach collection="list" item="item" open="(" close=")" separator=",">
                #{item}
            </foreach>
        </if>
    </select>


</mapper>

