package com.yihu.jw.dict.dao;

import com.yihu.jw.entity.base.dict.BaseDrugUseDictDO;
import com.yihu.jw.entity.base.dict.BaseFollowUpDictDO;
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 BaseFollowUpDictDao extends PagingAndSortingRepository<BaseFollowUpDictDO, String>, JpaSpecificationExecutor<BaseFollowUpDictDO> {
    @Query("from BaseFollowUpDictDO t where t.code=?1 and t.name=?2")
    List<BaseFollowUpDictDO> findByCodeAndName(String code, String name);

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

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


    @Query("from BaseFollowUpDictDO t where t.isDel='1' and t.status='1' and t.code=?1")
    BaseFollowUpDictDO findByCode(String code);

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