<?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.member.account.mapper.CuMemberRelatedAccountsMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.related.CuMemberRelatedAccounts">
        <id column="PK_ID" property="pkId" />
    <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_COUNTRY" property="pkCountry" />
    <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_MEMBER" property="pkMember" />
        <result column="PK_RELATED_MEMBER" property="pkRelatedMember" />
    </resultMap>
    <resultMap id="resultMap" type="com.hzs.common.domain.member.ext.CuMemberRelatedAccountsExt">
        <id column="PK_ID" property="pkId" />
        <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_COUNTRY" property="pkCountry" />
        <result column="DEL_FLAG" property="delFlag" />
        <result column="PK_MEMBER" property="pkMember" />
        <result column="PK_RELATED_MEMBER" property="pkRelatedMember" />
        <result column="relatedMemberCode" property="relatedMemberCode" />
        <result column="relatedMemberName" property="relatedMemberName" />
    </resultMap>
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        CREATION_TIME,
        PK_CREATOR,
        MODIFIED_TIME,
        PK_MODIFIED,
        PK_COUNTRY,
        DEL_FLAG,
        PK_ID, PK_MEMBER, PK_RELATED_MEMBER
    </sql>

    <select id="queryList" resultMap="resultMap">
         select ra.*, cm.MEMBER_CODE relatedMemberCode ,cm.MEMBER_NAME relatedMemberName from CU_MEMBER_RELATED_ACCOUNTS ra
         left join CU_MEMBER cm on cm.PK_ID = ra.PK_RELATED_MEMBER
        <if test="memberCode != null and memberCode != ''">
            and cm.MEMBER_CODE = #{memberCode}
        </if>
        <if test="memberName != null and memberName != ''">
            and cm.MEMBER_NAME = #{memberName}
        </if>
        <if test="pkMember != null">
            and cm.PK_ID = #{pkMember}
        </if>
    </select>
</mapper>
