package com.yihu.jw.dict.dao;

import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFrequencyDictDO;
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 BaseFrequencyDictDao extends PagingAndSortingRepository<BaseFrequencyDictDO, String>, JpaSpecificationExecutor<BaseFrequencyDictDO> {
    @Query("from BaseFrequencyDictDO t where  t.freq_code=?1 and t.freq_name=?2")
    List<BaseFrequencyDictDO>  findByCodeAndIdName(String code, String name);
    @Query("from BaseFrequencyDictDO t where t.is_del='1' and t.status ='1' order by t.createTime desc")
    List<BaseFrequencyDictDO> findByDel(Pageable pageRequest);
    @Query("select  count(1) from BaseFrequencyDictDO t where t.is_del='1' and t.status='1'")
    Integer getconuntByDel();

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


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

    @Query("from BaseFrequencyDictDO t where t.freq_code=?1 and t.is_del='1'")
    List<BaseFrequencyDictDO>  findByFrqCode(String code);
}
