|
|
|
@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Platform.ViewModels;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace Platform.Controllers
|
|
|
|
@ -44,12 +45,27 @@ namespace Platform.Controllers
|
|
|
|
|
public IActionResult Building(HomeModel model)
|
|
|
|
|
{
|
|
|
|
|
var userOrganId = User.GetOrganId().Value;//当前用户机构Id
|
|
|
|
|
var currentOrgan = this._organRepo.ReadOnlyTable().FirstOrDefault(o => o.Id == userOrganId);//当前用户机构
|
|
|
|
|
var organList = this._organRepo.ReadOnlyTable()//当前用户机构及下级机构
|
|
|
|
|
.Where(o => o.ParentId != null)
|
|
|
|
|
.Where(o => o.Left >= currentOrgan.Left && o.Right <= currentOrgan.Right)
|
|
|
|
|
.Include(o => o.Buildings)
|
|
|
|
|
var userOrgans = this._userRepo.ReadOnlyTable()
|
|
|
|
|
.Where(o=>o.UserName==User.Identity.Name)
|
|
|
|
|
.SelectMany(o => o.OrganUsers)
|
|
|
|
|
.Select(o => o.Organ)
|
|
|
|
|
.ToList();
|
|
|
|
|
var organList = new List<Organ>();
|
|
|
|
|
foreach (var item in userOrgans)
|
|
|
|
|
{
|
|
|
|
|
var userOrganList = this._organRepo.ReadOnlyTable()//当前用户机构及下级机构
|
|
|
|
|
.Where(o => o.ParentId != null)
|
|
|
|
|
.Where(o => o.Left >= item.Left && o.Right <= item.Right)
|
|
|
|
|
.Include(o => o.Buildings)
|
|
|
|
|
.ToList();
|
|
|
|
|
organList.AddRange(userOrganList);
|
|
|
|
|
}
|
|
|
|
|
var currentUserOrgan = this._organRepo.ReadOnlyTable().FirstOrDefault(o => o.Id == userOrganId);//当前用户机构
|
|
|
|
|
//var organList = this._organRepo.ReadOnlyTable()//当前用户机构及下级机构
|
|
|
|
|
// .Where(o => o.ParentId != null)
|
|
|
|
|
// .Where(o => o.Left >= currentUserOrgan.Left && o.Right <= currentUserOrgan.Right)
|
|
|
|
|
// .Include(o => o.Buildings)
|
|
|
|
|
// .ToList();
|
|
|
|
|
organList.ToTree();
|
|
|
|
|
var rootOrganId = this._organRepo.ReadOnlyTable().Where(o => o.Number == "root").Select(o => o.Id).FirstOrDefault();
|
|
|
|
|
model.Organs = organList.Where(o => o.Parent == null).ToList();
|
|
|
|
|