using MilitaryTrainingManagement.Models.Entities;
using MilitaryTrainingManagement.Models.Enums;

namespace MilitaryTrainingManagement.Services.Interfaces;

/// <summary>
/// 组织管理服务接口
/// </summary>
public interface IOrganizationService
{
    Task<OrganizationalUnit?> GetByIdAsync(int id);
    Task<IEnumerable<OrganizationalUnit>> GetAllAsync();
    Task<IEnumerable<OrganizationalUnit>> GetSubordinatesAsync(int unitId);
    Task<IEnumerable<int>> GetAllSubordinateIdsAsync(int unitId);
    Task<IEnumerable<int>> GetAllAncestorIdsAsync(int unitId);
    Task<OrganizationalUnit> CreateAsync(string name, OrganizationalLevel level, int? parentId);
    Task<OrganizationalUnit> UpdateAsync(int id, string name);
    Task DeleteAsync(int id);
    Task<bool> IsSubordinateOfAsync(int unitId, int potentialParentId);
    Task<bool> IsUnitOrSubordinateAsync(int userUnitId, int targetUnitId);
    Task<bool> IsParentUnitAsync(int parentUnitId, int childUnitId);
    
    /// <summary>
    /// 获取用户可见的单位ID列表
    /// 营部及以下级别：本单位 + 直接下级
    /// 师团级别：本单位 + 所有下级
    /// </summary>
    /// <param name="unitId">用户所属单位ID</param>
    /// <param name="userLevel">用户的组织层级</param>
    /// <returns>可见的单位ID列表</returns>
    Task<IEnumerable<int>> GetVisibleUnitIdsAsync(int unitId, OrganizationalLevel userLevel);
}
