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

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.system.base.BdPlatformMessageDetail">
        <result column="CREATION_TIME" property="creationTime"/>
        <result column="MODIFIED_TIME" property="modifiedTime"/>
        <result column="DEL_FLAG" property="delFlag"/>
        <result column="PK_COUNTRY" property="pkCountry"/>
        <result column="PK_CREATOR" property="pkCreator"/>
        <result column="PK_MODIFIED" property="pkModified"/>
        <result column="PK_ID" property="pkId"/>
        <result column="PK_MESSAGE" property="pkMessage"/>
        <result column="STATUS" property="status"/>
        <result column="SUBMIT_TIME" property="submitTime"/>
        <result column="PK_SUBMIT" property="pkSubmit"/>
        <result column="SUBMIT_DEPT" property="submitDept"/>
        <result column="BUSINESS_CODE" property="businessCode"/>
        <result column="PK_REJECT" property="pkReject"/>
        <result column="REJECT_DEPT" property="rejectDept"/>
        <result column="PK_MEMBER" property="pkMember"/>
        <result column="WARES_NAME" property="waresName"/>
        <result column="PK_DEPT" property="pkDept"/>
        <result column="READ_STATE" property="readState"/>
        <result column="APPROVAL_CODE" property="approvalCode"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        CREATION_TIME,
        MODIFIED_TIME,
        DEL_FLAG,
        PK_COUNTRY,
        PK_CREATOR,
        PK_MODIFIED,
        PK_ID, PK_MESSAGE, STATUS, SUBMIT_TIME, PK_SUBMIT, SUBMIT_DEPT, BUSINESS_CODE, PK_REJECT, REJECT_DEPT,PK_MEMBER
    </sql>

    <select id="selectPlatformMessageDetailByPkMember" resultType="com.hzs.common.domain.system.ext.BdPlatformMessageDetailExt">
        select d.submit_time   submitTime,
               s.nick_name     submitName,
               d.submit_dept   submitDept,
               r.nick_name     rejectName,
               d.reject_dept   rejectDept,
               d.business_code businessCode,
               d.pk_id         pkId,
               t.title,
               t.content,
               t.url,
               t.business_type businessType,
               t.approval_type approvalType,
               d.wares_name waresName,
               d.pk_dept pkDept,
               d.read_state readState,
               d.approval_code approvalCode,
               d.creation_time creationTime
          from bd_platform_message_detail d
          left join bd_platform_message t
            on d.pk_message = t.pk_id
           and t.del_flag = 0
          left join sys_user s
            on s.user_id = d.pk_submit
           and s.del_flag = 0
          left join sys_user r
            on r.user_id = d.pk_reject
           and r.del_flag = 0
         where d.del_flag = 0
           and d.pk_country = #{pkCountry}
           and d.pk_member = #{pkMember}
         order by d.creation_time desc
    </select>


</mapper>
