package com.yihu.jw.base.dao.org;

import com.yihu.jw.entity.base.org.BaseOrgUserDO;
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.Set;


/**
 * 
 * 机构与机构管理员关联信息 数据库访问层
 * 
 * @version 
 * <pre>
 * Author	Version		Date		Changes
 * litaohong 	1.0  		2018年10月20日 	Created
 *
 * </pre>
 * @since 1.
 */
public interface BaseOrgUserDao extends PagingAndSortingRepository<BaseOrgUserDO, String>, JpaSpecificationExecutor<BaseOrgUserDO>  {

    List<BaseOrgUserDO> findAllByOrgCode(String orgCode);


    @Query("select id from BaseOrgUserDO where userId = ?1")
    Set<Object> findIdListByUserId(String userId);

    @Query("select orgCode from BaseOrgUserDO where userId = ?1")
    Set<String> findorgCodeListByUserId(String userId);

    @Query("select userId from BaseOrgUserDO where userId = ?1")
    List<BaseOrgUserDO> findAllByUserId(String userId);

    @Query("select orgCode from BaseOrgUserDO where orgCode = ?1 and userId =?2")
    BaseOrgUserDO getBaseOrgUserByOrgCodeAndUserid(String orgCode,String userId);
}