/// <summary> /// 获取论坛下的版块 /// </summary> /// <param name="minisnsId"></param> /// <param name="pId">父级ID,0是一级版块</param> /// <param name="fromCache"></param> /// <returns></returns> public List <ArticleType> GetArticleTypeList(int minisnsId, int pId, bool fromCache = true) { string key = string.Format(MemCacheKey.Model_ArtTypeListLevel_Key, minisnsId, pId); int ver = RedisUtil.GetVersion(string.Format(minisnsTypeVer, minisnsId)); ArticleTypeCache _list = null; try { _list = RedisUtil.Get <ArticleTypeCache>(key); } catch (SerializationException) { _list = null; } if (_list == null || _list.Version != ver || null == _list._ArticleTypeList || _list._ArticleTypeList.Count == 0 || !fromCache) { _list = new ArticleTypeCache(); _list._ArticleTypeList = new ArticleTypeBll().GetList(string.Format("minisnsId={0} and pid={1} and state=1 and AppType=0", minisnsId, pId), 0, 0, "", " Sort DESC "); _list.Version = ver; if (_list._ArticleTypeList != null && _list._ArticleTypeList.Count > 0) { RedisUtil.Set(key, _list, TimeSpan.FromHours(24)); } } return(_list._ArticleTypeList); }
/// <summary> /// 查找同城下所有官方版块 /// </summary> /// <param name="minisnsId">0,代表所有同城一样的版块</param> /// <param name="pId"></param> /// <param name="fromCache"></param> /// <returns></returns> public List <ArticleType> GetCityAllTypes(int minisnsId, int pId, bool fromCache = true) { string key = string.Format(MemCacheKey.Model_ArtTypeListLevel_Key, minisnsId, pId); int ver = RedisUtil.GetVersion(string.Format(minisnsTypeVer, minisnsId)); ArticleTypeCache _list = RedisUtil.Get <ArticleTypeCache>(key); if (_list == null || _list.Version != ver || null == _list._ArticleTypeList || _list._ArticleTypeList.Count == 0 || !fromCache) { _list = new ArticleTypeCache(); _list._ArticleTypeList = GetList(string.Format("minisnsId={0} and pid={1} and state=1 and AppType=1", minisnsId, pId), 0, 0, "*", " Sort DESC "); _list.Version = ver; RedisUtil.Set(key, _list, TimeSpan.FromHours(24)); } return(_list._ArticleTypeList); }