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

    <!-- 通用查询映射结果 -->
    <resultMap id="BdAgreementExt" type="com.hzs.common.domain.system.ext.BdAgreementExt">
        <id column="PK_ID" property="pkId" />
    <result column="DEL_FLAG" property="delFlag" />
    <result column="PK_COUNTRY" property="pkCountry" />
    <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="TITLE" property="title" />
        <result column="CONTENT" property="content" />
        <result column="EFFECTIVE_DATE" property="effectiveDate" />
        <result column="PK_AGREEMENT" property="pkAgreement" />
        <result column="SPECIAL_AREA" property="specialArea" />
        <result column="IS_INDEX_ALERT" property="isIndexAlert" />
    </resultMap>

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


    <select id="querySpecialAreaAgreement" resultMap="BdAgreementExt">
        select a.TITLE,a.CONTENT,a.EFFECTIVE_DATE,b.SPECIAL_AREA,a.CREATION_TIME,a.PK_COUNTRY,a.IS_INDEX_ALERT
        from  BD_AGREEMENT a
    INNER JOIN BD_AGREEMENT_DETAIL b on a.PK_ID=b.PK_AGREEMENT
    where a.DEL_FLAG=0 and b.DEL_FLAG=0
        <if test="specialArea != null">
            AND  b.SPECIAL_AREA= #{specialArea}
        </if>
        <if test="pkCountry != null">
            AND  a.PK_COUNTRY= #{pkCountry}
        </if>
    </select>

</mapper>
