<?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.system.config.mapper.CuAuthorityControlMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.attest.CuAuthorityControl">
        <id column="PK_ID" property="pkId" />
    <result column="PK_COUNTRY" property="pkCountry" />
    <result column="DEL_FLAG" property="delFlag" />
    <result column="CREATION_TIME" property="creationTime" />
    <result column="PK_CREATOR" property="pkCreator" />
    <result column="MODIFIED_TIME" property="modifiedTime" />
    <result column="PK_MODIFIED" property="pkModified" />
        <result column="PK_MEMBER" property="pkMember" />
        <result column="CONTROL_TYPE" property="controlType" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        PK_COUNTRY,
        DEL_FLAG,
        CREATION_TIME,
        PK_CREATOR,
        MODIFIED_TIME,
        PK_MODIFIED,
        PK_ID, PK_MEMBER, CONTROL_TYPE
    </sql>

    <!--   查询会员控制配置列表-->
    <select id="queryAuthorityControlList" parameterType="com.hzs.common.domain.member.attest.ext.CuAuthorityControlExt"
            resultType="com.hzs.common.domain.member.attest.ext.CuAuthorityControlExt">
        SELECT
        cac.PK_ID pkId,
        cac.PK_MEMBER pkMember,
        cm.MEMBER_CODE memberCode,
        cm.MEMBER_NAME memberName,
        cac.CONTROL_TYPE controlType
        FROM
        CU_MEMBER cm
        INNER JOIN CU_AUTHORITY_CONTROL cac ON cm.PK_ID = cac.PK_MEMBER
        WHERE
        cm.DEL_FLAG = 0
        AND cac.DEL_FLAG = 0
        AND cac.PK_COUNTRY=#{pkCountry}
        <if test="controlType != null">
            AND cac.CONTROL_TYPE =#{controlType}
        </if>
        <if test="memberName != null and memberName != ''">
            and cm.MEMBER_NAME like #{memberName} || '%'
        </if>
        <if test="memberCode != null and memberCode != ''">
            and cm.member_code like #{memberCode} || '%'
        </if>
        order by cac.PK_ID desc
    </select>

</mapper>
