package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalProductCheckOrderItem;
import com.fs.hospital.vo.HospitalProductCheckOrderItemListHVO;
import org.apache.ibatis.annotations.Select;

/**
 * 采购单明细Mapper接口
 *
 * @author fs
 * @date 2024-03-14
 */
public interface HospitalProductCheckOrderItemMapper
{
    /**
     * 查询采购单明细
     *
     * @param itemId 采购单明细主键
     * @return 采购单明细
     */
    public HospitalProductCheckOrderItem selectHospitalProductCheckOrderItemByItemId(Long itemId);

    /**
     * 查询采购单明细列表
     *
     * @param hospitalProductCheckOrderItem 采购单明细
     * @return 采购单明细集合
     */
    public List<HospitalProductCheckOrderItem> selectHospitalProductCheckOrderItemList(HospitalProductCheckOrderItem hospitalProductCheckOrderItem);

    /**
     * 新增采购单明细
     *
     * @param hospitalProductCheckOrderItem 采购单明细
     * @return 结果
     */
    public int insertHospitalProductCheckOrderItem(HospitalProductCheckOrderItem hospitalProductCheckOrderItem);

    /**
     * 修改采购单明细
     *
     * @param hospitalProductCheckOrderItem 采购单明细
     * @return 结果
     */
    public int updateHospitalProductCheckOrderItem(HospitalProductCheckOrderItem hospitalProductCheckOrderItem);

    /**
     * 删除采购单明细
     *
     * @param itemId 采购单明细主键
     * @return 结果
     */
    public int deleteHospitalProductCheckOrderItemByItemId(Long itemId);

    /**
     * 批量删除采购单明细
     *
     * @param itemIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalProductCheckOrderItemByItemIds(Long[] itemIds);
    @Select({"<script>     select i.*,p.product_name,p.product_code from hospital_product_check_order_item i  LEFT JOIN hospital_product p ON p.product_id=i.product_id  " +
            "<where>  \n" +
            "            <if test=\"orderId != null \"> and i.order_id = #{orderId}</if>\n" +
            "            <if test=\"hospitalId != null \"> and i.hospital_id = #{hospitalId}</if>\n" +
            "            <if test=\"productId != null \"> and i.product_id = #{productId}</if>\n" +
            "        </where> order by i.item_id desc"+
            "</script>"})
    List<HospitalProductCheckOrderItemListHVO> selectHospitalProductCheckOrderItemListPVO(HospitalProductCheckOrderItem hospitalProductCheckOrderItem);


}
