You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//----------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
{
/// <summary>
/// 部门表Repository
/// </summary>
public class SysDeptRepository : BaseRepository<SysDept>, ISysDeptRepository
{
public SysDeptRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
{
}
/// <summary>
/// 根据ID查询所有子部门正常状态
/// </summary>
/// <param name="deptId"> 部门ID </param>
/// <returns> 子部ID及当前选中节点部门ID的List </returns>
public async Task<List<int>> SelectNormalChildrenIDsById(int deptId)
{
var children = await SelectChildrenDeptById(deptId);
var childrenIds = children.Select(x => x.DeptID).ToList();
childrenIds.Add(deptId);
return childrenIds;
}
/// <summary>
/// 获取所有子节点
/// </summary>
/// <param name="deptId"></param>
/// <returns></returns>
public async Task<List<SysDept>> 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结束----------