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

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

import java.util.List;

/**
 * @author wangzhinan
 * @vsrsion 2.0
 * Created at 2020.07.08
 */
public interface BaseUserMessageDao extends PagingAndSortingRepository<BaseUserMessageDO, String>, JpaSpecificationExecutor<BaseUserMessageDO> {
    @Query(value = "select count(1) AS \"all\" from base_user_message t where t.receiver = ?1 order by t.update_time desc ",nativeQuery = true)
    Integer getAllMessageTotalCount(String doctor);
    @Query(value = "select count(1) AS \"notRead\" from base_user_message t where t.receiver = ?1 and t.is_read = 0 order by t.update_time desc ",nativeQuery = true)
    Integer getMessageNotReadCount(String doctor);
    @Query(value = "select *  from base_user_message t where t.receiver = ?1 and t.is_read = 0 order by t.update_time desc",nativeQuery = true)
    List<BaseUserMessageDO> getMessageNotReadNotPage(String doctor);
    @Query("from BaseUserMessageDO p where p.receiver=?1 and p.sender=?2 order by p.createTime desc ")
    public abstract List<BaseUserMessageDO> getMessageByPatientAndDoctor(String paramString1, String paramString2);



}
