using System;
using System.Collections.Generic;
using System.Linq;
using CB.Cache;
using CB.Entity;
namespace CB.Data
{
public partial class Caches
{
///
/// 获取专栏列表
///
///
public static IList GetColumnList()
{
var list = CB.Cache.CBCache.GetCacheService().GetObject(CB.Cache.CacheKeys.ColumnList) as IList;
if (null == list)
{
list = CB.Data.ColumnService.ToList();
CB.Cache.CBCache.GetCacheService().AddObject(CB.Cache.CacheKeys.ColumnList, list);
}
return list;
}
///
/// 根据专栏ID获取专栏信息
///
///
///
public static ColumnInfo GetColumnInfo(int id)
{
var list = GetColumnList();
if (null == list || 0 >= list.Count)
return null;
ColumnInfo entity = null;
foreach (var item in list)
{
if (id == item.Id && 0 < item.Status)
{
entity = item; break;
}
}
return entity;
}
///
/// 根据专栏URL重写获取专栏信息
///
///
///
public static ColumnInfo GetColumnInfo(string rewriteUrl)
{
var list = GetColumnList();
if (null == list || 0 >= list.Count)
return null;
ColumnInfo entity = null;
foreach (var item in list)
{
if (rewriteUrl == item.RewriteUrl && 0 < item.Status)
{
entity = item; break;
}
}
return entity;
}
///
/// 获取所属彩种所有专栏
///
///
///
public static IList GetColumnList(string lottery)
{
var list = GetColumnList();
if (null == list || 0 >= list.Count)
return null;
IList r = new List();
foreach (var item in list)
{
if (item.Lottery.Equals(lottery, StringComparison.CurrentCultureIgnoreCase))
{ r.Add(item); }
}
return r;
}
///
/// 获取所属彩种热门专栏
///
///
///
public static IList GetHotColumnList(string lottery)
{
var list = GetColumnList(lottery);
if (null == list || 0 >= list.Count)
return null;
return list.OrderByDescending(item => item.Status).ToList();
}
}
}