using CP.Cache; using CP.Model; using MC.ORM; using MySql.Data.MySqlClient; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CP.Business { public class ZtColumnBll : BaseBll { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); static List colInfoList; public static List TestGetList() { string key = string.Format(CacheKeys.Zt_Column); List list = cache.GetObject>(key) as List; if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("order by id asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list; } public static List GetList() { if (colInfoList != null) { return colInfoList; } else { string key = string.Format(CacheKeys.Zt_Column); List list = cache.GetObject>(key) as List; if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("where status>0 order by id asc"); cache.AddObject(key, list, (int)CacheTime.System); } colInfoList = list; return list; } } public static List GetList(string lotteryCode) { if (lotteryCode.Equals(ZtLotteryEnum.fc3d.ToString())) lotteryCode = "3d"; List list = GetList(); if (list == null) { string key = string.Format(CacheKeys.Zt_Column); var dc = new DataConnect(); list = dc.db.Fetch("where status>0 order by id asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list.Where(m => m.Lottery == lotteryCode).ToList() ?? new List(); } /// /// 根据专栏URL重写获取专栏信息 /// /// /// public static ZtColumn GetBy(string rewriteUrl) { var list = GetList(); if (list == null || list.Count == 0) return null; ZtColumn entity = null; foreach (var item in list) { if (rewriteUrl == item.RewriteUrl && item.Status > 0) { entity = item; break; } } return entity; } } }