package com.yihu.jw.dict.dao;

import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.DictIcd10DO;
import org.springframework.data.domain.Pageable;
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 BaseDrugUseDictDao extends PagingAndSortingRepository<BaseDrugUseDictDO, String>, JpaSpecificationExecutor<BaseDrugUseDictDO> {
    @Query("from BaseDrugUseDictDO t where t.supply_code=?1 and t.supply_name=?2")
    List<BaseDrugUseDictDO>  findByCodeAndName(String code, String name);

    @Query("from BaseDrugUseDictDO t where t.del_flag='1' and t.status ='1' order by t.createTime desc")
    List<BaseDrugUseDictDO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from BaseDrugUseDictDO t where t.del_flag='1' and t.status='1'")
    Integer getconuntByDel();

    @Query("from BaseDrugUseDictDO t where t.del_flag='1' and t.status ='1' and t.supply_name like %?1% and t.sort_code like %?2% order by t.createTime desc")
    List<BaseDrugUseDictDO> findByNameDel(String name,String code,Pageable pageRequest);


    @Query("from BaseDrugUseDictDO t where t.del_flag='1' and t.status='1' and t.supply_code=?1")
    BaseDrugUseDictDO findByCode(String code);

    @Query("from BaseDrugUseDictDO t where t.supply_code=?1 and t.del_flag='1'")
    List<BaseDrugUseDictDO>  findBySupCode(String code);
}
