using Hncore.Infrastructure.Data; using Hncore.Infrastructure.DDD; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using System.Data; using System.Linq.Expressions; using Microsoft.EntityFrameworkCore; using Hncore.Infrastructure.WebApi; using Hncore.Pass.Manage.Request; using Hncore.Pass.Manage.Domain; namespace Hncore.Pass.Manage.Response { public class QueryItemManagerResponse { /// /// 用户数据库ID /// public int Id { get; set; } /// /// 所属物业ID /// public int OwnerId { get; set; } /// /// 创建时间 /// public DateTime CreateTime { get; set; } /// /// 更新时间 /// public DateTime UpdateTime { get; set; } /// /// 删除标记 /// public int DeleteTag { get; set; } /// /// 管理员登录名 /// public string LoginCode { get; set; } /// /// 管理员手机号 /// public string Phone { get; set; } /// /// 头像地址 /// public string Photourl { get; set; } /// /// 项目关联 /// public string ProjectContact { get; set; } /// /// 管理员姓名 /// public string RealName { get; set; } public int Isroot { get; set; } public int RoleCode { get; set; } public List Permission =new List(); public List Domain = new List(); public static async Task Query( IQueryable ManagerQueryable , IQueryable ManagerToPermissionQueryable , IQueryable DomainQueryable , QueryByIdRequest param ) { var search = from dw in ManagerQueryable.Where(p => p.DeleteTag == 0 && p.Id == param.Id && p.TenantId == param.TenantId) join mtp in ManagerToPermissionQueryable.Where(p => p.DeleteTag == 0) on dw.Id equals mtp.ManagerId into Permissions select new { dw, Permissions }; var list = search.ToList(); QueryItemManagerResponse pm = new QueryItemManagerResponse(); foreach (var item in list) { pm.Id = item.dw.Id; pm.CreateTime = item.dw.CreateTime; pm.UpdateTime = item.dw.UpdateTime; pm.DeleteTag = item.dw.DeleteTag; pm.OwnerId = item.dw.TenantId; pm.LoginCode = item.dw.LoginCode; pm.RealName = item.dw.RealName; pm.Phone = item.dw.Phone; pm.Photourl = item.dw.PhotoUrl; pm.RoleCode = item.dw.RoleId; // pm.ProjectContact = item.dw.ProjectContact; foreach (var itemper in item.Permissions) { PermissionResponse mtp =new PermissionResponse() ; mtp.ManagerId = itemper.ManagerId; mtp.Id = itemper.Id; mtp.AllowAdd = itemper.AllowAdd; mtp.AllowDel = itemper.AllowDel; mtp.AllowEdit = itemper.AllowEdit; mtp.AllowView = itemper.AllowView; mtp.PermissionCode = itemper.PermissionCode; mtp.OwnerId = item.dw.TenantId; pm.Permission.Add(mtp); } } //var projectList= DomainQueryable.Where(p => p.DeleteTag == 0 && p.ManagerId == param.Id && p.TenantId == param.TenantId); //foreach(var project in projectList) //{ // pm.Domain.Add(new DomainResponse() { // Id= project.Id, // ProjectCode= project.ProjectCode // }); //} return pm; } } }