1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- static List<ZtColumn> colInfoList;
- public static List<ZtColumn> TestGetList()
- {
- string key = string.Format(CacheKeys.Zt_Column);
- List<ZtColumn> list = cache.GetObject<List<ZtColumn>>(key) as List<ZtColumn>;
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<ZtColumn>("order by id asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- public static List<ZtColumn> GetList()
- {
- if (colInfoList != null)
- {
- return colInfoList;
- }
- else
- {
- string key = string.Format(CacheKeys.Zt_Column);
- List<ZtColumn> list = cache.GetObject<List<ZtColumn>>(key) as List<ZtColumn>;
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<ZtColumn>("where status>0 order by id asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- colInfoList = list;
- return list;
- }
- }
- public static List<ZtColumn> GetList(string lotteryCode)
- {
- if (lotteryCode.Equals(ZtLotteryEnum.fc3d.ToString()))
- lotteryCode = "3d";
- List<ZtColumn> list = GetList();
- if (list == null)
- {
- string key = string.Format(CacheKeys.Zt_Column);
- var dc = new DataConnect();
- list = dc.db.Fetch<ZtColumn>("where status>0 order by id asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list.Where(m => m.Lottery == lotteryCode).ToList() ?? new List<ZtColumn>();
- }
- /// <summary>
- /// 根据专栏URL重写获取专栏信息
- /// </summary>
- /// <param name="rewriteUrl"></param>
- /// <returns></returns>
- 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;
- }
- }
- }
|