package com.yihu.jw.team;

import com.yihu.jw.entity.base.team.BaseTeamMemberDO;
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;
import java.util.Set;

/**
 * 
 * 团队成员 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年08月31日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseDoctorTeamMemberDao extends PagingAndSortingRepository<BaseTeamMemberDO, String>, JpaSpecificationExecutor<BaseTeamMemberDO>  {

    @Query("select doc.name as name,doc.idcard as idcard ,doc.id as doctorCode from BaseDoctorDO doc where doc.id in (select team.doctorCode from BaseTeamMemberDO team where team.teamCode = ?1)")
    List<Map<String,Object>> getTeamMemberList(String teamCode);

    @Query("select id from BaseTeamMemberDO where teamCode = ?1")
    Set<Object> findIdListByTeamCode(String teamCode);

    List<BaseTeamMemberDO> findByTeamCode(String teamCode);
    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.del ='1'")
    List<BaseTeamMemberDO> findUseDoctorCode(String doctorCode);

    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.del ='1'")
    List<BaseTeamMemberDO> findUseDoctorCodeAndDel(String doctorCode);


    @Query("from BaseTeamMemberDO  t where t.doctorCode = ?1 and t.teamCode=?2 and t.del ='1'")
    BaseTeamMemberDO findUseDoctorCodeAndTeamCode(String doctorCode, String teamCode);
}