package com.ywt.mg.domain.entities;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;


public interface DoctorRepository extends JpaRepository<Doctor, Integer> {
    @Query(value = "SELECT * FROM doctor WHERE id = ? AND is_deleted  = 0 limit 1;",nativeQuery = true)
    Doctor findById(Integer id);

    /**
     * 判断是否关联某个医生
     * @param doctorId
     * @param unionDoctorId
     * @return
     */
    @Query(value = "SELECT COUNT(1) FROM union_doctor WHERE doctor_id = ? AND union_doctor_id = ? AND is_deleted =0 AND status = 1 limit 1",nativeQuery = true)
    int checkUnionDoctor(Integer doctorId, Integer unionDoctorId);

}
