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

import com.yihu.jw.entity.hospital.doctor.WlyyDoctorWorkTimeDO;
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/5/31.
 */
public interface DoctorWorkTimeDao extends PagingAndSortingRepository<WlyyDoctorWorkTimeDO, String>, JpaSpecificationExecutor<WlyyDoctorWorkTimeDO> {

    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.endTime > ?2 and a.endTime < ?3 order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTime(String doctor, Date startTime, Date endTime);

    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.date like ?2 order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTimeByMonth(String doctor, String date);

    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.startTime >= ?2 and a.startTime <= ?3 order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTimeByTime(String doctor, Date startDate,Date endDate);


    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.startTime >= ?2 and a.endTime <= ?3 order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTimeByDate(String doctor, Date startTime, Date endTime);

    @Query("from WlyyDoctorWorkTimeDO a where a.doctor = ?1 and a.createUserType =?2  order by a.startTime asc")
    List<WlyyDoctorWorkTimeDO> findDoctorWorkTime(String doctor,Integer createUserType);

}
