package com.yihu.jw.hospital.message.dao;

import com.yihu.jw.entity.hospital.message.BaseBannerDO;
import com.yihu.jw.entity.hospital.message.BaseBannerDoctorDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;
import java.util.Map;

/**
 * @author wangzhinan
 * @vsrsion 2.0
 * Created at 2020.07.08
 */
public interface BaseBannerDoctorDao extends PagingAndSortingRepository<BaseBannerDoctorDO, String>, JpaSpecificationExecutor<BaseBannerDoctorDO> {
    //获取医生获得锦旗总量的接口
    @Query( value = "SELECT COUNT(1) AS \"total\"  FROM base_banner_doctor a LEFT JOIN base_banner b on a.banner_id= b.id where a.doctor = ?1",nativeQuery = true)
    Integer getTotalBannerCount(String doctor);
    @Query( value = "SELECT * from base_banner_doctor t where t.doctor = ?1 and t.patient_id =?2 and t.relation_code =?3" ,nativeQuery = true)
    List<BaseBannerDoctorDO> getBanners(String doctor,String patientId,String relationCode);
    @Query("from BaseBannerDoctorDO t where t.patientId =?1 order by t.createTime desc ")
    List<BaseBannerDoctorDO> getBannersBypatients(String patientId);
    @Query("from BaseBannerDoctorDO t where t.patientId =?1 and t.doctor =?2 order by t.createTime desc ")
    public abstract List<BaseBannerDoctorDO> getBannersBypatients(String paramString1, String paramString2);

}
