/// <summary> /// 获取模块列表 /// </summary> /// <param name="userID">用户ID</param> /// <returns></returns> public CheckReturn LoadModules(int userID) { if (!UserInfoRepository.IsExists(u => u.ID == userID)) { return(new CheckReturn { Message = "用户不存在", Flag = false }); } var modules = ModuleRepository.LoadEntities(c => true, true) .Select(r => new { ID = r.ID, Name = r.Name }).ToDictionary(key => key.ID, value => value.Name); int[] ids = ModuleUserInfoRepository.LoadModuleIDs(userID); int[] roleIDs = RoleUserInfoRepository .LoadEntities(r => r.UserInfoID == userID) .Select(r => r.RoleID) .ToArray(); ids = RoleModuleRepository .LoadEntities(r => roleIDs.Contains(r.RoleID)) .Select(r => r.ModuleID) .Union(ids).ToArray(); return(new CheckReturn { Flag = true, Message = "获取成功", dics = modules, IDs = ids }); }
/// <summary> /// 获取模块列表 /// </summary> /// <param name="roleID">角色ID</param> /// <returns>角色模块列表</returns> public CheckReturn LoadModules(int roleID) { if (!CurrentRepository.IsExists(u => u.ID == roleID)) { return(new CheckReturn { Message = "角色不存在", Flag = false }); } var modules = ModuleRepository.LoadEntities(c => true, true) .Select(r => new { ID = r.ID, Name = r.Name }).ToDictionary(key => key.ID, value => value.Name); int[] ids = RoleModuleRepository.LoadEntities(r => r.RoleID == roleID) .Select(r => r.ModuleID) .ToArray(); return(new CheckReturn { Flag = true, Message = "获取成功", dics = modules, IDs = ids }); }