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

    <!-- 通用查询映射结果 -->
    <resultMap id="procurementPlanDetailResultMap" type="org.springblade.zhaocai.pojo.entity.ProcurementPlanDetail">
        <result column="id" property="id"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="create_user" property="createUser"/>
        <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="plan_id" property="planId"/>
        <result column="year" property="year"/>
        <result column="plan_no" property="planNo"/>
        <result column="sort_no" property="sortNo"/>
        <result column="project_name" property="projectName"/>
        <result column="project_type" property="projectType"/>
        <result column="contact_person" property="contactPerson"/>
        <result column="contact_person_id" property="contactPersonId"/>
        <result column="apply_date" property="applyDate"/>
        <result column="expect_date" property="expectDate"/>
        <result column="project_attr" property="projectAttr"/>
        <result column="purchase_requirement" property="purchaseRequirement"/>
        <result column="budget_amount" property="budgetAmount"/>
        <result column="bidding_method" property="biddingMethod"/>
        <result column="project_intro" property="projectIntro"/>
        <result column="remark" property="remark"/>
        <result column="material_detail" property="materialDetail"/>
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="baseColumnList">
        select
        id, tenant_id, create_user, create_time, update_user, update_time, status, is_deleted,
        plan_id, year, plan_no, sort_no, project_name, project_type, contact_person, contact_person_id,
        apply_date, expect_date, project_attr, purchase_requirement, budget_amount, bidding_method,
        project_intro, remark, material_detail
    </sql>

    <select id="selectByPlanId" resultMap="procurementPlanDetailResultMap">
        <include refid="baseColumnList"/>
        from zc_procurement_plan_project
        where plan_id = #{planId}
        and is_deleted = 0
        order by sort_no asc
    </select>

    <delete id="deleteByPlanId">
        delete from zc_procurement_plan_project where plan_id = #{planId}
    </delete>

</mapper>
