1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System;
- using System.Collections.Generic;
- using CB.Cache;
- using CB.Entity;
- namespace CB.Data
- {
- public partial class Caches
- {
- /// <summary>
- /// 页面推荐列表 热点推荐列表
- /// </summary>
- /// <returns></returns>
- public static IList<RecommendInfo> GetRecommendList()
- {
- var cache = CBCache.GetCacheService();
- IList<RecommendInfo> list = cache.GetObject(CacheKeys.RecommendList) as IList<RecommendInfo>;
- if (null == list)
- {
- list = RecommendsService.ToList();
- cache.AddObject(CacheKeys.RecommendList, list);
- }
- return list;
- }
- /// <summary>
- /// 获取推荐信息 热点推荐
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public static RecommendInfo GetRecommend(int id)
- {
- var list = GetRecommendList();
- if (null == list || 0 >= list.Count)
- return null;
- RecommendInfo entity = null;
- foreach (var item in list)
- {
- if (id == item.Id)
- { entity = item; break; }
- }
- return entity;
- }
- /// <summary>
- /// 获取推荐内容 热点内容
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public static string GetRecommendContent(int id)
- {
- var entity = GetRecommend(id);
- return null == entity ? "" : entity.Content;
- }
- }
- }
|