package com.yihu.jw.hospital.drugstore.dao;

import com.yihu.jw.entity.base.area.BaseDrugStoreDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface BaseDrugStoreDao extends PagingAndSortingRepository<BaseDrugStoreDO, String>, JpaSpecificationExecutor<BaseDrugStoreDO> {
    @Query(value = " from  BaseDrugStoreDO  where (drugStoreName like %?1% or ?1 is null ) or ( hospitalName like %?1% or ?1 is null) and isDel = 1 and isUsed= '1'")
    List<BaseDrugStoreDO> findDrugByName(String storeName);

    @Query(value = " from  BaseDrugStoreDO  where drugStoreCode =?1 and hospitalCode = ?2  and isDel = '1'")
    BaseDrugStoreDO findDrugByNameAndCode(String drugStoreCode,String hospitalCode);

    @Query(value = " from  BaseDrugStoreDO  where id =?1  ")
    BaseDrugStoreDO findDrugByid(String drugStoreCode);
    @Query(value = " from  BaseDrugStoreDO  where id =?1 and isDel = 1 and isUsed ='1'")
    BaseDrugStoreDO findDrugByidAndIsUsed(String drugStoreCode);


}
