添加项目文件。
This commit is contained in:
101
Atomx.Data/CacheServices/StoreLevelCacheService.cs
Normal file
101
Atomx.Data/CacheServices/StoreLevelCacheService.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
//using Microsoft.EntityFrameworkCore;
|
||||
|
||||
//namespace Atomx.Data.CacheServices
|
||||
//{
|
||||
// public partial interface ICacheService
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 获取店铺等级列表
|
||||
// /// </summary>
|
||||
// /// <param name="reload"></param>
|
||||
// /// <returns></returns>
|
||||
// Task<List<StoreLevel>> GetStoreLevels(bool? reload = null);
|
||||
|
||||
// /// <summary>
|
||||
// /// 通过ID获取或更新缓存
|
||||
// /// </summary>
|
||||
// /// <param name="id"></param>
|
||||
// /// <param name="data"></param>
|
||||
// /// <returns></returns>
|
||||
// Task<StoreLevel> GetStoreLevelById(long id, StoreLevel? data = null);
|
||||
|
||||
// /// <summary>
|
||||
// /// 通过ID获取店铺登记
|
||||
// /// </summary>
|
||||
// /// <param name="id"></param>
|
||||
// /// <param name="reload"></param>
|
||||
// /// <returns></returns>
|
||||
// Task<StoreLevel> GetStoreLevel(long id, bool? reload = false);
|
||||
// }
|
||||
// public partial class CacheService : ICacheService
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 获取店铺等级列表
|
||||
// /// </summary>
|
||||
// /// <param name="reload"></param>
|
||||
// /// <returns></returns>
|
||||
// public async Task<List<StoreLevel>> GetStoreLevels(bool? reload = null)
|
||||
// {
|
||||
// var cacheData = await GetCacheAsync<List<StoreLevel>>(CacheKeys.StoreLevel);
|
||||
// if (cacheData == null || reload.HasValue)
|
||||
// {
|
||||
// var data = _dbContext.StoreLevels.Where(p => p.Enabled).ToList();
|
||||
// if (data.Any())
|
||||
// {
|
||||
// cacheData = data;
|
||||
// await SetCacheAsync(CacheKeys.StoreLevel, cacheData);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return cacheData;
|
||||
// }
|
||||
// public async Task<StoreLevel> GetStoreLevelById(long id, StoreLevel? data = null)
|
||||
// {
|
||||
// var cacheData = await GetStoreLevels();
|
||||
// if (cacheData == null || data != null)
|
||||
// {
|
||||
// var storeLevel = cacheData.SingleOrDefault(p => p.Id == id);
|
||||
// if (storeLevel != null)
|
||||
// {
|
||||
// cacheData.Remove(storeLevel);
|
||||
// cacheData.Add(data);
|
||||
// await SetCacheAsync(CacheKeys.StoreLevel, cacheData);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// cacheData.Add(data);
|
||||
// await SetCacheAsync(CacheKeys.StoreLevel, cacheData);
|
||||
// }
|
||||
// }
|
||||
// var level = cacheData.SingleOrDefault(p => p.Id == id);
|
||||
// return level;
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
// /// 通过ID获取店铺登记
|
||||
// /// </summary>
|
||||
// /// <param name="id"></param>
|
||||
// /// <param name="reload"></param>
|
||||
// /// <returns></returns>
|
||||
// public async Task<StoreLevel> GetStoreLevel(long id, bool? reload = false)
|
||||
// {
|
||||
// var cacheData = await GetStoreLevels();
|
||||
// var reloadData = reload.HasValue ? reload.Value : false;
|
||||
|
||||
// if (cacheData == null || reload == true)
|
||||
// {
|
||||
// var storeLevel = cacheData.SingleOrDefault(p => p.Id == id);
|
||||
// if (storeLevel != null)
|
||||
// {
|
||||
// cacheData.Remove(storeLevel);
|
||||
// }
|
||||
|
||||
// var level = _dbContext.StoreLevels.SingleOrDefault(p => p.Id == id);
|
||||
// cacheData.Add(level);
|
||||
// await SetCacheAsync(CacheKeys.StoreLevel, cacheData);
|
||||
// }
|
||||
// var data = cacheData.SingleOrDefault(p => p.Id == id);
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user