/// <summary> /// 得到图片 /// </summary> /// <param name="model"></param> /// <returns></returns> protected virtual IList <TemplateEntity> GetTemplates(TemplateListModel model) { var query = new QueryInfo(); query.SetPageIndex(model.PageIndex).SetPageSize(model.PageSize).Query <TemplateEntity>(). Where(it => it.Account.Id == Identity.Id) .Select(it => new object[] { it.Id, it.Name }); if (!string.IsNullOrWhiteSpace(model.FolderId)) { query.AppendWhere("Folder.Id==@FolderId").SetParameter("FolderId", model.FolderId.Convert <long>()); } var infos = this.GetEntities <TemplateEntity>(query); model.DataCount = query.DataCount; return(infos); }
/// <summary> /// 得到标签 /// </summary> /// <returns></returns> protected virtual IList <FolderEntity> GetFolders(FolderListModel model) { var query = new QueryInfo(); query.SetPageIndex(model.PageIndex).SetPageSize(model.PageSize).Query <FolderEntity>() .Where(it => it.Account.Id == Identity.Id) .Select(it => new object[] { it.Id, it.Name, it.Type, it.Sequence }); if (!string.IsNullOrWhiteSpace(model.Name)) { query.AppendWhere("Name.Contains(@Name)").SetParameter("Name", model.Name); } var infos = this.GetEntities <FolderEntity>(query); model.DataCount = query.DataCount; return(infos); }
/// <summary> /// 根据角色加载菜单 /// </summary> /// <param name="subSystemUrl"></param> /// <param name="roleIds"></param> /// <returns></returns> public virtual IList <MenuEntity> GetMenus(long[] roleIds, string subSystemUrl) { var result = new Dictionary <long, MenuEntity>(); foreach (var roleId in roleIds) { var key = GetRoleMenuCacheKey(roleId, subSystemUrl); var infos = CacheRepository.Get <IList <MenuEntity> >(key); if (infos == null) { var query = new QueryInfo(); query.Query <MenuEntity>().Where(it => ( !it.Abilities.Any() || it.Abilities.Count(m => m.IsVerify == false && m.RoleAbilities.Count(r => r.Role.Id == roleId) == 0) > 0 || it.Abilities.Count(m => m.RoleAbilities.Count(r => r.Role.Id == roleId) > 0) > 0 ) && it.IsShow).OrderBy(it => it.Sequence) .Select(it => new object[] { it, it.Subsystem.Url, it.Parent }); if (!string.IsNullOrWhiteSpace(subSystemUrl)) { var urlName = ConfigurationManager.GetSetting <string>(subSystemUrl); query.AppendWhere <MenuEntity>( it => (it.Subsystem.Url == subSystemUrl || it.Subsystem.Url == urlName)); } infos = Repository.GetEntities <MenuEntity>(query); CacheRepository.Set(key, infos, DateTime.MaxValue); } if (infos != null) { foreach (var info in infos) { if (!result.ContainsKey(info.Id)) { result.Add(info.Id, info); } } } } return(result.Values.ToList()); }