/// <summary>
/// 查询项目列表
/// </summary>
/// <param name="userModel"></param>
/// <returns></returns>
public async Task<List<GetProjectListOutput>> GetProjectList(GetProjectListInput model,TokenModel userModel)
{
var allList = await UserDB.Queryable<File_Project>().Where(x => x.IsDelete == 0)
.WhereIF(!string.IsNullOrWhiteSpace(model.SearchValue), x => x.ProjectName.Contains(model.SearchValue))
.Select(x => new GetProjectListOutput
{
IID = x.IID,
ProjectName = x.ProjectName,
Pjt_No= x.Pjt_No,
Pjt_Orderno = x.Pjt_Orderno,
DrawingNo = x.DrawingNo,
ProductName = x.ProductName,
Parent_iid=x.Parent_iid,
}).ToListAsync();
var tree = BuildProjectTree(allList, 0);
return tree;
}
/// <summary>
/// 树结构查询
/// </summary>
/// <param name="allProjectList"></param>
/// <param name="parentID"></param>
/// <returns></returns>
public static List<GetProjectListOutput> BuildProjectTree(List<GetProjectListOutput> allProjectList, long parentID)
{
return allProjectList
.Where(d => d.Parent_iid == parentID)
.Select(d =>
{
d.children = BuildProjectTree(allProjectList, d.IID);
return d;
})
.ToList();
}