/// <summary> /// 获取用户选择已经拥有的权限 /// </summary> /// <param name="UserID"></param> /// <returns></returns> public ModuleDTOList GetUserPermission(Guid UserID) { ModuleDTOList mdtolist = new ModuleDTOList(); var user = userRepository.Find(Specification <User> .Eval(u => u.Status == Wings.Domain.Model.Status.Active).And(Specification <User> .Eval(u => u.ID.Equals(UserID)))); if (user == null) { return(null); } //添加用户组模块 user.Groups.ForEach(g => { if (g.Status.Equals(Wings.Domain.Model.Status.Active)) { g.Modules.ForEach( m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); } }); user.Roles.FindAll(t => t.Status == Wings.Domain.Model.Status.Active).ForEach(r => { r.Modules.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); }); user.ModuleAllow.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); //去除重复项 ModuleDTOList resultmdtolist = new ModuleDTOList(); mdtolist.GroupBy(m => m.ID).ToList().ForEach(m => { resultmdtolist.Add(mdtolist.Find(mt => mt.ID == m.Key)); }); //去除禁用的 user.ModuleBan.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { if (resultmdtolist.Contains(Mapper.Map <Module, ModuleDTO>(m))) { resultmdtolist.Remove(Mapper.Map <Module, ModuleDTO>(m)); } }); return(resultmdtolist.ToViewModel()); }
public ModuleDTOList GetModuleByParentID(Guid parentid) { ModuleDTOList dtolist = new ModuleDTOList(); var modules = moduleRepository.GetAll(Specification <Module> .Eval(m => m.ParentModule.ID.Equals(parentid))); foreach (var item in modules) { dtolist.Add(Mapper.Map <Module, ModuleDTO>(item)); } return(dtolist.ToViewModel()); }
/// <summary> /// 非树形排列 /// </summary> /// <param name="webid"></param> /// <returns></returns> public ModuleDTOList GetAllWebModules(Guid webid, bool IsMix = false) { ModuleDTOList dtolist = new ModuleDTOList(); var modules = IsMix ? moduleRepository.GetAll(Specification <Module> .Eval(m => m.Web.ID.Equals(webid))) : moduleRepository.GetAll(Specification <Module> .Eval(m => m.Web.ID.Equals(webid)).And(Specification <Module> .Eval(m => m.ParentModule == null))); foreach (var item in modules) { dtolist.Add(Mapper.Map <Module, ModuleDTO>(item)); } return(dtolist.ToViewModel()); }
public void DeleteModule(IDList moduleids) { ModuleDTOList moduledtolist = new ModuleDTOList(); moduleids.ForEach(s => { moduledtolist.Add(new ModuleDTO() { ID = s }); }); PerformUpdateObjects <ModuleDTOList, ModuleDTO, Module>(moduledtolist, moduleRepository, w => w.ID, (w, wdto) => { w.Status = Wings.Domain.Model.Status.Deleted; }); }
public List <Permission> GetPermissionByUserID(Guid accountid, Guid webid, bool IsAdmin = false) { List <Permission> plist = new List <Permission>(); ModuleDTOList mdtolist = new ModuleDTOList(); var user = userRepository.Find(Specification <User> .Eval(u => u.Status == Wings.Domain.Model.Status.Active).And(Specification <User> .Eval(u => u.ID.Equals(accountid)))); if (user == null) { return(plist); } ModuleDTOList resultmdtolist = new ModuleDTOList(); if (IsAdmin) { var web = webRepository.Get(Specification <Web> .Eval(w => w.ID.Equals(webid))); if (web != null && web.Modules != null) { web.Modules.ForEach(m => { resultmdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); } } else { //添加用户组模块 user.Groups.ForEach(g => { if (g.Status.Equals(Wings.Domain.Model.Status.Active)) { g.Modules.ForEach( m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); } }); user.Roles.FindAll(t => t.Status == Wings.Domain.Model.Status.Active).ForEach(r => { r.Modules.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); }); user.ModuleAllow.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { mdtolist.Add(Mapper.Map <Module, ModuleDTO>(m)); }); //去除重复项 mdtolist.GroupBy(m => m.ID).ToList().ForEach(m => { resultmdtolist.Add(mdtolist.Find(mt => mt.ID == m.Key)); }); //去除禁用的 user.ModuleBan.FindAll(m => m.Status == Wings.Domain.Model.Status.Active).ForEach(m => { //if (resultmdtolist.Contains(Mapper.Map<Module, ModuleDTO>(m))) //{ resultmdtolist.RemoveAll(mm => mm.ID.Equals(Mapper.Map <Module, ModuleDTO>(m).ID)); //} }); } resultmdtolist.ForEach(r => plist.Add(Mapper.Map <ModuleDTO, Permission>(r))); return(plist); }