//----------SysDept开始----------
using System.Threading.Tasks;
using System.Collections.Generic;
using SqlSugar;
using System.Linq;
using Admin.Core.IRepository.ISys;
using Admin.Core.Model.Sys;
namespace Admin.Core.Repository.Sys
{
///
/// 部门表Repository
///
public class SysDeptRepository : BaseRepository, ISysDeptRepository
{
public SysDeptRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
///
/// 根据ID查询所有子部门(正常状态)
///
/// 部门ID
/// 子部ID及当前选中节点部门ID的List
public async Task> SelectNormalChildrenIDsById(int deptId)
{
var children = await SelectChildrenDeptById(deptId);
var childrenIds = children.Select(x => x.DeptID).ToList();
childrenIds.Add(deptId);
return childrenIds;
}
///
/// 获取所有子节点
///
///
///
public async Task> SelectChildrenDeptById(int deptId)
{
var sql = @"EXEC [dbo].[Pro_Dept_ChildrenByID] @DeptID";
SugarParameter[] parameters = new SugarParameter[]
{
new SugarParameter("@DeptID", deptId)
};
return await QuerySqlAsync(sql, parameters);
}
}
}
//----------SysDept结束----------