package com.yihu.wlyy.repository.education;

import com.yihu.wlyy.entity.education.HealthEduArticle;
import com.yihu.wlyy.entity.education.HealthEduArticleDoctor;
import com.yihu.wlyy.entity.education.HealthEduArticlePatient;
import org.json.JSONArray;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface HealthEduArticleDoctorDao extends PagingAndSortingRepository<HealthEduArticleDoctor, Long>, JpaSpecificationExecutor<HealthEduArticleDoctor> {
	HealthEduArticleDoctor findByArticleAndDoctor(String article,String doctor);

	int deleteByArticleAndDoctor(String article,String doctor);

	@Query("SELECT b FROM HealthEduArticleDoctor a ,HealthEduArticle b where b.code = a.article and a.doctor =?1 ORDER BY a.czrq DESC")
	List<Object> list(String doctor,Pageable pageRequest);

	@Query("SELECT b FROM HealthEduArticleDoctor a ,HealthEduArticle b where b.code = a.article and (a.title like ?1 or b.keyword like?2) and a.doctor =?3 ORDER BY a.czrq DESC")
	List<Object> listFilter(String title,String keyword,String doctor,Pageable pageRequest);
}
