123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using CP.Cache;
- using CP.Model;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CP.Business
- {
- /// <summary>
- /// 菜单相关的逻辑操作类
- /// </summary>
- public class ChartBll
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- #region menus
- /// <summary>
- /// cache中的所有menus list
- /// </summary>
- /// <returns></returns>
- public static List<Chart> GetList()
- {
- string key = string.Format(CacheKeys.SYSTEM_MENUS);
- List<Chart> list = cache.GetObject<List<Chart>>(key);
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Chart>("order by seq asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- public static List<Chart> GetList(int cid, SiteTypeEnum siteType = SiteTypeEnum.PC)
- {
- string key = string.Format(CacheKeys.SYSTEM_MENUS);
- List<Chart> list = cache.GetObject<List<Chart>>(key);
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Chart>("order by seq asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list.Where(m => m.cid == cid && m.SiteType == siteType).OrderBy(m => m.seq).ToList() ?? new List<Chart>();
- }
- public static Chart GetChart(int id)
- {
- string key = string.Format(CacheKeys.SYSTEM_MENUS);
- List<Chart> list = cache.GetObject<List<Chart>>(key);
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Chart>("order by seq asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list.FirstOrDefault(m => m.chartid == id) ?? new Chart();
- }
- #endregion
- }
- }
|