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

import com.yihu.jw.entity.hospital.doctor.WlyyDoctorOnlineTimeDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.Date;
import java.util.List;

/**
 * Created by Trick on 2019/7/31.
 */
public interface WlyyDoctorOnlineTimeDao extends PagingAndSortingRepository<WlyyDoctorOnlineTimeDO, String>, JpaSpecificationExecutor<WlyyDoctorOnlineTimeDO> {

    @Query("from WlyyDoctorOnlineTimeDO a where a.doctor = ?1 and (a.startTime <= ?2 AND a.endTime <= ?2 )OR (a.startTime <= ?3 AND a.endTime <= ?3)")
    List<WlyyDoctorOnlineTimeDO> findWorkExistList(String doctor, Date startDate,Date endDate);

    @Query("from WlyyDoctorOnlineTimeDO a where a.doctor = ?1 and a.startTime >= ?2 AND a.startTime <= ?3 order By a.startTime ASC)")
    List<WlyyDoctorOnlineTimeDO> findWorkList(String doctor, Date startDate,Date endDate);
}
