<?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.BdPlatformMessageMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.hzs.common.domain.system.base.BdPlatformMessage">
        <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="TITLE" property="title"/>
        <result column="CONTENT" property="content"/>
        <result column="URL" property="url"/>
        <result column="BUSINESS_TYPE" property="businessType"/>
        <result column="APPROVAL_TYPE" property="approvalType"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        CREATION_TIME,
        MODIFIED_TIME,
        DEL_FLAG,
        PK_COUNTRY,
        PK_CREATOR,
        PK_MODIFIED,
        PK_ID, TITLE, CONTENT, URL, BUSINESS_TYPE, APPROVAL_TYPE
    </sql>


    <update id="deletePlateFormMessageById">
        update BD_PLATFORM_MESSAGE  set del_flag = 1,PK_MODIFIED=#{pkModified},MODIFIED_TIME = sysdate where PK_ID=#{pkId}
    </update>

    <select id="showPlatformMessage" resultMap="BaseResultMap">
        select *
          from BD_PLATFORM_MESSAGE t
         where t.del_flag = 0
           and t.pk_country = #{pkCountry}
    </select>

    <select id="selectPlatformMessageByBusinessAndApproveType" resultMap="BaseResultMap">
        select *
          from (
                select t.pk_id, t.title, t.content, t.url
                  from BD_PLATFORM_MESSAGE t
                 where t.del_flag = 0
                   and t.pk_country = #{pkCountry}
                   and t.business_type = #{businessType}
                   and t.approval_type = #{approvalType}
                 order by t.creation_time desc) n
         where rownum = 1
    </select>
</mapper>
