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.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 BaseDictIcd10Dao extends PagingAndSortingRepository<DictIcd10DO, Integer>, JpaSpecificationExecutor<DictIcd10DO> {
    List<DictIcd10DO>  findByCodeAndName(String code, String name);

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


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

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

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


}
