package com.ga.core.mapper.org;

import com.ga.core.vo.org.OrganizationResp;
import com.ga.core.vo.org.OrganizationVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface OrganizationMapper {
    List<OrganizationResp> selectAllForTree();
    List<OrganizationResp> selectList(@Param("keyword") String keyword,
                                      @Param("orgType") String orgType,
                                      @Param("isActive") String isActive);
    OrganizationVO selectById(@Param("orgId") Long orgId);
    /** 자기 자신 + 모든 하위 조직 ID (CTE 재귀) */
    List<Long> selectDescendantIds(@Param("orgId") Long orgId);
    /** 자기 자신 + 모든 상위 조직 ID (root 까지, 가까운 순) */
    List<Long> selectAncestorIds(@Param("orgId") Long orgId);
    int insert(OrganizationVO vo);
    int update(OrganizationVO vo);
    int deleteById(@Param("orgId") Long orgId);
    int countChildren(@Param("orgId") Long orgId);
    int countAgents(@Param("orgId") Long orgId);
}
