package com.fs.hospital.mapper;

import java.util.List;
import com.fs.hospital.domain.HospitalStore;
import com.fs.hospital.param.HospitalStoreParam;
import com.fs.hospital.vo.HospitalStoreHVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 诊所供应商关联Mapper接口
 *
 * @author fs
 * @date 2024-03-12
 */
public interface HospitalStoreMapper
{
    /**
     * 查询诊所供应商关联
     *
     * @param id 诊所供应商关联主键
     * @return 诊所供应商关联
     */
    public HospitalStore selectHospitalStoreById(Long id);

    /**
     * 查询诊所供应商关联列表
     *
     * @param hospitalStore 诊所供应商关联
     * @return 诊所供应商关联集合
     */
    public List<HospitalStore> selectHospitalStoreList(HospitalStore hospitalStore);

    /**
     * 新增诊所供应商关联
     *
     * @param hospitalStore 诊所供应商关联
     * @return 结果
     */
    public int insertHospitalStore(HospitalStore hospitalStore);

    /**
     * 修改诊所供应商关联
     *
     * @param hospitalStore 诊所供应商关联
     * @return 结果
     */
    public int updateHospitalStore(HospitalStore hospitalStore);

    /**
     * 删除诊所供应商关联
     *
     * @param id 诊所供应商关联主键
     * @return 结果
     */
    public int deleteHospitalStoreById(Long id);

    /**
     * 批量删除诊所供应商关联
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteHospitalStoreByIds(Long[] ids);

    @Select({"<script> " +
            "select hs.*,fs.store_name  from hospital_store hs    " +
            "left join fs_store fs on fs.store_id = hs.store_id " +
            "where 1=1  " +
            "<if test = ' maps.hospitalId!=null  '> " +
            "and hs.hospital_id = #{maps.hospitalId} " +
            "</if>" +
            "<if test = ' maps.storeName!=null and maps.storeName != \"\"  '> " +
            "and fs.store_name like concat('%', #{maps.storeName}, '%') " +
            "</if>" +
            "<if test = ' maps.status!=null  '> " +
            "and hs.status = #{maps.status} " +
            "</if>" +
            "<if test = ' maps.linkUserName!=null and maps.linkUserName!= \"\"  '> " +
            "and hs.link_user_name = #{maps.linkUserName} " +
            "</if>" +
            "<if test = ' maps.linkUserPhone!=null and maps.linkUserPhone!= \"\"  '> " +
            "and hs.link_user_phone = #{maps.linkUserPhone} " +
            "</if>" +
            " order by hs.create_time desc "+
            "</script>"})
    List<HospitalStoreHVO> selectHospitalStoreListPVO(@Param("maps") HospitalStoreParam param);
}
