package com.yihu.figure.dao.health;

import com.yihu.figure.model.health.HealthEduArticle;
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.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface HealthEduArticleDao extends PagingAndSortingRepository<HealthEduArticle, Long>, JpaSpecificationExecutor<HealthEduArticle> {

	HealthEduArticle findByCode(String code);

	@Query("SELECT a FROM HealthEduArticle a WHERE (a.title like ?1 or a.keyword like ?2) ORDER BY a.czrq DESC")
	Page<HealthEduArticle> list(String title, String keyword, Pageable pageRequest);

	@Query("SELECT a FROM HealthEduArticle a WHERE  a.keyword like ?1 ORDER BY a.czrq DESC")
	List<HealthEduArticle> findByKeyword(String keyword);
}
