package com.qmth.teachcloud.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qmth.teachcloud.common.bean.dto.OrgDto;
import com.qmth.teachcloud.common.entity.SysOrg;
import com.qmth.teachcloud.common.entity.SysUser;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * 学校组织架构 Mapper 接口
 * </p>
 *
 * @author xf
 * @since 2021-03-23
 */
public interface SysOrgMapper extends BaseMapper<SysOrg> {

    /**
     * 根据机构类型查找用户
     *
     * @param schoolId
     * @param orgId
     * @param orgTypeEnum
     * @return
     */
    List<SysUser> findUserByOrgType(@Param("schoolId") Long schoolId, @Param("orgId") Long orgId, @Param("orgTypeEnum") String orgTypeEnum);

    /**
     * 递归树查询(同级及以上)
     *
     * @param orgId
     * @param school
     * @param college
     * @return
     */
    List<SysOrg> findByConnectByParentId(@Param("orgId") Long orgId, @Param("school") Boolean school, @Param("college") Boolean college);

    /**
     * 递归树查询(同级及以上)
     *
     * @param orgId
     * @param orgType
     * @return
     */
    List<SysOrg> findByJxzyyConnectByParentId(@Param("orgId") Long orgId, @Param("orgType") String orgType);

    /**
     * 递归树查询(同级及以下)
     *
     * @param orgId
     * @return
     */
    List<SysOrg> findByConnectByRootOrgId(@Param("orgId") Long orgId);

    /**
     * 获取所有机构
     *
     * @param schoolId
     * @return
     */
    List<OrgDto> listOrgAll(@Param("schoolId") Long schoolId);
}
