<?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="cn.iocoder.yudao.module.knowledge.mapper.TMonthlyProjectPurchaseMapper" >

    <!-- 用于select查询公用抽取的列 -->
    <sql id="columns">
        id,project_name,procurement_matters,procurement_content,matter_type,purchasing_method,tendering_agency,contract_price_estimated,contract_price,bid_price,purchase_time,contract_signing_time,contract_counterparty,remark,creator,create_time,update_time,deleted,identity_id,dept_id,tenant_id
    </sql>

    <select id="getListPage" resultType="cn.iocoder.yudao.module.knowledge.entity.TMonthlyProjectPurchase">
        SELECT
        <include refid="columns"/>
        FROM t_monthly_project_purchase
        WHERE
        deleted = 0
        <if test="dto.projectName != '' and dto.projectName != null">
            AND `project_name` LIKE CONCAT( '%',#{dto.projectName}, '%')
        </if>
        <if test="dto.procurementMatters != '' and dto.procurementMatters != null">
            AND `procurement_matters` LIKE CONCAT( '%',#{dto.procurementMatters}, '%')
        </if>
        <if test="dto.procurementContent != '' and dto.procurementContent != null">
            AND `procurement_content` LIKE CONCAT( '%',#{dto.procurementContent}, '%')
        </if>
        <if test="dto.purchasingMethod != '' and dto.purchasingMethod != null">
            AND `purchasing_method` LIKE CONCAT( '%',#{dto.purchasingMethod}, '%')
        </if>
        <if test=" dto.purchaseTime != null">
            AND DATE(purchase_time) = #{dto.purchaseTime}
        </if>
        <if test="dto.bgnTime!=null">
            AND (purchase_time >= date_format(#{dto.bgnTime},'%y-%m-%d 00:00:00') and purchase_time <![CDATA[<=]]> date_format(#{dto.endTime},'%y-%m-%d 23:59:59'))
        </if>
        ORDER BY
        purchase_time DESC
    </select>

</mapper>
