<?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.jeeplus.psimanage.foodPurchase.mapper.PsiFoodPurchaseChangeDetailMapper">

    <select id="getByChangeId" resultType="com.jeeplus.psimanage.foodPurchase.domain.PsiFoodPurchaseChangeDetail">
        SELECT
            id,
            create_by_id,
            create_time,
            update_by_id,
            update_time,
            del_flag,
            tenant_id,
            remarks,
            change_id,
            goods_name,
            food_type,
            purchase_number,
            unit,
            unit_price,
            total_price,
            storage_area,
            shelf_life,
            shelf_life_unit,
            expiry_date,
            sort
        FROM psi_management_food_purchase_change_detail
        WHERE change_id = #{changeId}
          AND del_flag = 0
        ORDER BY sort ASC, create_time ASC
    </select>

    <select id="getIdByChangeId" resultType="java.lang.String">
        SELECT id
        FROM psi_management_food_purchase_change_detail
        WHERE change_id = #{changeId}
          AND del_flag = 0
    </select>

    <update id="deleteByChangeId">
        UPDATE psi_management_food_purchase_change_detail
        SET del_flag = 1
        WHERE change_id = #{changeId}
          AND del_flag = 0
    </update>
</mapper>
