package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalProduct;
import com.fs.hospital.param.HospitalOrderItemParam;
import com.fs.hospital.vo.HospitalOrderItemListHVO;
import com.fs.hospital.vo.HospitalProductListHVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 诊所商品Mapper接口
 *
 * @author fs
 * @date 2024-03-12
 */
public interface HospitalProductMapper
{
    /**
     * 查询诊所商品
     *
     * @param productId 诊所商品主键
     * @return 诊所商品
     */
    public HospitalProduct selectHospitalProductByProductId(Long productId);

    /**
     * 查询诊所商品列表
     *
     * @param hospitalProduct 诊所商品
     * @return 诊所商品集合
     */
    public List<HospitalProduct> selectHospitalProductList(HospitalProduct hospitalProduct);

    /**
     * 新增诊所商品
     *
     * @param hospitalProduct 诊所商品
     * @return 结果
     */
    public int insertHospitalProduct(HospitalProduct hospitalProduct);

    /**
     * 修改诊所商品
     *
     * @param hospitalProduct 诊所商品
     * @return 结果
     */
    public int updateHospitalProduct(HospitalProduct hospitalProduct);

    /**
     * 删除诊所商品
     *
     * @param productId 诊所商品主键
     * @return 结果
     */
    public int deleteHospitalProductByProductId(Long productId);

    /**
     * 批量删除诊所商品
     *
     * @param productIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalProductByProductIds(Long[] productIds);


    @Select({"<script> " +
            "select h.*  from hospital_product h    " +
            "where 1=1  " +
            "<if test = ' maps.hospitalId!=null  '> " +
            "and h.hospital_id = #{maps.hospitalId} " +
            "</if>" +
            "<if test = ' maps.productName!=null and maps.productName != \"\"  '> " +
            "and h.product_name like concat('%', #{maps.productName}, '%') " +
            "</if>" +
            " order by h.product_id desc "+
            "</script>"})
    List<HospitalProductListHVO> selectHospitalProductListPVO(@Param("maps") HospitalProduct hospitalProduct);

    @Select({"<script> " +
            "select h.product_id as id,h.product_name as name,h.unit,h.sell_price as price,h.sell_count as stock,4 as type  from hospital_product h    " +
            "where 1=1 and h.product_type IN (5, 6, 7, 8) " +
            "<if test = ' maps.hospitalId!=null  '> " +
            "and h.hospital_id = #{maps.hospitalId} " +
            "</if>" +
            "<if test = ' maps.cate!=null  '> " +
            "and h.product_type = #{maps.cate} " +
            "</if>" +
            "<if test = ' maps.keyword!=null and maps.keyword != \"\"  '> " +
            "and h.product_name like concat('%', #{maps.keyword}, '%') " +
            "</if>" +
            "</script>"})
    List<HospitalOrderItemListHVO> selectHospitalOrderItemListHVOList(@Param("maps") HospitalOrderItemParam param);
}
