<?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.base.mapper.CuHonorWallMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.member.honor.CuHonorWall">
        <id column="PK_ID" property="pkId"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="TYPE" property="type"/>
        <result column="VALUE" property="value"/>
        <result column="IMG" property="img"/>
        <result column="NAME" property="name"/>
    </resultMap>
    <resultMap id="BaseExtResultMap" type="com.hzs.common.domain.member.ext.CuHonorWallExt">
        <id column="PK_ID" property="pkId"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="TYPE" property="type"/>
        <result column="VALUE" property="value"/>
        <result column="IMG" property="img"/>
        <result column="remarks" property="remarks"/>
        <result column="NAME" property="name"/>
        <result column="haveTime" property="haveTime"/>
        <result column="PK_MEMBER" property="pkMember"/>
    </resultMap>

    <select id="queryAll" resultMap="BaseExtResultMap">
        select hw.*,
               a.CREATION_TIME haveTime,
               a.PK_MEMBER
        from CU_HONOR_WALL hw

                 left join (
            select mhw.CREATION_TIME, mhw.PK_MEMBER, mhw.PK_HONOR_WALL from CU_MEMBER_HONOR_WALL mhw where mhw.PK_MEMBER = #{pkMember}
        ) a on a.PK_HONOR_WALL = hw.pk_id
        where hw.PK_COUNTRY = #{pkCountry}
        order by hw.type, hw.value
    </select>

</mapper>
