using System.Collections.Generic;
using System.Threading.Tasks;
using GxPress.Entity;
using GxPress.Request.Department;
using GxPress.Result.Department;
using Datory;

namespace GxPress.Repository.Interface
{
    public interface IDepartmentRepository : IRepository
    {
        Task<bool> ExistsChildrenAsync(int parentId);

        Task<Department> GetAsync(int id);
        Task<Department> GetAsync(string name);

        Task<string> GetNameAsync(int id);

        Task<int> InsertAsync(Department department);

        Task<bool> UpdateAsync(Department department);

        Task<IEnumerable<Department>> GetListAsync(int parentId);

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<Department> AddAsync(Department request);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(int id);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        Task<bool> DeleteAsync(SqlKata.Query query);
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="id"></param>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<bool> UpdateAsync(int id, Department request);

        /// <summary>
        /// 获取树列表
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<List<DepartmentTreeResult>> GetTreeAsync(int id);
        /// <summary>
        /// 根据部门ID获取成员以及下级部门
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        Task<DepartmentUserResult> GetDepartmentUserResultAsync(DepartmentUserRequest request);
        /// <summary>
        /// 根据PID获取所用部门
        /// </summary>
        /// <param name="id"></param>
        /// <param name="departments"></param>
        /// <returns></returns>
        /// <summary>
        /// 获取所用下级部门
        /// </summary>
        /// <param name="id"></param>
        /// <param name="departments"></param>
        /// <returns></returns>
        Task<List<Department>> GetDepartmentById(int id, List<Department> departments);

        Task<string> GetDepartmentFullPathAsync(int departmentId, string departmentName);


        /// <summary>
        /// 获取所用下级部门
        /// </summary>
        /// <param name="id"></param>
        /// <param name="departments"></param>
        /// <returns></returns>
        Task<List<Department>> GetDepartmentByPid(int Pid, List<Department> departments);

        Task<IEnumerable<Department>> GetAllAsync(SqlKata.Query query);
    }
}