package com.qmth.paper.library.common.mapper;

import com.qmth.paper.library.common.base.CustomBaseMapper;
import com.qmth.paper.library.common.bean.dto.OrgDto;
import com.qmth.paper.library.common.entity.SysOrg;
import org.apache.ibatis.annotations.Param;

import java.util.List;

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

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

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

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

    List<SysOrg> findByConnectByRootOrgIdAndType(@Param("orgId") Long orgId, @Param("orgType") String orgType);

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