<?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="org.springblade.zhaocai.mapper.ProcurementPlanMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="procurementPlanResultMap" type="org.springblade.zhaocai.pojo.entity.ProcurementPlan">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="applicant" property="applicant"/>
        <result column="apply_time" property="applyTime"/>
        <result column="phone" property="phone"/>
        <result column="company" property="company"/>
        <result column="bill_no" property="billNo"/>
        <result column="year" property="year"/>
        <result column="dept" property="dept"/>
        <result column="apply_company" property="applyCompany"/>
        <result column="estimated_amount" property="estimatedAmount"/>
        <result column="amount_upper" property="amountUpper"/>
        <result column="remark" property="remark"/>
        <result column="flow_status" property="flowStatus"/>
        <result column="process_instance_id" property="processInstanceId"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="baseColumnList">
        select
        id, tenant_id, create_user, create_dept, create_time, update_user, update_time, status, is_deleted,
        applicant, apply_time, phone, company, bill_no, year, dept, apply_company, estimated_amount, amount_upper,
        remark, flow_status, process_instance_id
    </sql>

    <select id="selectProcurementPlanPage" resultMap="procurementPlanResultMap">
        <include refid="baseColumnList"/>
        from zc_procurement_plan
        where is_deleted = 0
        <if test="procurementPlan.applicant != null and procurementPlan.applicant != ''">
            and applicant like concat('%', #{procurementPlan.applicant}, '%')
        </if>
        <if test="procurementPlan.billNo != null and procurementPlan.billNo != ''">
            and bill_no like concat('%', #{procurementPlan.billNo}, '%')
        </if>
        <if test="procurementPlan.year != null and procurementPlan.year != ''">
            and year = #{procurementPlan.year}
        </if>
        order by create_time desc
    </select>

</mapper>
