<?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.ningdatech.pmapi.projectlib.mapper.ProjectRenewalFundDeclarationMapper">

    <select id="pageSql"
            parameterType="com.ningdatech.pmapi.projectlib.model.req.ProjectRenewalListReq"
            resultType="com.ningdatech.pmapi.projectlib.model.po.ProjectRenewalFundDeclarationPO">
        select
            prfd.id,prfd.create_on,prfd.update_on,prfd.project_id,
            prfd.project_year,prfd.annual_payment_amount,prfd.have_amount,
            prfd.gov_own_finance_amount,prfd.gov_superior_finance_amount,
            prfd.bank_lending_amount,prfd.other_amount,prfd.approval_status,prfd.deleted,
            p.project_type,p.project_name,p.build_org_name
        from nd_project_renewal_fund_declaration prfd
        left join nd_project p on prfd.project_id = p.id
        where prfd.deleted = false
        <if test="param.projectName != null and param.projectName != ''">
            and p.project_name like concat('%',#{param.projectName},'%')
        </if>
        <if test="param.orgCode != null and param.orgCode != ''">
            and prfd.org_code = #{param.orgCode}
        </if>
        <if test="param.regionCode != null and param.regionCode != ''">
            and prfd.region_code = #{param.regionCode}
        </if>
        <if test="param.projectType != null">
            and p.project_type = #{param.projectType}
        </if>
        <if test="param.projectYear != null">
            and p.project_year = #{param.projectYear}
        </if>
        <if test="param.stage != null">
            and p.stage = #{param.stage}
        </if>
        <if test="param.status != null">
            and p.status = #{param.status}
        </if>
        <if test="param.createOnMin != null">
            and p.create_on &gt;= #{param.createOnMin}
        </if>
        <if test="param.createOnMax != null">
            and p.create_on &lt;= #{param.createOnMax}
        </if>
    </select>
</mapper>
