package com.yihu.jw.dict.dao;

import com.yihu.jw.entity.base.dict.BaseDrugDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
import com.yihu.jw.entity.base.dict.DictJobTitleDO;
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 BaseDrugDictDao  extends PagingAndSortingRepository<BaseDrugDictDO, String>, JpaSpecificationExecutor<BaseDrugDictDO> {
    @Query("from BaseDrugDictDO t where t.charge_code=?1 and t.drugname=?2 and t.dosage=?3")
    List<BaseDrugDictDO>  findByCodeAndNameAndDosage(String code,String name,String dosage);

    @Query("from BaseDrugDictDO t where t.charge_code=?1 and t.is_del='1'")
    List<BaseDrugDictDO>  findByChargeCode(String code);

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

    @Query("from BaseDrugDictDO t where t.is_del='1' and t.status='1' and t.drugname like %?1%  and t.charge_code like %?2% order by  t.create_time desc")
    List<BaseDrugDictDO> findByNameDel(String name,String code ,Pageable pageRequest);


    @Query("from BaseDrugDictDO t where t.is_del='1' and t.status='1' and t.charge_code=?1")
    BaseDrugDictDO findByCode(String code);


}
