You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

48 lines
1.5 KiB

using Znyc.CloudCar.IRepository.CardIntro;
using Znyc.CloudCar.IServices.CaChe;
using Znyc.CloudCar.IServices.CardIntro;
using Znyc.CloudCar.Model.Dtos.CardIntro;
using Znyc.CloudCar.Model.ViewModels.ReportsCallBack;
using Znyc.CloudCar.Utility.Extensions;
namespace Znyc.CloudCar.Services.CardIntro
{
public class CardIntroService : ICardIntroService
{
private readonly ICardIntroRepository _cardIntroRepository;
private readonly ICacheService _cacheService;
public CardIntroService(
ICardIntroRepository cardIntroRepository,
ICacheService cacheService
)
{
_cardIntroRepository = cardIntroRepository;
_cacheService = cacheService;
}
/// <summary>
/// 查询优惠卡缓存
/// </summary>
/// <returns></returns>
public async Task<ResponseOutput> GetCardIntroListAsync()
{
var cardIntroes = await _cacheService.GetCardIntroListAsync();
if (cardIntroes.IsNull())
{
cardIntroes = await _cardIntroRepository
.Where(x => x.State == 10 && x.IsEnabled == true && x.IsDeleted == false)
.OrderBy(x => x.Sort)
.ToListAsync<CardIntroOutput>();
await _cacheService.SetCardIntroListAsync(cardIntroes);
}
return new ResponseOutput()
{
Data = cardIntroes,
Successed = true,
Code = 1
};
}
}
}